ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
In part of it a routine called by an interrupt sets an event, SetEvent().
A separate thread is waiting for that event to be set using WaitForSingleObject() function, before it can carry on.
I cannot find any reference to events in Linux so how would I do this.
AFAIK there is no WaitForSingleObject equivalent in Linux
(I had to do with this in a software port a while ago, don't recall how I solved the problem, probably coded a solution
myself).
I haven't done anything with events since I programmed a mac, but I would suspect that events are handled by the gui toolkit you are using, like X11, GTK, or QT etc.
These "events" are not GUI events. Way back in the old days the VMS operating system used the concept of events like a mutex/semaphore. You could wait() (unix: select()) on a list of events for any or all to complete. event resources were usually associated with device channels (unix: file descriptors). Instead of the contrived functionality of select() which had to be shared by everyone in the process, event were asynchronous and independent so that your library code didn't have to share a select loop with everyone else. Changes to an Event structure could trigger an AST (Asynchronous System Trap), basically a callback directly to your routine. It was extremely cool.
So why am I talking about VMS? Dave Cutler, one ot the main VMS kernel architects for Digital Electronics, left Digital in the late 1990's and went to work for Microsoft as the cheif architect for Windows NT. Windows NT is basically the next generation VMS. In fact, if you take the acronym "VMS" and add 1 to each letter you get "WNT". WinNT went on to become Win2K and WinXP. It has many other originally VMS concepts in it like IRPs (I/O Request Packets) and channels. Before WinNT, Windows was a joke of an OS, little more than a graphical toolkit on top of DOS. Microsoft needed outside help to build a real OS.
Anyways, it is unfortunate that these WinNT system Events have the same name as GUI events. Unix is not generally sophisticated enough to handle these concepts in a general purpose way. How you want to emulate Events depends on your scheduling needs. Your best best is to use pthreads (POSIX threads). These threads have several mechanisms for communicating between themselves, including mutexes (mutices?). pthread_cond_wait() is probably what you are looking for. Try doing a google search on "pthread communication".
I am using pthreads already and will investigate it futher.
I am also looking at signals, as a previous message suggested.
I have been writing Windows programs since v3.0 but only started on Linux 2 months ago. There is alot to learn about the differences. It has been very interesting if at times frustrating, trying to match functions I have used for along time with there equivalent in Linux, and not always finding them.
David, you might also have a look at wxWindows. Yes, it's a GUI toolkit, but also, IIRC it's very much like MFC. Perhaps you can make use of just the non-gui portion that you require. (?)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.