Annotation of libaitsched/example/test.c, revision 1.1.2.2
1.1.2.1 misho 1: #include <stdio.h>
1.1.2.2 ! misho 2: #include <unistd.h>
! 3: #include <fcntl.h>
! 4: #include <sys/types.h>
! 5: #include <sys/stat.h>
! 6: #include <sys/socket.h>
! 7: #include <netinet/in.h>
1.1.2.1 misho 8: #include <aitsched.h>
9:
10: void *event(void *arg)
11: {
1.1.2.2 ! misho 12: printf("Event::\n");
! 13: return NULL;
! 14: }
! 15:
! 16: void *eventlo(void *arg)
! 17: {
! 18: printf("EventLOW::\n");
! 19: return NULL;
! 20: }
! 21:
! 22: void *timer(void *arg)
! 23: {
! 24: printf("Timer 10sec::\n");
! 25: return NULL;
! 26: }
! 27:
! 28: void *r(void *arg)
! 29: {
! 30: printf("read::\n");
! 31: return NULL;
! 32: }
! 33:
! 34: void *w(void *arg)
! 35: {
! 36: printf("write::\n");
! 37: return NULL;
! 38: }
! 39:
! 40: void *once(void *arg)
! 41: {
! 42: printf("once::\n");
1.1.2.1 misho 43: return NULL;
44: }
45:
46: int
47: main(int argc, char **argv)
48: {
49: sched_root_task_t *root;
1.1.2.2 ! misho 50: int f;
! 51: struct sockaddr_in sin;
! 52:
! 53: f = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
! 54: if (f == -1)
! 55: return 1;
! 56: sin.sin_len = sizeof sin;
! 57: sin.sin_family = AF_INET;
! 58: sin.sin_port = htons(2345);
! 59: sin.sin_addr.s_addr = INADDR_ANY;
! 60: if (bind(f, (struct sockaddr*) &sin, sizeof sin) == -1)
! 61: return 1;
1.1.2.1 misho 62:
63: root = schedBegin();
64: if (!root) {
65: printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
66: return 1;
67: }
68:
69: if (!schedEvent(root, event, "piuk", 1234)) {
70: printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
71: return 2;
72: }
73:
1.1.2.2 ! misho 74: if (!schedEventLo(root, eventlo, "piuk", 1111)) {
! 75: printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
! 76: return 3;
! 77: }
! 78:
! 79: if (!schedTimer(root, timer, "blah", 10000000)) {
! 80: printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
! 81: return 4;
! 82: }
! 83:
! 84: if (!schedRead(root, r, "rrr", f)) {
! 85: printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
! 86: return 5;
! 87: }
! 88:
! 89: if (!schedWrite(root, w, "www", f)) {
! 90: printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
! 91: return 6;
! 92: }
! 93:
! 94: schedCallOnce(root, once, "000000", 42);
! 95:
! 96: schedRun(root);
1.1.2.1 misho 97: schedEnd(root);
1.1.2.2 ! misho 98:
! 99: close(f);
1.1.2.1 misho 100: return 0;
101: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>