Solved

Code for Q functions?

Posted on 1998-04-22
5
167 Views
Last Modified: 2010-04-10
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).
0
Comment
Question by:tflai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 4

Author Comment

by:tflai
ID: 1163271
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
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1163272
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
 
LVL 4

Author Comment

by:tflai
ID: 1163273
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
 
LVL 4

Author Comment

by:tflai
ID: 1163274
Please wait for the grading till after I obtained the book.  Thanks.
0
 
LVL 4

Author Comment

by:tflai
ID: 1163275
Got it.  A terrific book indeed.  Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question