WaitForSingleObject for Linux
Hello, i'm a Linux programming newbie. I developed several programs for Windows and i often use WaitForSingleObject and WaitForMultipleObjects in my programs. Is there a linux implementation of WaitForSingleObject and WaitForMultipleObjects? Or, how can i wait for multiple objects (event, semaphores, etc) ? Thanks, A. Roth
On Wednesday 23 April 2003 14:10, Andreas Roth wrote:
i'm a Linux programming newbie. I developed several programs for Windows and i often use WaitForSingleObject and WaitForMultipleObjects in my programs. Is there a linux implementation of WaitForSingleObject and WaitForMultipleObjects?
There is no real equivalent. This is the one single issue where the Win32 API is better designed than the Linux/Unix POSIX API (which is a lot older than Win32). You cannot wait for all kinds of different objects at the same time; there are specific system calls to wait for different kinds of events. select() (it waits for sockets - see "man 2 select") comes close, but it can only wait for I/O events. Most windowing toolkits (Qt for one) provide an easy-to-use interface that integrates waiting for user sockets with waiting for windowing events (most windowing toolkits use nothing else than select() internally).
Or, how can i wait for multiple objects (event, semaphores, etc) ?
This usually only works if you stick with one toolkit. Qt for example provides
QMutex, QSemaphore, QSocket etc. that emulate that behaviour.
In general, however, this doesn't work. POSIX provides the semop() system call
that waits for semaphores, select() that waits for sockets(), wait() that
waits for child processes etc. - different wait system calls that wait for
different things.
Hope this helps.
CU
--
Stefan Hundhammer
On Wed, 23 Apr 2003 14:10:05 +0200
"Andreas Roth"
i'm a Linux programming newbie. I developed several programs for Windows and i often use WaitForSingleObject and WaitForMultipleObjects in my programs. Is there a linux implementation of WaitForSingleObject and WaitForMultipleObjects? Or, how can i wait for multiple objects (event, semaphores, etc) ?
I think this is answered in the context of Linux (and QT), but you may
consider sticking with the Windows API and using the WINE library
directly. http://www.winehq.org/
Several commercial packages have used the WINE library to port their
products to Linux,
As far as QT is concerned, it is a more dynamic interface than Windows.
You register a function to be called when an event occurs. You do not
need to set up your own dispatcher. (If I recall from the last time I
wrote a Windows app, you had to determine what the event was and invoke
the appropriate function).
Also, you can write a QT based app and run it on Windows.
--
Jerry Feldman
participants (3)
-
Andreas Roth
-
Jerry Feldman
-
Stefan Hundhammer