busy looping in kernel, time question

Marty McFadden marty at fritz.UUCP
Thu Apr 24 04:28:13 AEST 1986


In article <291 at copper.UUCP> stevesu at copper.UUCP (Steve Summit) writes:
>In article <234 at Shasta.ARPA> alex at lancelot writes:
>>
>>	Assume I want to busy loop in the kernel for 100 milliseconds, how
>>many times (approx) should I go around a loop which increments an int?
>
>	while(ryaddr->ryics & RY_TR) == 0);

My advice is to be careful here!! The first question about how many times
should one loop is NOT processor portable!! Say for instance, you decide to
upgrade from a 68000 to a 68020 with cache. These 100 millisecond loops are
no longer 100 milliseconds but can virtually take almost NO time at all :-)

The second suggestion is okay, but I suggest that you also add some sort of
timeout mechanism that comes along every few seconds or so and makes sure
that you are not hung in that state.

cheers.
-- 
	Martin J. McFadden
	{decvax, ucbvax}trwrb!felix!marty
	FileNet Corp. 
	Costa Mesa, Ca.



More information about the Comp.unix.wizards mailing list