ADD_TIMER(9) Driver Basics ADD_TIMER(9)NAME
add_timer - start a timer
SYNOPSIS
void add_timer(struct timer_list * timer);
ARGUMENTS
timer
the timer to be added
DESCRIPTION
The kernel will do a ->function(->data) callback from the timer interrupt at the ->expires point in the future. The current time is
'jiffies'.
The timer's ->expires, ->function (and if the handler uses it, ->data) fields must be set prior calling this function.
Timers with an ->expires field in the past will be executed in the next timer tick.
COPYRIGHT Kernel Hackers Manual 3.10 June 2014 ADD_TIMER(9)
Check Out this Related Man Page
pods::SDL::Time(3pm) User Contributed Perl Documentation pods::SDL::Time(3pm)NAME
SDL::Time - An SDL Perl extension for managing timers
CATEGORY
Core
SYNOPSIS
use warnings;
use strict;
use threads;
use threads::shared;
use SDL::Time;
package foo;
use SDL ':all';
SDL::init(SDL_INIT_TIMER);
my $tick :shared = 0;
sub ticker { $tick++; warn $tick; return 100; }
package main;
my $id = SDL::Time::add_timer(100, 'foo::ticker');
sleep(2);
SDL::Time::remove_timer($id);
METHODS
add_timer
my $id = SDL::Timer::add_timer( $ms_interval, $callback );
This runs in a separate thread and a cloned Perl thread. "threads" and "threads::shared" must be used to share any variables the timer
uses.
The $callback function, specified with a string of the function's name, will be called after the milliseconds of $interval have elapsed.
The actual delay may be longer than specified depending on the underlying OS. The callback function is passed the current timer interval
as well as the $interval parameter and should return the next timer interval. If the return value from the callback is 0, the timer is
cancelled; otherwise, the timer will continue to run.
The timer callback function may run in a different thread to your main program, so it shouldn't call any functions from within itself. You
may call SDL::push_event, however.
"SDL::Time::add_timer" returns the identifier value of the generated timer or undef on error.
Note: You must initialize ("SDL::init") the timer subsystem to use this function.
remove_timer
SDL::Timer::remove_timer( $id );
The other way to cancel a timer is to use "SDL::Time::remove_timer" on the $id of a timer. This ID is the return value of the
"SDL::Time::add_timer" function.
"SDL::Time::remove_timer" returns 0 on success or "-1" on error.
AUTHORS
See "AUTHORS" in SDL.
perl v5.14.2 2012-05-28 pods::SDL::Time(3pm)
Hi ,
I am trying to learn timers in linux kernel. I am trying to write a program where I can configure a timer to tick in every 5 seconds and a function should thus exicute in every five seconds. I tried one program with the help of linux/timer.h headerfile but I couldnt get the... (4 Replies)
I'm a beginner to the Linux programming and trying my hands on some device driver examples while practising. The below code (a trimmed down version of tiny_tty.c from ldd3 book) loads perfectly using insmod and I'm able to see it in /proc/tty/drivers , /proc/modules and device nodes are getting... (1 Reply)
I have added a new experimental "Computer Science and Mathematics Trivia - True or False" section in the discussions, currently under the tags box.
In the future, I plan to
Expand this feature to add more trivia categories from math, science and technology.
Keep track of correct and... (20 Replies)