Hi Roger and all,

> It turns out that the default windows timer, on which the sleep 
> function depends, does not function as one might think.  The function 
> parameter () is used to set the sleep time in increments of 1 msec, 
> down to a minimum of 1 msec [e.g. sleep(1)].  But in its default state, 
> the timer interval/resolution actually doesn't go below 15 ms.  If you 
> set it to any number between 1 and 15 it will be [approximately] 15 
> msec.  But you can set the timer to 'high resolution' using the Windows 
> Multimedia function timeBeginPeriod() where the resolution is specified 
> in milliseconds, with a minumum of 1 msec.  When you no longer need the 
> high resolution timer, you then revert to the default timer by using 
> timeEndPeriod() and specifying the same resolution.
Hmmm, I did not know.
In Linrad there is:

void lir_sleep(int us)
{
Sleep(us/1000);
}

Since Linrad is developed under Linux for Linux primarily I have
allowed for lir_sleep(xxx) to sleep for a time equal to xxx or 
'a bit more'. Linux does not sleep for the desired time, but for
a time of xxx plus whatever time the thread that the CPU has given
control to wants to use. That means that lir_sleep(1000) will sleep
for at least 1 ms, but it could also sleep for perhaps 20 ms.
This means that the Windows timer is not a problem in Linrad:-)
I have nevertheless changed it (wsys.c) to this:

void lir_sleep(int us)
{
timeBeginPeriod(1);
Sleep(us/1000);
timeEndPeriod(1);
}

This will be in Linrad-02.38, but I am curious on feedback from those
of you who actually use Linrad under Windows and who can compile from
source code. Do you see any effect of this change?

The timing for the WSE units in Linrad does not use the sleep
statement. The timing is much more precise, it is using the blocking
read statement on the soundcard device driver which will return
with high priority each time a dma buffer is full. Under Linux a separate
thread with sleep statements does not seem to be a good idea unless
the CPU is idle most of the time....

73

Leif / SM5BSZ


#############################################################
This message is sent to you because you are subscribed to
  the mailing list <linrad@antennspecialisten.se>.
To unsubscribe, E-mail to: <[EMAIL PROTECTED]>
To switch to the DIGEST mode, E-mail to <[EMAIL PROTECTED]>
To switch to the INDEX mode, E-mail to <[EMAIL PROTECTED]>
Send administrative queries to  <[EMAIL PROTECTED]>

Reply via email to