Um teste que voce pode fazer ( em usermode) é utilizar o código abaixo...não sei bem se é a maneira certa de utilizar...
- Código: Selecionar todos
//---------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
//---------------------------------------------------------------------------
void init_timer( void *handler );
static void timer_handler( int signo );
//---------------------------------------------------------------------------
int main( void )
{
//timer handler ==========================
init_timer( &timer_handler );
while(1)
{
}
return 0;
}
//---------------------------------------------------------------------------
void init_timer( void *handler )
{
struct itimerval value;
struct sigaction sa_timer;
//timer handler ==========================
sa_timer.sa_handler = handler;
sa_timer.sa_flags = SA_RESTART;
sigemptyset(&sa_timer.sa_mask);
sigaction( SIGPROF, &sa_timer, NULL );
value.it_interval.tv_sec = 0;
value.it_interval.tv_usec = 10000;
value.it_value = value.it_interval;
setitimer( ITIMER_PROF, &value, NULL );
}
//---------------------------------------------------------------------------
static void timer_handler( int signo )
{
static unsigned int counter = 0x00;
static unsigned int tmp_1s = 0;
//insert your code here - time 10 ms
//1 second timer
if ( tmp_1s > 0 ) tmp_1s--;
else{
tmp_1s = 99;
fprintf(stderr,"counter: %d\n",counter++);
}
}
//---------------------------------------------------------------------------
mas o ideal talvez é criar um /dev/timer0 ...através de um device driver...
o que não é muito difícil não...
[/code]