main() { printf("Testing OS abstraction layer\n"); printf("============================\n"); // System init TEST_OK("os_init", os_init()); AllocatorCheck(); TimerCheck(); ThreadCheck(); EventCheck(); EventCheck2(); }
/** * Event Manager thread entry function * * @param ptr pointer to the FThread structure of the event manager * @todo This function waits a maximum of 10 seconds for each event to be completed. FL>PS !!! */ void *EventManagerLoopThread( FThread *ptr ) { EventManager *ce = (EventManager *)ptr->t_Data; //const unsigned long long nano = 1000000000; //unsigned long long t1, t2, lasttime; //struct timespec tm; time_t stime = time( NULL ); time_t etime = stime; do { time_t dtime = etime - stime; CoreEvent *locnce = ce->em_EventList; while( locnce != NULL ) { EventCheck( ce, locnce, stime ); locnce = (CoreEvent *) locnce->node.mln_Succ; } time_t end_time = WAIT_SECOND_1m - dtime; usleep( end_time ); //printf("waiting..... %d\n", end_time ); stime = etime; etime = time( NULL ); } while( ptr->t_Quit != TRUE ); ptr->t_Launched = FALSE; //pthread_exit( 0 ); /* clock_t time = clock(); while( ptr->t_Quit != TRUE ) { clock_t dtime = clock() - time; CoreEvent *locnce = em->em_EventList; while( locnce != NULL ) { // if( locnce->ce_Time. locnce = (CoreEvent *) locnce->node.mln_Succ; } clock_t end_time = (WAIT_SECOND * CLOCKS_PER_SEC ) - dtime; usleep( end_time ); //printf("witing..... %d\n", end_time ); time = clock(); }*/ /* { //clock_gettime( CLOCK_REALTIME, &tm ); t1 = tm.tv_nsec + tm.tv_sec * nano; long long tmp = lasttime+20000-now; if( tmp > 0 ) { usleep( tmp ); } //clock_gettime( CLOCK_REALTIME, &tm ); t2 = tm.tv_nsec + tm.tv_sec * nano; clock_t start_time = clock(); clock_t end_time = sec * 1000 + start_time; printf( "delay: %ld\n", ( t2 - t1 ) / 1000 ); }*/ return NULL; }