lkml.org 
[lkml]   [2002]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Lightweight userspace semphores...
Hubertus Franke wrote:

> Again, the trick is to not
> sync the state of the kernel and the user level. It comes naturally
> if you properly separate the duties.
>

Your code for usema_down is simply:

int usema_down(ulock_t *ulock)
{
if (!__ulock_down(ulock)) {
return 0;
}
return ulock_wait(ulock,0);
}

This means you do not recheck if the usema is really available after you
return form ulock_wait(), but you may have the following situtation:

Process 1 Process 2 Process 3
down

down
-> call usema_wait
but gets preempted shortly
before it
can enter kernel mode

up
(kernel sema is free)

down -> got it


resume execution,
thinks its also got it
because kernel sema is free!

Now you have two owners!!


Martin Wirth




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:24    [W:0.071 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site