version 1.1.2.2, 2014/01/28 12:57:52
|
version 1.4, 2014/06/05 22:37:29
|
Line 8
|
Line 8
|
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <sys/socket.h> |
#include <sys/socket.h> |
#include <netinet/in.h> |
#include <netinet/in.h> |
#include "../inc/config.h" |
|
#include <aitsched.h> |
#include <aitsched.h> |
|
|
intptr_t Kill; |
intptr_t Kill; |
Line 33 void *timer(sched_task_t *arg)
|
Line 32 void *timer(sched_task_t *arg)
|
|
|
void *r(sched_task_t *arg) |
void *r(sched_task_t *arg) |
{ |
{ |
printf("read:: %ld bytes wait\n", (long) TASK_RET(arg)); | int rlen; |
| char buf[BUFSIZ] = { [0 ... BUFSIZ - 1] = 0 }; |
| |
| rlen = read(TASK_FD(arg), buf, sizeof buf); |
| printf("read:: RET=%d FLAG=0x%lx rlen=%d bytes readed = %s\n", |
| (int) TASK_RET(arg), TASK_FLAG(arg), (int) rlen, buf); |
| for (rlen = 0; rlen < TASK_RET(arg); rlen++) |
| printf("buf[%d]=%c\n", rlen, buf[rlen]); |
Kill++; |
Kill++; |
taskExit(arg, NULL); |
taskExit(arg, NULL); |
} |
} |
|
|
void *w(sched_task_t *arg) |
void *w(sched_task_t *arg) |
{ |
{ |
printf("write:: test\n"); | printf("write:: RET=%d FLAG=0x%lx\n", (int) TASK_RET(arg), TASK_FLAG(arg)); |
write(TASK_FD(arg), "piuk\n", 6); | |
taskExit(arg, NULL); |
taskExit(arg, NULL); |
} |
} |
|
|
Line 81 int
|
Line 86 int
|
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
sched_root_task_t *root; |
sched_root_task_t *root; |
int f, fd; | int f; |
struct sockaddr_in sin; |
struct sockaddr_in sin; |
struct timespec ts = { 20, 0 }; |
struct timespec ts = { 20, 0 }; |
// struct timespec p = { 0, 10000000 }; |
// struct timespec p = { 0, 10000000 }; |
Line 95 main(int argc, char **argv)
|
Line 100 main(int argc, char **argv)
|
f = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
f = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
if (f == -1) |
if (f == -1) |
return 1; |
return 1; |
|
#ifndef __linux__ |
sin.sin_len = sizeof sin; |
sin.sin_len = sizeof sin; |
|
#endif |
sin.sin_family = AF_INET; |
sin.sin_family = AF_INET; |
sin.sin_port = htons(2345); |
sin.sin_port = htons(2345); |
sin.sin_addr.s_addr = INADDR_ANY; |
sin.sin_addr.s_addr = INADDR_ANY; |
if (bind(f, (struct sockaddr*) &sin, sizeof sin) == -1) |
if (bind(f, (struct sockaddr*) &sin, sizeof sin) == -1) |
return 1; |
return 1; |
|
|
fd = open("test_aio.dat", O_CREAT | O_RDWR, 0644); |
|
if (fd == -1) |
|
return 1; |
|
printf("fd=%d\n", fd); |
|
|
|
root = schedBegin(); |
root = schedBegin(); |
if (!root) { |
if (!root) { |
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
Line 155 main(int argc, char **argv)
|
Line 157 main(int argc, char **argv)
|
} |
} |
if (!schedThread(root, thr, "mdaaaa this is thread task", 8192, NULL, 0)) { |
if (!schedThread(root, thr, "mdaaaa this is thread task", 8192, NULL, 0)) { |
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
return 7; | printf("stack is too small\n"); |
} |
} |
if (!schedThread(root, thr, "mdaaaa this is thread task -detached", 131072, NULL, 0)) { |
if (!schedThread(root, thr, "mdaaaa this is thread task -detached", 131072, NULL, 0)) { |
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
Line 177 main(int argc, char **argv)
|
Line 179 main(int argc, char **argv)
|
} |
} |
if (!schedThread(root, thr, "mdaaaa this is thread task -j3", 4096, NULL, 0)) { |
if (!schedThread(root, thr, "mdaaaa this is thread task -j3", 4096, NULL, 0)) { |
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError()); |
return 7; | printf("stack is too small\n"); |
} |
} |
sleep(1); |
sleep(1); |
schedCancel(t); |
schedCancel(t); |
Line 188 main(int argc, char **argv)
|
Line 190 main(int argc, char **argv)
|
schedRun(root, &Kill); |
schedRun(root, &Kill); |
schedEnd(&root); |
schedEnd(&root); |
|
|
close(fd); |
|
close(f); |
close(f); |
return 0; |
return 0; |
} |
} |