Solved

sleep CPU usage + threads

Posted on 2004-08-13
2
345 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 125 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

778 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