Code for Q functions?

Anybody want to post code or URL to code for generic Q functions:
1)  AddQ() will signal an internal event.
2)  RemoveQ() will wait on the event or timeout.
But the trick is that it will work even under scenerio of multiple producers and/or multiple consumers on the Q (multi-thread).
LVL 4
tflaiAsked:
Who is Participating?
 
Tommy HuiConnect With a Mentor EngineerCommented:
One very good book I've seen on this subject is Win32 Multithreaded Programing, published by O'Reilly. It has a jellyfish on the cover. It provides code for what you're trying to do. Take a look at their website to see if they have the code online. http://www.oreilly.com.
0
 
tflaiAuthor Commented:
Hmm...  This may sound to some experts as yet another homework.  I'd better clear it up.
I've already have a generic Q functions written.  There is just some little confusion on RemoveQ(), in particular.  It used to be something like the following psuedo-code:
while 1 loop
  enter critical section
  remove head element from the list
  if list is empty reset the event
  leave critical section
  return the list element if it was there
  wait on the event with certain timeout
end while

0
 
tflaiAuthor Commented:
Thank you for the quick response.  I'll see if my co-workers or anyone that I know has it.  (The website does not have online code on this topic.)
0
 
tflaiAuthor Commented:
Please wait for the grading till after I obtained the book.  Thanks.
0
 
tflaiAuthor Commented:
Got it.  A terrific book indeed.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.