Reverted the recent change from random_rand() to rand(). It turned out that
since libc rand() returns a signed int, there were frequently problems with timer values wrapping. By reverting to random_rand(), we can provide a random generator that returns an unsigned and the timer problems are solved.
This commit is contained in:
parent
b80d3cfdb9
commit
585620c102
10 changed files with 28 additions and 29 deletions
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: shell-time.c,v 1.6 2009/02/09 20:54:49 adamdunkels Exp $
|
||||
* $Id: shell-time.c,v 1.7 2009/02/11 11:08:55 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -44,7 +44,7 @@
|
|||
#include "sys/clock.h"
|
||||
#include "net/rime/timesynch.h"
|
||||
|
||||
#include "lib/rand.h"
|
||||
#include "lib/random.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -318,7 +318,7 @@ PROCESS_THREAD(shell_randwait_process, ev, data)
|
|||
/* printf("randwait %d command '%s'\n",
|
||||
maxwait, command);*/
|
||||
|
||||
etimer_set(&etimer, rand() % (CLOCK_SECOND * maxwait));
|
||||
etimer_set(&etimer, random_rand() % (CLOCK_SECOND * maxwait));
|
||||
PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
|
||||
|
||||
/* printf("Starting '%s' child %p (%s)\n", command, randwait_command.child, */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue