Skip to main content

Posts

Showing posts from March, 2018

Waitqueue

A " wait queue " in the Linux kernel is a data structure to manage threads that are waiting for some condition to become true; they are the normal means by which threads block (or "sleep") in kernel space. While writing modules there might be situations where one might have to wait for input some condition to occur before proceeding further. Tasks that need such behavior can make use of the sleep functionality available in the kernel.  In Linux sleeping is handled by a data structure called wait queue, which is nothing but a list of processes waiting for an input or  event. To manage a wait queue ,we need a structure of the kind wait_queue_head_t, which is defined in linux/wait.h.  Wait queue head can be initialized in the following ways  Statically using:  DECLARE_WAIT_QUEUE_HEAD(name);  Dynamically using :  wait_queue_head_t my_queue; init_waitqueue_head(name), where "name" is name of queue on which task will be put to sleep.   Once