diff --git a/platform/minimal-net/contiki-main.c b/platform/minimal-net/contiki-main.c index e0365b995..8d4414aa6 100644 --- a/platform/minimal-net/contiki-main.c +++ b/platform/minimal-net/contiki-main.c @@ -29,7 +29,7 @@ * * This file is part of the Contiki OS * - * $Id: contiki-main.c,v 1.11 2007/11/26 23:28:33 adamdunkels Exp $ + * $Id: contiki-main.c,v 1.12 2007/11/28 12:54:41 adamdunkels Exp $ * */ @@ -78,16 +78,16 @@ main(void) while(1) { int n; - struct timespec ts; + struct timeval tv; n = process_run(); /* if(n > 0) { printf("%d processes in queue\n"); }*/ - ts.tv_sec = 0; - ts.tv_nsec = 1000; - nanosleep(&ts, NULL); + tv.tv_sec = 0; + tv.tv_usec = 1; + select(0, NULL, NULL, NULL, &tv); etimer_request_poll(); } diff --git a/platform/native/contiki-main.c b/platform/native/contiki-main.c index 0130ef641..4a8e38404 100644 --- a/platform/native/contiki-main.c +++ b/platform/native/contiki-main.c @@ -29,12 +29,12 @@ * * This file is part of the Contiki OS * - * $Id: contiki-main.c,v 1.5 2007/11/26 23:28:33 adamdunkels Exp $ + * $Id: contiki-main.c,v 1.6 2007/11/28 12:54:42 adamdunkels Exp $ * */ #include -#include +#include #include "contiki.h" @@ -73,12 +73,12 @@ main(void) while(1) { int n; - struct timespec ts; + struct timeval tv; n = process_run(); - ts.tv_sec = 0; - ts.tv_nsec = 1000; - nanosleep(&ts, NULL); + tv.tv_sec = 0; + tv.tv_usec = 1; + select(0, NULL, NULL, NULL, &tv); etimer_request_poll(); } diff --git a/platform/netsim/contiki-main.c b/platform/netsim/contiki-main.c index 6a91e2b40..12bdc0a29 100644 --- a/platform/netsim/contiki-main.c +++ b/platform/netsim/contiki-main.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: contiki-main.c,v 1.20 2007/11/26 23:28:33 adamdunkels Exp $ + * $Id: contiki-main.c,v 1.21 2007/11/28 12:54:42 adamdunkels Exp $ */ #include "contiki.h" @@ -55,7 +55,7 @@ #include #include -#include +#include #include #include "dev/button-sensor.h" @@ -125,15 +125,15 @@ contiki_main(int flag) while(1) { int n; - struct timespec ts; + struct timeval tv; n = process_run(); /* if(n > 0) { printf("%d processes in queue\n"); }*/ - ts.tv_sec = 0; - ts.tv_nsec = 1000; - nanosleep(&ts, NULL); + tv.tv_sec = 0; + tv.tv_usec = 1; + select(0, NULL, NULL, NULL, &tv); etimer_request_poll(); } diff --git a/platform/netsim/main.c b/platform/netsim/main.c index 6489feb1b..7492b2445 100644 --- a/platform/netsim/main.c +++ b/platform/netsim/main.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: main.c,v 1.7 2007/11/26 23:28:33 adamdunkels Exp $ + * $Id: main.c,v 1.8 2007/11/28 12:54:42 adamdunkels Exp $ */ /** @@ -111,7 +111,7 @@ static int start_node(int x, int y, int b) { pid_t pid; - struct timespec ts; + struct timeval tv; static unsigned short port = NODES_PORTBASE; pid = fork(); @@ -123,9 +123,9 @@ start_node(int x, int y, int b) srand(getpid()); - ts.tv_sec = 0; - ts.tv_nsec = 1000000 * (rand() % 1000); - nanosleep(&ts, NULL); + tv.tv_sec = 0; + tv.tv_usec = 1000 * (rand() % 1000); + select(0, NULL, NULL, NULL, &tv); node_init(port - NODES_PORTBASE + 2, x, y, b); ethernode_init(port); @@ -213,10 +213,10 @@ static signed long drift = 0; void clock_delay(unsigned int num) { - struct timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = 100000 * num; - nanosleep(&ts, NULL); + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 100 * num; + select(0, NULL, NULL, NULL, &tv); } void diff --git a/platform/netsim/net/ethernode.c b/platform/netsim/net/ethernode.c index d0947fa53..b512f6d0d 100644 --- a/platform/netsim/net/ethernode.c +++ b/platform/netsim/net/ethernode.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: ethernode.c,v 1.12 2007/11/27 20:45:15 nvt-se Exp $ + * $Id: ethernode.c,v 1.13 2007/11/28 12:54:42 adamdunkels Exp $ */ /** * \file @@ -51,7 +51,7 @@ #include "lib/random.h" #include -#include +#include #include #define BUF ((uip_tcpip_hdr *)&uip_buf[HDR_LEN]) @@ -198,7 +198,7 @@ ethernode_send(void) static char tmpbuf[2048]; struct hdr *hdr = (struct hdr *)tmpbuf; u8_t dest; - struct timespec ts; + struct timeval tv; if(uip_len > sizeof(tmpbuf)) { PRINTF(("Ethernode_send: too large uip_len %d\n", uip_len)); @@ -209,9 +209,9 @@ ethernode_send(void) len = uip_len + HDR_LEN; dest = ID_BROADCAST; - ts.tv_sec = 0; - ts.tv_nsec = 1000 * (random_rand() % 1000); - nanosleep(&ts, NULL); + tv.tv_sec = 0; + tv.tv_usec = (random_rand() % 1000); + select(0, NULL, NULL, NULL, &tv); do_send(TYPE_DATA, dest, hdr, len);