• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

sleep CPU usage + threads

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
dignified
Asked:
dignified
1 Solution
 
rmharwoodCommented:
Nope, a sleeping process/thread does not use any CPU.
0
 
HamishMarsonCommented:
sleep() is fine in a thread. It'll stop the whole thread from being scheduled until the time expires.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now