- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I just want a simple OS friendly wait timer. I want to wait for 20ms and then continue my loop. However, I dont want just write some proccesor intensive loop (which obviously doesnt work in a multitasking enviroment) I just want some OS wait() or sleep() function where you specifey the time in milliseconds, and the application sleeps, returns the proccesor to the OS, and then wakes up to finish what it was doing in 20 milliseconds. Is there such a function built into C? What do I need to include to access this? http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif Thanks.Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you're in a linux environment, the function that you want is usleep(unsigned long usec). Please note, though, that it only sleeps for a minimum of the specified number of milliseconds -- it might sleep longer. Life is much harder if you're trying to go for guaranteed time intervals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In order to use usleep() I needed to include:
# include <unistd.h> Thanks for all your help should work for what I need.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page