Solved

Code for Q functions?

Posted on 1998-04-22
5
164 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
  • 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MSVCR80.dll crash 2 140
C++ get user from AD  (VS6) 7 75
VS2015 compilation and missing DLLs 9 147
Why  my code (program) build with old compiler? 11 47
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

809 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