LinuxQuestions.org
Help answer threads with 0 replies.
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 03-29-2007, 08:34 AM   #1
mailsteam
LQ Newbie
 
Registered: Mar 2007
Posts: 4

Rep: Reputation: 0
posix timers


hi,
I'm using posix timers..is there any way to put argument to the sigevent function other than signum..pls help me
Thanks
 
Old 03-29-2007, 02:43 PM   #2
klopfer
LQ Newbie
 
Registered: Mar 2007
Location: Germany
Posts: 6

Rep: Reputation: 0
hi,
as i know sigevent is a structure, not a function.

Could you describe more clearly what you mean?
 
Old 03-29-2007, 02:54 PM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,176
Blog Entries: 4

Rep: Reputation: 430Reputation: 430Reputation: 430Reputation: 430Reputation: 430
Moved to Programming
 
Old 03-30-2007, 02:44 AM   #4
mailsteam
LQ Newbie
 
Registered: Mar 2007
Posts: 4

Original Poster
Rep: Reputation: 0
struct sigaction act;

sigfillset(&act.sa_mask); /* Set up signal handler */

act.sa_flags = 0;

act.sa_handler = userfunction; //userfunction is set as the function to be + called when a signal event occures.



sigaction(signum, &act, NULL)
struct sigevent se;
se.sigev_notify = SIGEV_SIGNAL;
se.sigev_signo = signum;
se.sigev_value.sival_int = 0;

timer_create(CLOCK_REALTIME, &se, &timer_id)


Here the problem is when the timer fires, only the signum (by default)is available in the userfunction. Can i pass any other arguments other than that.

And also i'm able to use only SIGRTAX number of timers. ie 32 or 64.. but i want to use more than that...say 250 timers at a time

Thanks..

Quote:
Originally Posted by klopfer
hi,
as i know sigevent is a structure, not a function.

Could you describe more clearly what you mean?
 
Old 03-30-2007, 09:14 AM   #5
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
As an aside -

If you have a large number of timers, then you will have timer events going off constantly, possibly creating a lot of timer overruns - meaning more processing time required per jump to the function, since you have to worry about overruns.

I think you have a design problem. What exactly are trying to do?
Somebody here has probably already done it.
 
Old 03-31-2007, 06:14 AM   #6
mailsteam
LQ Newbie
 
Registered: Mar 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Actually i'm trying develop a wrap around for posix timers. So that the application developer can use my timer function instead of using the posix timer directly. And also i need to provide a minimum of 100timers working at a time. Say if a tcp/ip application may need many timers..ie for each packet a timer is assosiated. Its just an example.. Hope u understood the situation.
Thank you..

Quote:
Originally Posted by jim mcnamara
As an aside -

If you have a large number of timers, then you will have timer events going off constantly, possibly creating a lot of timer overruns - meaning more processing time required per jump to the function, since you have to worry about overruns.

I think you have a design problem. What exactly are trying to do?
Somebody here has probably already done it.
 
Old 03-31-2007, 09:40 AM   #7
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Quote:
minimum of 100timers working at a time. Say if a tcp/ip application may need many timers..ie for each packet a timer is assosiated. Its just an example.. Hope u understood the situation.
I'm sorry I just don't understand the logic to your example of why you would need a hundred timers, why would a packet using TCP need a timer? TCP is a connection orientated protocol which guaranties delivery once sent unless the connection is broken. If using UDP and wanting to implement your own guaranteed delivery on top then I could maybe understand the need for a timer, but personally I would still not use a timer as such more a time stamp and a delivery window.
 
Old 05-18-2007, 11:32 PM   #8
jc1118
LQ Newbie
 
Registered: May 2007
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by dmail
I'm sorry I just don't understand the logic to your example of why you would need a hundred timers, why would a packet using TCP need a timer? TCP is a connection orientated protocol which guaranties delivery once sent unless the connection is broken. If using UDP and wanting to implement your own guaranteed delivery on top then I could maybe understand the need for a timer, but personally I would still not use a timer as such more a time stamp and a delivery window.
Your answer to this question is partially right but its also wrong. TCP was designed for connectionless networks. As stated in Tanenbaum's Computer Networks 4th Ed, TCP was specifically designed to provide a reliable end-to-end byte stream over an unreliable network. Over unreliable networks like 802.11 wireless networks packets can get lost and TCP uses timers at the sending end to wait for an acknowledgment. That said I would not call TCP a connection oriented protocol but a connectionless oriented protocol that makes a reliable connection possible over an unreliable network layer. However because the Internet is mostly based on TCP/IP, TCP is also used on connection oriented networks for the purpose of accessing the Internet and people somehow have this assumption that TCP is connection oriented which is wrong.

In general you are right when you say there is no need for a timer on packets when using TCP. However for educational organizations that need to do research on TCP or for a networking class in the Computer Science department of a University that requires a student to implement a transport entity similar to TCP for the purpose of learning, then it becomes practical to have timeouts on packets even if TCP sockets are being used to make connections. I took a course like this at the University of Illinois and I had an assignment similar to this. Timers were absolutely necessary because the requirements called for the ability to emulate an unreliable network layer and to demonstrate knowledge by showing that the transport layer actually does create a reliable byte stream under the conditions of an unreliable network layer. In addition when the assignment calls for the server to support multiple connections, the need for multiple timers is essential because using just one timer will have a negative impact on performance.

Last edited by jc1118; 05-18-2007 at 11:36 PM.
 
  


Reply

Tags
posix, timer


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
Linux timers arabindav Linux - General 3 05-20-2011 07:33 AM
java timers :@ trscookie Programming 6 07-20-2006 10:50 AM
about timers eshwar_ind Programming 1 12-27-2004 09:23 AM
C - Linux - Timers - How? drigz Programming 6 08-30-2004 02:36 PM
Help with Linux timers samble Programming 8 02-07-2004 10:54 PM


All times are GMT -5. The time now is 12:24 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration