[lkml]   [2012]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: semaphore and mutex in current Linux kernel (3.2.2)
Chen, Dennis (SRDC SW) wrote:
> I know that the rationale of the mutex's optimization is, if the lock owner is
> running, it's likely to release the lock soon. So make the waiter to spin a
> short time waiting for the lock to be released is reasonable given the workload
> of a process switch.
> But how about if the lock owner running doesn't release the lock soon?

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();
> }
> ...
> }
> [experiment]
> 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 ...


 \ /
  Last update: 2012-04-05 16:15    [W:0.076 / U:0.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site