LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-23-2004, 06:07 AM   #1
DavidW567
LQ Newbie
 
Registered: Nov 2004
Posts: 17

Rep: Reputation: 0
What is the equivalent of Windows events in Linux


Hi

I have to convert an MFC program to Linux.

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.

Thanks
David
 
Old 12-23-2004, 07:06 AM   #2
Marius2
Member
 
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 276

Rep: Reputation: 31
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).
 
Old 12-23-2004, 07:09 AM   #3
hobbestec
LQ Newbie
 
Registered: Nov 2003
Location: Boston, MA
Distribution: Debian, Ubuntu, Fedora
Posts: 27

Rep: Reputation: 15
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.
 
Old 12-23-2004, 07:31 AM   #4
DavidW567
LQ Newbie
 
Registered: Nov 2004
Posts: 17

Original Poster
Rep: Reputation: 0
I am not using a gui tool kit.
The code is for a DLL (shared library) it does not need a gui.

David
 
Old 12-23-2004, 08:01 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
linux isn't event-driven so there's no equivalent.
maybe you could use signals?
send a signal to the process from another?
 
Old 12-23-2004, 09:58 AM   #6
bm17
Member
 
Registered: Sep 2004
Location: Santa Cruz, CA, USA
Distribution: Redhat 9.0
Posts: 104

Rep: Reputation: 15
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".

Sorry to be long winded.
 
Old 12-23-2004, 10:12 AM   #7
DavidW567
LQ Newbie
 
Registered: Nov 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks for the reply.

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.

Spooky about VMS/WNT reminds me of IBM/HAL.

David
 
Old 12-24-2004, 03:15 AM   #8
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
It wasn't long-winded bm17, it was very interesting.
After all we log in here to try and help people and learn
something too.

It's a shame this fellow went to help the dark side tho'.

Imagine if his talents were used for good instead of evil.





billy
 
Old 12-24-2004, 05:14 PM   #9
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32
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. (?)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux equivalent to Windows Explorer sjia Linux - Software 22 10-13-2013 04:32 AM
Windows Notepad Equivalent in Linux? Bob5 Linux - Software 21 09-16-2013 02:43 AM
What equivalent of MSDN (in MS Windows ) is in Linux Igor007 Programming 9 05-15-2009 09:35 AM
Linux equivalent to windows registry? marri Linux - Newbie 10 07-22-2004 12:07 AM
linux equivalent of the path in windows mep]-[isto Linux - Newbie 10 11-21-2003 03:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration