Unix to Windows Porting Dictionary for HPC |
||
|
|
||
|
|
LinksFunction List
|
Table of Contents The Unix and Windows sleep functions have the same intent but differ by the type of argument passed to the function and the spelling of the function name. The Unix function is spelling in all lower case while the Windows function is spelled with an uppercase 'S' with the rest in lowercase. We mention this because this is a minor typo that trips many people initially. The time argument to the Unix function is in seconds while the Windows function's argument is in milliseconds. Conversion is easily done by multiplying the argument (Unix to Windows porting) by 1000. The Unix sleep() returns zero on success after the sleep has completed. The Windows Sleep() does not return a value; execution continues when the function call has completed. #include <windows.h> DWORD time; /* previously u_int on Unix */ time = 5; /* for 5 seconds */ time = time * 1000; /* to convert to milliseconds on Windows */ Sleep(time); /* code continues */ |