Mailing List Archive

proper way to sleep
This is not spam about sleep aids :)

Q: Is there a 'standard' way to sleep for a specified number of BIOS ticks
(or seconds) in a com32 program?

I grepped through the com32 library source and didn't find anything for
'sleep' or 'tick'.

If not, you may want to consider adding:
void syslinux_sleep(int seconds);
void syslinux_sleep_bios_ticks(int ticks);


or something like that.

!Gracias!
Miguel

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: proper way to sleep [ In reply to ]
Miguel wrote:
> This is not spam about sleep aids :)
>
> Q: Is there a 'standard' way to sleep for a specified number of BIOS ticks
> (or seconds) in a com32 program?
>
> I grepped through the com32 library source and didn't find anything for
> 'sleep' or 'tick'.
>
> If not, you may want to consider adding:
> void syslinux_sleep(int seconds);
> void syslinux_sleep_bios_ticks(int ticks);
>
> or something like that.

Not sleep, but there is a standard busy wait, so you could have
something like:

#include <syslinux/idle.h>
#include <sys/times.h>

void syslinux_sleep_ticks(int ticks)
{
clock_t start = times(NULL);

while (times(NULL) - start < ticks)
syslinux_idle();
}

void syslinux_sleep(int seconds)
{
syslinux_sleep_ticks(seconds*CLK_TCK);
}

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: proper way to sleep [ In reply to ]
> Not sleep, but there is a standard busy wait,

You are correct ... not really sleeping.

> so you could have
> something like:
>
> #include <syslinux/idle.h>
> #include <sys/times.h>
>
> void syslinux_sleep_ticks(int ticks)
> {
> clock_t start = times(NULL);
>
> while (times(NULL) - start < ticks)
> syslinux_idle();
> }
>
> void syslinux_sleep(int seconds)
> {
> syslinux_sleep_ticks(seconds*CLK_TCK);
> }

Excellent!


Miguel

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: proper way to sleep [ In reply to ]
Miguel wrote:
> This is not spam about sleep aids :)
>
> Q: Is there a 'standard' way to sleep for a specified number of BIOS ticks
> (or seconds) in a com32 program?
>
> I grepped through the com32 library source and didn't find anything for
> 'sleep' or 'tick'.
>
> If not, you may want to consider adding:
> void syslinux_sleep(int seconds);
> void syslinux_sleep_bios_ticks(int ticks);
>
>
I had the same problem in my com32 modules.. It could be nice to add a
sleep(unsigned int msec) function.

Can't we use such code ?

unsigned char sleep(unsigned int msec)
{
unsigned long micro = 1000*msec;
com32sys_t inreg,outreg;
REG_AH(inreg) = 0x86;
REG_CX(inreg) = (micro >> 16);
REG_DX(inreg) = (micro & 0xFFFF);
__intcall(0x15,&inreg,&outreg);
return REG_AH(outreg);
}

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: proper way to sleep [ In reply to ]
Erwan Velu wrote:
> I had the same problem in my com32 modules.. It could be nice to add a
> sleep(unsigned int msec) function.
>
> Can't we use such code ?
>
> unsigned char sleep(unsigned int msec)
> {
> unsigned long micro = 1000*msec;
> com32sys_t inreg,outreg;
> REG_AH(inreg) = 0x86;
> REG_CX(inreg) = (micro >> 16);
> REG_DX(inreg) = (micro & 0xFFFF);
> __intcall(0x15,&inreg,&outreg);
> return REG_AH(outreg);
> }

No, please spin on syslinux_idle(), at least for anything other than a
trivial delay. Especially PXELINUX tends to need to perform tasks while
spinning.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: proper way to sleep [ In reply to ]
hpa wrote:
> No, please spin on syslinux_idle(), at least for anything other than a
> trivial delay. Especially PXELINUX tends to need to perform tasks while
> spinning.
>
> -hpa

*This* is important information that needs to be more broadly circulated.


Miguel

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: proper way to sleep [ In reply to ]
Op 21-08-2007 om 14:47 schreef Miguel:
> hpa wrote:
> > No, please spin on syslinux_idle(), at least for anything other than a
> > trivial delay. Especially PXELINUX tends to need to perform tasks while
> > spinning.
> >
> > -hpa
>
> *This* is important information that needs to be more broadly circulated.

I think mentioning it on the syslinux wiki would be a good thing.
( that is one click away on http://syslinux.zytor.com )



Geert Stappers

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: proper way to sleep [ In reply to ]
Miguel wrote:
> hpa wrote:
>> No, please spin on syslinux_idle(), at least for anything other than a
>> trivial delay. Especially PXELINUX tends to need to perform tasks while
>> spinning.
>>
>> -hpa
>
> *This* is important information that needs to be more broadly circulated.
>

Overall the whole API layer needs documentation.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.