Quote:
Originally Posted by Aeris
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.