Update to new code

This commit is contained in:
Nils O. Selåsdal
2013-01-02 21:21:15 +01:00
parent 3e7fd8a34b
commit 22d15ea1a1
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ void *reader(void *arg)
for (i = 0; i < CNT/2; i++) {
struct uc_threadmsg *msg;
struct my_msg *my;
if (uc_thread_queue_get(&queue, NULL, &msg) != 0) {
if (uc_thread_queue_get(&queue, &msg) != 0) {
printf("uc_threadqueue_get failed\n");
return NULL;
}
+9 -1
View File
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <ucore/ucore_threadqueue.h>
struct uc_threadqueue queue;
@@ -17,7 +18,13 @@ void *handler(void *arg)
for (;;) {
struct uc_threadmsg *msg;
struct my_msg *my;
if (uc_thread_queue_get(&queue, NULL, &msg) != 0) {
struct timespec timeout = {5, 0};
int rc;
rc = uc_thread_queue_tryget(&queue, &timeout, &msg);
if(rc == ETIMEDOUT) {
printf("handler timed out\n");
continue;
} else if (rc != 0) {
printf("uc_threadqueue_get failed\n");
return NULL;
}
@@ -61,6 +68,7 @@ int main(int argc, char *argv[])
}
struct my_msg *msg = malloc(sizeof *msg);
msg->sig = sig;
msg->uc_msg.msgtype = 0;
uc_thread_queue_add(&queue, msg);