observability

Norman Diamond diamond at csl.sony.co.jp
Wed Sep 13 12:54:46 AEST 1989


In article <1989Sep8.091010.12450 at gdt.bath.ac.uk> exspes at gdr.bath.ac.uk (P E Smee) writes:

> -- though one might ask why you would want to write a chunk
>of code that has ZERO effect.
>(The counter-example people inevitably come up with is 'maybe the
>program is meant to be a timing loop'.  The tired answer is 'if you
>want a time delay, you should tell the operating system to put you to
>sleep for some period of time, rather than wasting CPU cycles twiddling
>your thumbs.  The other users of your multi-user system will thank you
>for it.)

If it takes longer to process an interrupt than to wait for a certain
hardware operation to finish, then the other users will thank you for
coding your no-ops.  If the kernel is trying to access a shared list
of task control blocks, and the list is locked (for a very short time)
by another processor's kernel, and the kernel decides not to crash the
system by trying to put itself to sleep, then the other users will
thank you for it.

Yes, people sometimes write timing loops in Fortran or C, for exactly
the same reason as people sometimes write kernels, device drivers,
libraries, and compilers in C.  Only sometimes they have to turn off
the optimizer.

The quoted meta-answer is more tired than the original answer.

--
-- 
Norman Diamond, Sony Corporation (diamond at ws.sony.junet)
  The above opinions are inherited by your machine's init process (pid 1),
  after being disowned and orphaned.  However, if you see this at Waterloo or
  Anterior, then their administrators must have approved of these opinions.



More information about the Comp.std.c mailing list