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
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); }
> 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
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); }
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
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