On 3/19/07, Arjan van de Ven <arjan@xxxxxxxxxxxxx> wrote:
> > I may be wrong, but from what I understand, the count passed in the > semaphore initialization > > sema_init(sem, count); > > is the number of threads that are allowed to hold the semaphore > simultaneously (no of threads that are allowed to enter their critical > sections simultaneously). So can't a semaphore be actually held > recursively? having multiple holders doesn't imply allowing recursion! just think of this: say you set the count such that 2 holders are allowed. your code then does down(&sem); .... down(&sem); and most of the time this will work. until another instance of your code runs in parallel: cpu 0 cpu 1 down(&sem); down(&sem) ... .... down(&sem); <- dead down(&sem); <- dead at which point you're very deadlocked.
Ah ... I got it ... Thanks! -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ