#include #include #include #include void FastTask(union sigval obj) { printf("Fast task call.\n"); } void SlowTask(union sigval obj) { printf("Begin the slow and the long execution task call.\n"); sleep(1); printf("End the slow and the long execution task call.\n"); } int main( int argc, char **argv ) { //Create and start the fast timer //- Create fast timer - timer_t tmIdFast; struct sigevent sigev; sigev.sigev_notify = SIGEV_THREAD; sigev.sigev_value.sival_ptr = NULL; sigev.sigev_notify_function = FastTask; sigev.sigev_notify_attributes = NULL; timer_create(CLOCK_REALTIME,&sigev,&tmIdFast); //- Start the fast timer - struct itimerspec itval; itval.it_interval.tv_sec = itval.it_value.tv_sec = 0; itval.it_interval.tv_nsec = itval.it_value.tv_nsec = 200000000; timer_settime(tmIdFast, 0, &itval, NULL); //Create and start the slow and the long execution timer //- Create the slow and the long execution timer - timer_t tmIdSlow; sigev.sigev_notify = SIGEV_THREAD; sigev.sigev_value.sival_ptr = NULL; sigev.sigev_notify_function = SlowTask; sigev.sigev_notify_attributes = NULL; timer_create(CLOCK_REALTIME,&sigev,&tmIdSlow); //- Start the slow and the long execution timer - itval.it_interval.tv_sec = itval.it_value.tv_sec = 2; itval.it_interval.tv_nsec = itval.it_value.tv_nsec = 0; timer_settime(tmIdSlow, 0, &itval, NULL); sleep(10); return 0; }