?
Solved

Linux variant for Windows Sleep command

Posted on 2003-12-03
2
Medium Priority
?
1,535 Views
Last Modified: 2012-06-27
Can someone please tell me how to implement a sleep command for Linux in the same was as the Windows variant.

The Windows version tells the current process to go to sleep and stops it for a number of milliseconds, but allows other functions/threads in the application to work in the background. How do I do this in Linux????

I want to let other threads do their bit, by waiting for one second.

I saw the sleep and usleep command in Linux but does this do what I need???

I am coding in QT3 / C++ on SuSE.

regards,

Gordon?
0
Comment
Question by:jeffreyg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
ID: 9870933
sleep() will definitely give up the CPU so that other threads or processes can run. usleep() will give up the CPU if you sleep for more than about 50 milliseconds. For shorter usleep amounts, it would be too timeconsuming to do a task switch, so the usleep command will do a busy wait.

if you want to wait for one second, do a sleep(1), this will give your other processes time to run.
0
 

Author Comment

by:jeffreyg
ID: 9873151
Thats all I needed to know, thanks khkremer!!!! Pts are yours.

regards,

Gordon.
0

Featured Post

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question