View Single Post
Old 11-03-2013, 06:42 PM   #16
NullNix
Guru
NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.NullNix ought to be getting tired of karma fortunes by now.
 
Posts: 929
Karma: 15576314
Join Date: Jan 2013
Location: Ely, Cambridgeshire, UK
Device: Kindle Oasis 3, Kindle Oasis 1
Quote:
Originally Posted by Aeris View Post
Does anybody know how much resources does sleep function consume (CPU and RAM mainly)? I've googled but didn't find nothing... are so low to be completely neglectable?
Sleeping consumes no CPU time, and minimal memory. From a userspace perspective, all sleeps -- like all hardware access -- simply involve a call into the kernel, where the process blocks (consuming no CPU) until awoken. From a kernel perspective, all these events involve putting the task (not 'process' at this level) into a waitqueue, which is traversed and waiting tasks awoken only when the conditions for awakening are right. So, total memory hit: one kernel stack (always consumed whenever the process exists, but worth noting) and one pointer on a waitqueue somewhere in the kernel.

So, basically, sleeping is as close to nil overhead as anything ever is.
NullNix is offline   Reply With Quote