Solved

Linux variant for Windows Sleep command

Posted on 2003-12-03
2
1,506 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
2 Comments
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

864 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now