Re: Re: sleeping and waiting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello...

> both have advantages/disadvantages and restrictions,  therefore they
> are used under (very) different circumstances. refer to a good kernel
> book for details (LDD3 has already been recommended to you -
> http://lwn.net/Kernel/LDD3/).

Just to add what Florin said. Busy wait is preferred if you are planning 
to wait for such a short time ("short" here are relative to your CPU 
clock, perhaps under 1-2 ms), because the process is still running and 
able to quickly grab the lock ASAP. 

In the other hand, sleeping lock (e.g semaphore) is preferred if you 
want to sleep for long time (again "long" is relative), for example 10 
seconds. Since the process is put on TASK_(UN)INTERRUPTIBLE and moved 
out from run queue, the CPU is free to do something else or simply go 
to idle state.

regards

Mulyadi.


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux