AboutRalph McArdell Expertise I am a software developer with more than 10 years C++ experience and over 20 years experience developing a wide variety of applications for Windows
NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C, software development and many platform specific and system development problems.
Experience My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines.
Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is).
When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD.
My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets include system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes.
On another avenue I have started writing software for Symbian based devices (mobile phones).
Sleep and sleep exist on both unix and Windows OS... So there is no need to reinvent the wheel and to do marvelous things shuch as while(tick() - nStart < nDelay) which consume about 100% cpu cycles during the wait... totally unuseful...
Sleep or sleep is a passive wait call which release your thread/process until the delay has been reached.
On Win32, Sleep is not very accurate when you begin to play with durations around 10-20ms (windows is not real-time os certified), but I have noticed in many projects that WaitForSingleObject(hObject, nDuration) (where hObject is an unused HANDLE (NULL for example) and nDuration is a timeout in ms, is really more accurate than Sleep (or WaitForMultipleObjects...).
Ralpho writes on 2007-02-28 19:28:03
I wrote this answer. If you had read it all you would have noticed that I make this very point.
However functions such as sleep, nanosleep, Sleep and WaitForSingleObject are _not_ part of C++ they are part of the operating system APIs.
Hence I start with the basic and standard then move onto better ways. I accept the point about WaitForSingleObject, however in many cases such accuracy is not required. This is especially true for those just starting to find out that there is a big wide world of operating system API functions out there.