Events vs. Condition Variables

Started by
10 comments, last by Shannon Barber 20 years, 5 months ago
Hi,

I recently program with multi-threads (for about 1 year) under Linux only. I tried to follow your discussion. I will just tell my point of view, just to enlarge my understanding.

quote:Original post by Anonymous Poster
One thing i''ve noticed is the inherit latency of event based systems. Even though they usually are simpler and more efficient than a traditional polled or slot/signal approach, they suffer from higher latencies. For most applicaitons, I dont think this is a major issue, and in all cases an event based implementation can be reduced down into a more direct slot/signal implementaiton, with the tradeoff in compleixty and size.


Isn''t that latency that failed with the cpu battle between AMD and Intel ?
Latency is a real problem because your cpu do nothing, and may surely have better things to do.

quote:
Defintely using mutex for multithreaded data protection is a good idea, as that is their function. However using these object to handle flow of control distributedly and asychonrously, proably is not the best technique. I''ve found events to fill that role more efficiently, from my limited expereince.

-ddn


Yes, but I think again, seemly as above, that mutexes and condition waitings could do the same work with lower latency.
Flows depends on the data; and this may be an important thing for me: if you do events for handle flows, you must protect your data with something like mutex, otherwise, you may suffer from synchronization problem. Your flow may not be read at the same speed and frequency than its writting.

I surely may be wrong, this will permit me to understand why.

thank you.
Advertisement
quote:SiCrane
Finally found the paper (took me forever because I was off by year):

Per Brinch Hansen, Concurrent Programming Concepts, ACM Computing Surveys, Vol. 5, No. 4, December, 1973.


I believe you need to have an account with the ACM in order to get at the full text though.


Probably about time I opened an account.

...
OT
The AP was talking about two different sorts of events - signaling events such as posix condition variables and Win32 Event objects which will either use far less CPU time or have less latency than polling systems.

Event driven programming is something different though related; you have a queue in which you post messages and sometime later the state machine processes the posted events. To operate efficiently, an Event object is used internal to the message queue, so the state machine is awoken to do work only when there is a message to do work on. This (obviously) has more latency than direct invocation, but also makes you to design the system to work in ''virtual time'' instead of ''real time'' which has advantages. (Unless you need real-time, and video games are _not_ real-time applications. They are "online" meaning the processing is done as data is made available but it is not a critical fault if the data in not processed by a deadline. All we need is a nominal level of performance, not a guaranteed level; ergo variable frame-rates).
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement