prepare_to_wait()

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

 



Hi,

Many times i have come across a code which uses prepare_to_wait() as follows :

>>>
up(&semaphore);
---
---
---
prepare_to_wait(queue, &wait, TASK_INTERRUPTIBLE);
if(condition())
    schedule();
finish_wait(queue, &wait);
---
---
---
down_interruptible(&semaphore);
<<<

Now this is what i am interpreting :

 1. The above code can get preempted just after the call to prepare_to_wait(), In that case it would not be run again by the scheduler since it
 is in the TASK_INTERRUPTIBLE state. After that when someone wake's it up, then the check is made (if condition) and then the normal flow of code.

 2. If the code does not get preempted after the call to prepare_to_wait(), it will still execute the if condition while in TASK_INTERRUPTIBLE state --> but a  TASK_INTERRUPTIBLE state is not runnable - i feel this is valid after the call to schedule() is made. (i.e. it would not run again after it has given up the CPU)

Am i right in the above two interpretations ?

_V


[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