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 03-04-2008, 08:59 AM   #1
hoshangi
Member
 
Registered: Nov 2007
Posts: 88

Rep: Reputation: 15
problem with timer


hi

I want to excute a function for every 5 msec.

i used threads but i had gotten error

please give me a source code to set the timer for 5 msec
 
Old 03-04-2008, 07:20 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
what lang?
Show us your code & error msgs.
 
Old 03-04-2008, 11:33 PM   #3
hoshangi
Member
 
Registered: Nov 2007
Posts: 88

Original Poster
Rep: Reputation: 15
this is the code i want to excute every 5 msec with signal
but the gdb can't running it a give me an error
please help me



void timer_handler (int signum)
{

RxHdlcPkt();
}

void HardInitTimer(void)
{
struct sigaction sa;
struct itimerval timer;
/* Install timer_handler as the signal handler for SIGVTALRM. */
memset (&sa, 0, sizeof (sa));
sa.sa_handler = &timer_handler;
sigaction (SIGALRM, &sa, NULL);
/* Configure the timer to expire after 1 sec... */
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = 5000;
/* ... and every 5 msec after that. */
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 5000;
/* Start a real timer. It counts down whenever this process is
executing. */
setitimer (ITIMER_REAL, &timer, NULL);


}

void InitOS(void)
{


HardInitTimer();
}
 
Old 03-05-2008, 06:54 AM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Maybe you might want to try using the library sleep() function?

Uh-oh, no you don't -- old eyes did not see "msec;" sorry about that (and all the rest is deleted).

And, later, after actually reading carefully and doing a little research, here's a link to an example program (that works on my Linux machine) that might help point you in the right direction (at least I hope it will help).

Give it a look-see http://publib.boulder.ibm.com/iserie...s/getitime.htm

Last edited by tronayne; 03-05-2008 at 10:22 AM.
 
Old 03-12-2008, 05:08 AM   #5
hoshangi
Member
 
Registered: Nov 2007
Posts: 88

Original Poster
Rep: Reputation: 15
thanks

thanks my friend
but i can't find Qp0sDisableSignals or Qp0sEnableSignals functions

can you give me an excutable code for signals please use this functions




thanks
 
  


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
How can I get LAPIC timer to run instead of the PIT timer? sixerjman Linux - Kernel 1 10-16-2007 09:59 PM
Multimedia timer (SMP friendly timer) bigqueso Linux - Kernel 0 03-15-2007 03:49 PM
problem in /usr/include/linux/timer.h santhosh.linux Linux - Software 0 12-01-2005 10:49 PM
Timer Deadlock problem in timer_create and delete_timer nkk4u Programming 0 04-15-2005 02:10 AM
clock timer problem Half_Elf Linux - General 2 10-02-2004 05:19 PM

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

All times are GMT -5. The time now is 02:25 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