10 millisecond resolution would suffice.
Cheers
Wegie
error = _os_getime (&timeNow, &ticks);
/* ticks contains the ticks per second in the MS 16 bits, the number of
ticks THIS second in the LS 16 bits */
/* So, assuming a 100Hz ticker.. Otherwise, do your own thing. */
hundredths = ticks & 0xffff ;
wegie wrote in message <62075fc3.01080...@posting.google.com>...
OS-9, by default, uses clock ticks. This is configurable on your
system, but the default is usually 100 ticks per second or 1000 ticks
per second (from Microware). My home OS-9 system runs 200 ticks per second.
Calls work in clock ticks by default:
/* sleep for 3 ticks */
count = 3;
_os_sleep( &count, &sig ); /* &sig not available on 68K version */
If you run 100 ticks per second, 1 tick is 10ms, but you cannot rely on
that. Your minimum should be TWO ticks (your SLICE value). Context
switches can happen at any moment, not just on tick boundries, so a
process could have used 95% of a tick then gone to sleep -- the nextg
process in line takes over on that current tick so if it used "1 tick"
it would be using the remaining 5% of that tick.
Rule of thumb: "(n-1) where n=system slice value" is the time you can
rely on getting if you are qualified to be in the CPU.
Default of a 100/second OS-9 system is a slice value of 2. So, if I get
in the CPU I can get (n-1) ticks (always 1 tick plus whatever was left
over from the previous tick, maybe the whole thing maybe not).
If you want 10ms timing, you will either need to use an external timer
interrupt (the only RELIABLE way to do this on any operating system), or
set your system ticker to at least 200/second ticks and then use a value
of "2" which would mean 10ms.
/* timed alarm */
_os_alarm_cycle( &alarmID, 2, 500 );
/* send signal 500 ever 2 clock ticks until I shut it off */
That gives you software timing of 2 ticks, but if other more important
processes are in the CPU, you won't be able to respond to the signal
until your task is back in the CPU. If you have a higher priority and
are waiting for the signal, you will preempt whoever is running and take
over immediately:
_os_setpt( myprocessID, 65535 ); /* I'm king of the world! */
while ( 1 ) {
count = 0;
_os_sleep( &count, &sig ); /* sleep "forever" */
/* when my signal/alarm came in, I woke up and preempted whoever
was in the CPU since I was running at 65535 and they were
probably at a much lower priority */
/* do my critical stuff, or maybe I want to be nice and lower
my priority back down before I do it so I don't hog the CPU */
/* when done, I can go back to my wait loop */
}
--
Over 20,000 digital pics from Disney, Theme Parks, and Ren Fests!
Visit http://www.AtTheFaire.com or http://www.DisneyFans.com
(Supporter of the Renaissance Foundation -/- http://renfound.org)
_os_getsys( ...get d_ticks... );
/* the current tick is "here" */
/* do something... */
_os_getsys( ...get d_ticks again );
/* subtract and now you know how long it took, within a tick */
Thanks very much for your assistance.
I won't be able to try your suggestions for a coupla weeks, as I'm on
holiday.
However, I'll try them as soon as I return.
Thanks for just now
Regards
Wegie
wegie <stewart...@ingenco.co.uk> wrote in message
news:62075fc3.01080...@posting.google.com...