I'm writing a timer for a client. It can send data every 100ms and receive every 150. It's an AI project so I *don't* want to fork() and pipe or go multi threaded, use interupts etc.
Using linux, gcc 4.3.2
The code I have:
It's fairly ugly I know, but when I run it normally, the output is fairly unexpected. 'elapsed' turns to negative numbers after about 2 seconds and if I take out the first printf ('printf("curUsecs: %d....') then it dumps 7 or 8 lines, then nothing for a while and dumps some more or occasionally doesn't dump anything if I've mess arround a bit more. If I pipe it out to less or redirect output to a file insead of stdout then the results seem to be fine but I can't test it to make sure it is actually kicking in about every two seconds.
Is this a printf thing? Have I done something stupid? Is there an easier way to time things? (I was using clock() orriginally but I can't simulate more than one agent per cpu that way). How do I know it won't do this in the middle of execution?
Many thanks
Sam
Last edited by scazz; 01-13-2010 at 12:13 PM..
Reason: Missed line of code above for loop
I'm trying generate an interrupt every 1 seconds using itimer and My clock is not running. This is what i did :
printf("about to sleep for 1 second \n");
signal(SIGALRM, wakeup);
//myTimer.it_interval.tv_sec=0;
//myTimer.it_interval.tv_usec =0;
... (5 Replies)
anyone can help me how to implement the timer on AIX?
I tried with 'setitimer' and its related functions, but it does not work correctly,the program exited each time.
thanks (2 Replies)
Hi!,
My shell script takes a quite a long time to execute.. Nothing appears on the screen during this period.. User are left guessing... whats going on????????????
Any ideas on how to create a small timer script which print a word on screen say " wait.. Program running" after every 10 seconds... (3 Replies)
Hi all,
Wanted to a create a shell script
-----------------------------------------------------------------------
1) which when called will start a timer and wait for 48 hours.
after 48 hours it will call some function(say XYZ)
2) Whenever this shell script is called (can be called... (3 Replies)
Hello fellows,
I am new in this forum, i would appreciate your assistance.
I need a timming system for my vnc desktops (Cybercafe timer stuff).
Each unix user login to my server only with vnc, and i want to write a program that can generate timer tickets and have control on the time used for... (0 Replies)
Hello fellows,
I am new in this forum, i would appreciate your assistance.
I need a timming system for my vnc desktops (Cybercafe timer stuff).
Each unix user login to my server only with vnc, and i want to write a program that can generate timer tickets and have control on the time used for... (1 Reply)
hello all
since a process running in kernel mode cannnot be preempted by any other process what would be the status of Timer interrupt that occurs when the time quantum of a process is elapsed?
thanks (2 Replies)
How do you set timer as output to the command line so that you get an output like
Has been waiting for 5 seconds
Has been waiting for 6 seconds
...
Where only the number changes. (2 Replies)
Discussion started by: locoroco
2 Replies
LEARN ABOUT SUSE
install_int
install_int(3alleg4) Allegro manual install_int(3alleg4)NAME
install_int - Installs a user timer handler. Allegro game programming library.
SYNOPSIS
#include <allegro.h>
int install_int(void (*proc)(), int speed);
DESCRIPTION
Installs a user timer handler, with the speed given as the number of milliseconds between ticks. This is the same thing as
install_int_ex(proc, MSEC_TO_TIMER(speed)). If you call this routine without having first installed the timer module, install_timer() will
be called automatically. Calling again this routine with the same timer handler as parameter allows you to adjust its speed.
RETURN VALUE
Returns zero on success, or a negative number if there is no room to add a new user timer.
SEE ALSO install_timer(3alleg4), remove_int(3alleg4), install_int_ex(3alleg4), install_param_int(3alleg4), exscn3d(3alleg4), exswitch(3alleg4),
extimer(3alleg4), exzbuf(3alleg4)Allegro version 4.4.2 install_int(3alleg4)