This is a classical problem with the wait queue that if no one is waiting and other thread signal on the wait queue then the signal lost. They have something call completion which actually count the signals. I dont no the history but I think they has introduced completion to get around the lost signal problem. ajit On Tue, Apr 28, 2009 at 4:19 PM, Matthias Kaehlcke <matthias@xxxxxxxxxxxx> wrote: > El Tue, Apr 28, 2009 at 03:29:27PM +0530 nidhi mittal ha dit: > >> i am stuck here confused how to get out of this >> >> i have this code kind of producer consumer code where consumer waits on >> wait queue >> if some particular list of elements is empty >> >> 1.while(count=count_request < = 0) >> 2.{ >> 3. >> 4.wait_event_interruptible(wq,count>0) >> 5. >> 6.} > > one problem is that count is a variable and will never have a > value > 0 once you entered the loop. in consequence the wakup > condition will never be fullfilled, even if count_request() would > return a value > 0 > > i don't know your real code, but it looks to me that the while loop > isn't what you really want. i suppose you just mean: > > wait_event_interruptible(wq, count_request() > 0) > > the main difference to your version is that the element count is > reevaluated by calling count_request() when the process wakes up. > >> there is a function >> >> 7. count_request() >> 8. { >> 9 take spinlock on list of elements >> 10. count elements >> 11. return count >> 12 . release spinlock >> 13 } > > i hope in the real code you release the spinlock before returning from > the function > > -- > Matthias Kaehlcke > Embedded Linux Engineer > Barcelona > > You must have a plan. If you don't have a plan, > you'll become part of somebody else's plan > .''`. > using free software / Debian GNU/Linux | http://debian.org : :' : > `. `'` > gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `- > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx > Please read the FAQ at http://kernelnewbies.org/FAQ > > -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ