Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sleep CPU usage + threads

Posted on 2004-08-13
2
Medium Priority
?
367 Views
Last Modified: 2010-04-21
I have a daemon thread running that gathers info into structs, and then another regular thread that dumps the structs to file every 5 minutes. For the second thread i was just  doing something like this:

while(1){
     sleep(300);
   ..................


}

Just wondering if this will hog the CPU more than one would think.

-ryan
0
Comment
Question by:dignified
2 Comments
 
LVL 2

Accepted Solution

by:
rmharwood earned 500 total points
ID: 11791569
Nope, a sleeping process/thread does not use any CPU.
0
 

Expert Comment

by:HamishMarson
ID: 11838794
sleep() is fine in a thread. It'll stop the whole thread from being scheduled until the time expires.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

876 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