Busy wait in network initialization

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Sep 28 14:20:42 UTC 2012


On 09/28/2012 03:49 PM, Eric Norum wrote:
> There are some places in the BSD network code (at the time, can't say for sure now) that assumed that this value could never be 0 -- they use 0 as a value meaning something special --  'time not set' or 'forever', things like that.

Ok, thanks for the hints.  In this case the implementation has a problem

unsigned long
rtems_bsdnet_seconds_since_boot (void)
{
	rtems_interval now;

	now = rtems_clock_get_ticks_since_boot();
	return now / rtems_bsdnet_ticks_per_second;
}

since rtems_clock_get_ticks_since_boot() will overflow regularly (e.g. 1ms tick 
=> every 50 days).

Maybe we should change this to

unsigned long
rtems_bsdnet_seconds_since_boot (void)
{
	rtems_interval ticks;

	ticks = rtems_clock_get_ticks_since_boot();
	ticks /= rtems_bsdnet_ticks_per_second;

	return ticks != 0 ? ticks : 1;
}

and remove the busy loop?

-- 
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.





More information about the devel mailing list