Discussion:
Implementing waitformultipleobject in Linux
(too old to reply)
Venkat
2003-06-26 08:47:18 UTC
Permalink
Hi All,

Can someone suggest me how can we implement WaitForMultipleObjects API of
windows in Linux.

As we all know WaitForMultipleObjects allows a thread to wait for multiple
synchronization objects at once. It can be set to return when any or all of
the objects become available.

Pls Suggest

Regards
Venkat
Sybren Stuvel
2003-06-26 08:53:00 UTC
Permalink
As we all know WaitForMultipleObjects allows a thread....
Ehm... How many Linux programmers know the windoze API? Do you really
think we're interested in that piece of crap?

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Markus Falkensteiner
2003-06-30 11:00:31 UTC
Permalink
Post by Sybren Stuvel
As we all know WaitForMultipleObjects allows a thread....
Ehm... How many Linux programmers know the windoze API?
i think there a lots of linux programmers who know the windows API!!!
Post by Sybren Stuvel
Do you really
think we're interested in that piece of crap?
sybren,

i'm wondering everytime about your statements. you may be a good linux
developer, sysadmin what ever.
it's strange for me that 80% of your comments are deprecatory against
windows and windows user (maybe former
windows user). the fact that you don't like windows-os is ok, and will be
acceped by everybody.
but i thing giving stupid comments against "windows-people" who have there
knowledge on windows-os and not
on linux is not really necessary. maybe they try to lear the differences
between windows and linux and therefore i think the question of "Venkat" is
accurate for this NG.

i would recommend, next time you would like to give such meaningless answers
write in on a post-it and attach it
on your screen would be a better place than a NG.

max

David Schwartz
2003-06-26 08:53:31 UTC
Permalink
Post by Venkat
Can someone suggest me how can we implement WaitForMultipleObjects API of
windows in Linux.
Any way you want to.
Post by Venkat
As we all know WaitForMultipleObjects allows a thread to wait for multiple
synchronization objects at once. It can be set to return when any or all of
the objects become available.
Exactly. There are many different ways you could do this. Perhaps one
way is for each thread to create its own condition variable to block on and
register a pointer to its condition variable and the events it's interested
in on a linked list. When a thread signals an event, it traverses the linked
list and signals the appropriate condition variables.

This is just one way to do it. Generally the best way is to rearchitect
so that you don't need to use it. Usually the reasons you need
WaitForMultipleObjects just don't apply on Linux. For example, it's commonly
used with I/O operations that signal their completion with an event, but
Linux has no such I/O operations.

Also, due to the way the windows API works, certain jobs sometimes have
to be done by certain threads. So it's not easy to use a single event and a
pool, because the 'wrong' thread might get a task. But there are no such API
functions in Linux, so this doesn't apply.

Perhaps one solution would simply be to have one thread waiting on each
event. You shouldn't have that many events, and if you do, you probably
should just consolidate them. For example, instead of having a 'client X
needs service' event and a 'client Y needs service' event (thus a thread
might need to wait on both of them), just have a 'one or more clients need
service' event. A thread that detects that event can service any one client
that needs it.

DS
Loading...