Re: [LIP] Thread waiting on multiple conditions
Linux India has been formed for Foster the growth of Linux in India
Brought to you by:
manojmishra,
raju
From: Arun S. <ar...@sh...> - 2001-06-30 17:23:04
|
On Sat, Jun 30, 2001 at 12:36:23PM +0530, Raju Mathur wrote: > Hi, > > A client asked an interesting question: is it possible to make a > pthread wait on multiple conditions (pthread_cond_wait or equivalent) > in Linux using POSIX threads? Apparently there is a call in Winduhs > (WaitForMultipleObjects) which achieves this, and he needs to port his > source from Winduhs to Linux. WaitForMultipleObjects is a more powerful construct than the one you found in the FAQs. Specifically, it can wait on not just pthread condition variables, but also file descriptors, network I/O and just about anything. Your client might be interested in a hybrid between pthread_cond_wait and select(2). Also, if you dig out the old NT wars triggered by Mark Russinovich's winntmag.com article on Linux scalability in the enterprise, you might find some good discussion on the topic. Also, this stuff is being hotly debated at this year's USENIX. http://people.freebsd.org/~jasone/kse/ May be they'll find a way to combine freebsd kqueue(2) with the pthread primitives. As you can see here: http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/linuxthreads/condvar.c?rev=1.30&content-type=text/x-cvsweb-markup&cvsroot=glibc pthread_cond_wait is doing while (1) { suspend(); ... }; -Arun |