lkml.org 
[lkml]   [2004]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectwaiting on a condition
Date
L.S.

I'd like to do something similar as can be done using a POSIX condition
variable in the kernel, i.e. wait for some condition to become true. The
pthread_cond_wait() function allows atomically unlocking a mutex and
waiting on a condition. I think I should do something like:
(the condition is updated from an interrupt handler)

disable interrupts
acquire spinlock
if condition not satisfied
add task to wait queue
set task to sleep
release spinlock
restore interrupts
schedule

Now, this will only work with preemption disabled within the critical
section. How would something like this be done whith preemption
enabled?


--ms




-
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 14:07    [W:0.052 / U:6.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site