--- libaitsched/example/test_time.c 2012/05/10 14:30:31 1.1.2.1 +++ libaitsched/example/test_time.c 2012/05/30 08:52:45 1.3 @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -27,6 +27,12 @@ void *timer(sched_task_t *arg) return NULL; } +void *alarmz(sched_task_t *arg) +{ + printf("Alarm %ld sec::\n", (intptr_t) TASK_ARG(arg)); + return NULL; +} + void *once(sched_task_t *arg) { printf("once::\n"); @@ -47,7 +53,7 @@ main(int argc, char **argv) { sched_root_task_t *root; struct timespec ts = { 20, 0 }; - struct timespec p = { 0, 10000000 }; +// struct timespec p = { 0, 10000000 }; signal(SIGTERM, sig); @@ -83,9 +89,36 @@ main(int argc, char **argv) return 4; } + if (!schedAlarm(root, alarmz, (void*) ts.tv_sec, ts, NULL, 0)) { + printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); + return 5; + } else { + ts.tv_sec = 3; + ts.tv_nsec = 500000000; + } + + if (!schedAlarm(root, alarmz, (void*) ts.tv_sec, ts, (void*) 1, 0)) { + printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); + return 5; + } + if (!schedAlarm(root, alarmz, (void*) ts.tv_sec, ts, (void*) 2, 0)) { + printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); + return 5; + } else { + ts.tv_sec = 0; + ts.tv_nsec = 700000000; + } + if (!schedAlarm(root, alarmz, (void*) ts.tv_sec, ts, (void*) 3, 0)) { + printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); + return 5; + } + schedCallOnce(root, once, "000000", 42, NULL, 0); - schedPolling(root, &p, NULL); + printf("read_queue=%d timer_queue=%d\n", + ROOT_QUEUE_EMPTY(root, read), ROOT_QUEUE_EMPTY(root, timer)); + +// schedPolling(root, &p, NULL); schedRun(root, &Kill); schedEnd(&root); return 0;