LinuxQuestions.org
Review your favorite Linux distribution.
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 04-05-2018, 10:51 AM   #1
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 119

Rep: Reputation: 11
Request tutorial for event programming


Novice to Linux, Eclipse Helios Service Release 2

I am looking into interrupt driven programming and have not “recognized” any articles providing a good discussion for Linux. (Note that I wrote “recognized.”)

In my head that means something like: task A has made a call to the OS stating that it wants to be notified when events 1, 2, or 3 gets set. Then it hits a line of code that says wait for event. It stops all processing.

At some time task B sets one or more of those events. Task B might be the OS itself.

When that happens Task A is restarted by the OS at the next line of code the wait statement. There it checks to see which event was set and takes appropriate action, to include resetting the event.

I see some answers that reference epoll, but that would be an oxymoron. Event programming gets rid of polling. I see FDs, file descriptors, but those are positive integers and I don't recognize how to get into them to specify events.

I am not recognizing anything that looks like it says: Declare events like (this), set events like (this), wait for them like (this), and reset them like (this).

Links to tutorials or names of books will be appreciated.
 
Old 04-05-2018, 06:59 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 & 7
Posts: 2,966

Rep: Reputation: 794Reputation: 794Reputation: 794Reputation: 794Reputation: 794Reputation: 794Reputation: 794
I've been using libevent to handle this stuff for me.
 
Old 04-05-2018, 10:24 PM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,503

Rep: Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080
what do you mean by "event"?
Note: select(2) and poll(2) don't actually poll, they just wait for some activity on the specified file-handles.
 
Old 04-06-2018, 09:33 AM   #4
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 119

Original Poster
Rep: Reputation: 11
Quote:
Originally Posted by NevemTeve View Post
what do you mean by "event"?
Note: select(2) and poll(2) don't actually poll, they just wait for some activity on the specified file-handles.
Event: a thing that happens, especially one of importance.
Examples: A keystroke is detected from a keyboard, a socket read or write has completed, Program A is executing a specific line of code and requests and that operating system take note of that so other programs will be aware that has occurred thereby synchronizing two or more applications.

Side comment: While I will look into poll(2) this is worth nothing for future use. Many programmers don't realize the importance of using clear and precise names. The use of the name poll() for an activity that does not poll is rather poor programming practice. Every time a person with a good command of the English language and with programming skills looks at code that says "poll()" they will, or should, immediately think of a polling operation. As that function does not poll, the use of the phrase "poll" is quite bad programming practice. Now, that name is embedded into the system and will probably never change. That rather badly chosen name will be with us for a long time.

I take the time to write this so that maybe one or more programmers will think just a little bit more and spend just a few more seconds creating well named functions and variables.

Back to the regularly scheduled question:

Program Decom spawns a task named Ethernet_Ingest to capture data via an Ethernet socket and get that data into one of two alternating buffers. Freed of that significant task, the main program waits for an event from Ethernet_Ingest signifying that buffer A has fresh data. When the event is received it examines the appropriate buffer, extracts some chunk of data and hands it off. Then it waits for the next event from Ethernet_Ingest. It does not poll, it suspends its operations and waits until the event is set.

How do I set up this communications between the main program and task Ethernet_Ingest?

I suspect a few people have been kind enough to document this in detail. I need some help in finding those pages.

Last edited by bkelly; 04-06-2018 at 10:07 AM.
 
Old 04-06-2018, 10:57 AM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: Slackware
Posts: 8,225

Rep: Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343
Quote:
Originally Posted by bkelly View Post
Program Decom spawns a task named Ethernet_Ingest to capture data via an Ethernet socket and get that data into one of two alternating buffers. Freed of that significant task, the main program waits for an event from Ethernet_Ingest signifying that buffer A has fresh data. When the event is received it examines the appropriate buffer, extracts some chunk of data and hands it off. Then it waits for the next event from Ethernet_Ingest. It does not poll, it suspends its operations and waits until the event is set.
Assuming you're using C?

nodejs uses libuv for that. Neovim is moving to libuv.

Note that the architecture behind all event-driven programming is the event loop Wikipedia.

Last edited by dugan; 04-06-2018 at 11:10 AM.
 
Old 04-06-2018, 12:20 PM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,503

Rep: Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080
If this "Ethernet Ingest" is an existing program, you have to read its documentation and/or ask its creators about its usage.

Last edited by NevemTeve; 04-06-2018 at 12:22 PM.
 
Old 04-06-2018, 12:22 PM   #7
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 119

Original Poster
Rep: Reputation: 11
Re: Assuming you're using C?
Yes, I am using C/C++.
Hmmm. Seems to be that the event concept is independent of the programming language. If not obvious to the programmer then it should be there under the covers. Did you intend to indicate otherwise?

The answers here indicate, to me, that the event concept is not fully implemented by the kernel. Or maybe not flexible and easy to use. Libuv is something to download and install as is libevent. If there was not a need for improved event handling code then there would not be a cottage industry of just such code.

I will check back for updates but this has provided the information needed so the problem is resolved.

Thank you for taking the time to post.
 
Old 04-06-2018, 02:04 PM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: Slackware
Posts: 8,225

Rep: Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343Reputation: 3343
I had another look at your problem description. You're thinking of signals, which are a Linux kernel service.

Here's one introductton:

http://www.linuxjournal.com/article/3985
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Barn raising event for Linux tutorial wiki need all of your help Cwashpimp Linux - General 2 08-09-2016 12:06 PM
How to install Gnome 3.2 on Slackware 13.37? (request for little tutorial) vitosky Slackware 2 11-26-2011 09:30 AM
Remote linux x-windows Tutorial request emme0032 Linux - Newbie 3 07-05-2006 09:09 PM

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

All times are GMT -5. The time now is 11:33 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration