LinuxQuestions.org
Review your favorite Linux distribution.
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 04-02-2003, 01:40 AM   #1
poojamanu
LQ Newbie
 
Registered: Apr 2003
Posts: 1

Rep: Reputation: 0
Question using timer for repeated function calls


In a VMS program I am using a timer function to call other function repeatedly .the syntax for the timer function is -:


set_timer(atoi(translate_logical("lnm$group","BACKUP_INTVAL",WARNING)),backup_data,0,FATAl);


where the backup_data is the function to be called repeatedly
Now I have to change this code as per linux programming in C.


atleast send a useful timer code to implement in linux for calling the functins repeatedly.
please help me out .I need it urgently
 
Old 04-09-2003, 08:17 PM   #2
AltF4
Member
 
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
check:
http://www.dilnetpc.com/mht-dp04.pdf


---------------------------------------------------------------------
// timertst1.c: Simple timer demo program. Use cross-gcc .
// Vers. 1.00 - 21.Oct. 2002
// k.d.walter@t-online.de
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
// This is a timer handler.
void timerHandler (int signum)
{
static int counter= 0;
printf ("timerHandler: counter= %d\n", counter++);
fflush (stdout);
}
// This is the one and only main function.
int main (void)
{
struct sigaction sa;
struct itimerval timer;
// Install the timer handler...
memset (&sa, 0, sizeof (sa));
sa.sa_handler= &timerHandler;
sigaction (SIGALRM, &sa, NULL);
// Configure the timer to expire every 100 msec...
timer.it_value.tv_sec= 0; // First timeout
timer.it_value.tv_usec= 100000;
timer.it_interval.tv_sec= 0; // Interval
timer.it_interval.tv_usec= 100000;
// Start timer...
setitimer (ITIMER_REAL, &timer, NULL);
// Do noting...
while (1)
sleep (10);
}
 
  


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
Hacking Win32 exe files ? (removing INT15 timer CALLS) for wine compatability qwijibow Linux - Software 5 06-24-2004 11:57 AM
timing function calls in C? (recvfrom() on Pentium II) pingswept Programming 4 05-24-2004 07:55 AM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM
libc function calls h/w Programming 4 02-13-2004 03:00 PM
Repeated GetModeLine calls in RH8 AshleyK Red Hat 0 09-16-2003 01:18 AM

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

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