Help: timer_create() blocks all system?!
Alex
kbyte at iol.pt
Wed Apr 7 11:54:47 UTC 2004
Hi,
I am trying to use timers in rtems. I have the following sample:
#include <bsp.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef _POSIX_TIMERS
#error "rtems is supposed to have timer_create"
#endif
void sigalarm(int signo, siginfo_t*extra, void*cruft)
{
printf( "\nSIGALARM CALLED...\n");
}
timer_t mytimer;
rtems_task Init(rtems_task_argument ignored)
{
struct sigevent evp;
int result;
struct itimerspec ts;
int i;
sigset_t sigmask;
//0. signal handler
struct sigaction act;
sigemptyset(&act.sa_mask);
act.sa_flags=SA_SIGINFO;
act.sa_sigaction=sigalarm;
if(sigaction(SIGRTMIN,&act,NULL) <0)
{
printf( "\nsigaction error...\n");
exit(0);
}
//1. Create timer
evp.sigev_notify = SIGEV_SIGNAL;
evp.sigev_signo = SIGRTMIN;
evp.sigev_value.sival_ptr=(void*) &mytimer;
printf( "\nBefore timer_create...\n");
result = timer_create(CLOCK_REALTIME, &evp, &mytimer );
printf( "\nAfter timer create...\n");
//2. Start Timer
ts.it_interval.tv_sec=5;
ts.it_interval.tv_nsec=10000;
ts.it_value=ts.it_interval;
result=timer_settime(mytimer,0,&ts,NULL);
printf( "\nAfter timer settime...\n");
for(i=0;i<200000;i++) ;
sigemptyset(&sigmask);
sigsuspend(&sigmask);
printf( "\nSome signal has arrived...\n");
timer_delete(mytimer);
exit(0);
}
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_MAXIMUM_POSIX_TIMERS 10
#define CONFIGURE_MAXIMUM_TIMERS 10
#define CONFIGURE_MAXIMUM_RTEMS_TIMERS 10
#define CONFIGURE_INIT
#include <confdefs.h>
/* end of file */
Why the program hangs in the timer_create() POSIX function?
Any help?
In the mailling list I saw a message with a doubt like this one
but doent helped me... :-(
Thanks in advance...
Alex
PS: I am a beginner in RTEMS world
BSP=i686
Alex
___________________________________________________________________________________________
IOL Flash. A net normal em versao acelerada.
Promocao: Ligue-se a Internet pelo IOL Flash e ganhe um Vale de 10 da Galp!
Saiba como: http://www.iol.pt/central_utilizador/iol_flash/promocao.php
More information about the users
mailing list