?
Solved

Code for Q functions?

Posted on 1998-04-22
5
Medium Priority
?
168 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

800 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