On Tue, 15 Sep 1998, Andres Kroonmaa wrote:
> And how do you signal threads?
Using cond_signal. The current code works as follows. When a request is
enqueued and there are threads waiting, I send a cond_signal. The condition
predicate is "queue is not empty". A [single] mutex protects a queue of
requests. Enqueue/dequeue/wait operations require locking (wait and dequeue
share the lock, of course). There are only two queues: wait_queue (incoming
requests) and done_queue (processed requests). The second queue requires no
cond_waiting and dequeues all requests at once. A thread gets requests from
wait_queue and puts them into done_queue. Main thread does the opposite.
This all may change as the code evolves, of course.
Since the old code did not work for us, we had to change a lot of things here
and there. The current code works. Now I am trying to identify where we
improved the old code, and where we did not, and take the best of the two
versions.
> I agree, this 3 sec is not nice. I just don't know your solution to the problem.
See above. The wait on the queue predicate is not timed, and there is no
polling of threads to queue new or dequeue processed requests.
> what pages?
Pthread man pages on IRIX and DEC pthread manual on the Web at
http://www.unix.digital.com/faqs/publications/base_doc/DOCUMENTATION/V40D_HTML/V40D_HTML/AQ2DPDTK/DOCU_029.HTM
I guess, they all comply with the POSIX standard in that part so I expect
others to say the same.
Alex.
Received on Tue Jul 29 2003 - 13:15:54 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:55 MST