[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4F7EC111.4010608@ladisch.de>
Date: Fri, 06 Apr 2012 12:10:25 +0200
From: Clemens Ladisch <clemens@...isch.de>
To: "Chen, Dennis (SRDC SW)" <Dennis1.Chen@....com>
CC: Ingo Molnar <mingo@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: semaphore and mutex in current Linux kernel (3.2.2)
Chen, Dennis (SRDC SW) wrote:
> On Thu, Apr 5, 2012 at 10:15 PM, Clemens Ladisch <clemens@...isch.de> wrote:
>> It would not make sense to spin too long, especially if some other
>> process wants to run on the same CPU.
>>
>>> int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner)
>>> {
>>> ...
>>> while (owner_running(lock, owner)) {
>>> if (need_resched())
>>> break;
>>>
>>> arch_mutex_cpu_relax();
>>> }
>>> ...
>>> }
>>>
>>> D+ means the App in CPU1 is sleeping in a UNINTERRUPTIBLE state. This is very interesting,
>>> How does this happen?
>>
>> Your experiment shows that there must be some condition that makes the
>> code break out of the spin loop ...
>
> I guess this is related with RCU component, but I don't found the right place where the code
> Located yet.
"On the internet, nobody can hear you being subtle."
If some other process wants to run on the same CPU, needs_resched() is set.
(This might happen to make the cursor blink, for keyboard input, or when
somebody starts a rogue process like ps.)
Regards,
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists