Solved

Linux variant for Windows Sleep command

Posted on 2003-12-03
2
1,500 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
Comment Utility
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
Comment Utility
Thats all I needed to know, thanks khkremer!!!! Pts are yours.

regards,

Gordon.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

11 Experts available now in Live!

Get 1:1 Help Now