version 1.3, 2012/05/30 08:52:45
|
version 1.3.2.1, 2012/05/31 14:45:10
|
Line 1
|
Line 1
|
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <sys/types.h> |
#include <sys/types.h> |
Line 23 void *eventlo(sched_task_t *arg)
|
Line 24 void *eventlo(sched_task_t *arg)
|
|
|
void *timer(sched_task_t *arg) |
void *timer(sched_task_t *arg) |
{ |
{ |
printf("Timer %ld sec::\n", (intptr_t) TASK_ARG(arg)); | printf("Timer %d sec::\n", (int) TASK_ARG(arg)); |
return NULL; |
return NULL; |
} |
} |
|
|
void *alarmz(sched_task_t *arg) |
void *alarmz(sched_task_t *arg) |
{ |
{ |
printf("Alarm %ld sec::\n", (intptr_t) TASK_ARG(arg)); | printf("Alarm %ld sec::\n", (u_long) TASK_ARG(arg)); |
return NULL; |
return NULL; |
} |
} |
|
|
|
void *node(sched_task_t *arg) |
|
{ |
|
printf("Node %s\n", (char*) TASK_ARG(arg)); |
|
return NULL; |
|
} |
|
|
|
void *proc(sched_task_t *arg) |
|
{ |
|
printf("Proc pid=%ld\n", TASK_VAL(arg)); |
|
return NULL; |
|
} |
|
|
|
void *sigz(sched_task_t *arg) |
|
{ |
|
printf("Signal signal=%ld\n", TASK_VAL(arg)); |
|
return NULL; |
|
} |
|
|
|
void *user(sched_task_t *arg) |
|
{ |
|
printf("User trigger id %ld\n", TASK_VAL(arg)); |
|
return NULL; |
|
} |
|
|
void *once(sched_task_t *arg) |
void *once(sched_task_t *arg) |
{ |
{ |
printf("once::\n"); |
printf("once::\n"); |
Line 54 main(int argc, char **argv)
|
Line 79 main(int argc, char **argv)
|
sched_root_task_t *root; |
sched_root_task_t *root; |
struct timespec ts = { 20, 0 }; |
struct timespec ts = { 20, 0 }; |
// struct timespec p = { 0, 10000000 }; |
// struct timespec p = { 0, 10000000 }; |
|
int f = 0; |
|
|
signal(SIGTERM, sig); |
signal(SIGTERM, sig); |
|
|
Line 113 main(int argc, char **argv)
|
Line 139 main(int argc, char **argv)
|
return 5; |
return 5; |
} |
} |
|
|
|
if (!schedUser(root, user, NULL, 42, 0, 0)) { |
|
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
|
return 6; |
|
} |
|
|
|
if (argc > 1) |
|
if (!schedProc(root, proc, NULL, atoi(argv[1]), 0, 0)) { |
|
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
|
return 7; |
|
} |
|
if (argc > 2) { |
|
f = open(argv[2], O_RDWR); |
|
if (f == -1) { |
|
perror("open()"); |
|
return 8; |
|
} |
|
if (!schedNode(root, node, argv[2], f, 0, 0)) { |
|
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
|
close(f); |
|
return 8; |
|
} |
|
} |
|
|
schedCallOnce(root, once, "000000", 42, NULL, 0); |
schedCallOnce(root, once, "000000", 42, NULL, 0); |
|
|
printf("read_queue=%d timer_queue=%d\n", |
printf("read_queue=%d timer_queue=%d\n", |
Line 121 main(int argc, char **argv)
|
Line 170 main(int argc, char **argv)
|
// schedPolling(root, &p, NULL); |
// schedPolling(root, &p, NULL); |
schedRun(root, &Kill); |
schedRun(root, &Kill); |
schedEnd(&root); |
schedEnd(&root); |
|
|
|
if (f > 2) |
|
close(f); |
return 0; |
return 0; |
} |
} |