The kernel only knows tick rates, so you cannot sleep for less than a
tick count. Realistically, it's n-1, (2 ticks minimum) since 1 tick
isn't useful (it could be anywhere within the tick depending on the
So, if the hardware ticker is set to 100 ticks per second and you want
to sleep with greater resolution that your hardware ticker, you have to
use a different hardware timer source. If you have a programmable
timer, you could create a simple device driver OR system state
application program that sends a wakeup signal.
Then, you could do something like:
_os_sigmask(1); /* mask signals until I am ready */
/* notify signal "driver" or app code here */
count = 0; /* forever! */
_os_sleep(&count,&sigval); /* sleep unmasks signals for us */
So, your app would just go to sleep forever (or set to high timeout
value in case something happens) and your "notify signal" part would
set up a hardware timer to respond to, then send a signal to the above
The best way -- and the way OS-9 was designed -- is to increase the
ticker resolution. You can set the high bit in F_Sleep to make the
kernel calculate based on 256ths of a tick -- ie,
time = (1<<31) | (x * 256);
x = 256; /* 256 256ths of a tick; 1 second on any system */
But you will see that some values won't make sense on a 100 tick per
second system. ie, "1" there would be 1/256, which would be rounded up
to one tick.
But, this does let you leave your C code alone and run on any system
that has a ticker at the highest resolution.
By the way, what version of OS-9 are you running? PowerPC 4.5 is the
latest release, and just came out a few months ago. It not only has
various bug fixes and updates, but also some optimizations. Kernel
event creation is now even faster in certain situations, and there has
been some new power management support added for certain PPC families.
If you have a support contract, you can get the update free (well, not
"free" since that's why you pay the support contract, but you know what
Allan Batteiger in Dallas (www.rtsi.com) handles distribution/updates
for Microware OS-9 in the USA.