hi all
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.}

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 }

14.   another producer function is
15.  {
16             take spinlock
17                 produce elements
18                 wake_up_interruptible(wq)
19                release spinlock
20      }



now what happens is on line number 3 if count has come  == 0
then my code shd sleep but before that
code transfers to producer
and code from line 14 to 20 is executed

 and  wake up at line 18 is lost

then code comes to consumer line 4 it sleeps and no one is there to wake it
up ....


i thought that
there shd be some way that before consumer
leave spin lock to producer as it gets to know count == 0
it should sleep ...
but if it does that

take spin lock
count == 0
sleep  till count >0
release spin lock

then how will spin lock be released??

and if
but if i do otherwise

take spin lock
count == 0
*release spin lock

*sleep

but here producer interrupts in between starred lines...


what to do pl help





-- 
Thanks & Regards
Nidhi

Reply via email to