Skip to main content

Posts

Showing posts from December 17, 2003
Wait Queues Wait queues are an implementation of lists. They are primarily used to provide synchronization.For example all the processes waiting for a particular event. Wait queues are implemented in kernel in <linux/wait.h> The 2 important structures are :- The wait queue head structure struct __wait_queue_head { spinlock_t lock; struct list_head task_list; }; The wait queue structure struct __wait_queue { unsigned int flags; #define WQ_FLAG_EXCLUSIVE 0x01 struct task_struct * task; wait_queue_func_t func; struct list_head task_list; }; TODO: I need to find out what is the wait queue function responsible for?? Is it something like that this function will be executed A wait queue event might be uninterruptible or interruptible. An interruptible event might interrupted as per a particular time interval. All these functions are available in <linux/wait.h>. As an exampl
Kernel Lists To prevent duplicated efforts in creating a linked lists and to provide a common interface in sharing them, the kernel developers have declared a kernel level linked list. The appropriate header is Here is the most imp struct struct list_head { struct list_head *next, *prev; }; Note that this list_head only mentions the next and prev pointers, it says nothing of the information. Therefore we need to embed this structue inside the structures that make up the list. So the actual struct will be defined as struct task_list { struct list_head list; task_struct *task; }; The head of he list must be a standalone list_head structure. It must be initialized to use with the INIT_LIST_HEAD macro. Ex INIT_LIST_HEAD(&list); Alternatively list-head can be initialized at compile time as follows :- LIST_HEAD(list); Now we can use functions in . SOme imp funcs are :- 1. list_add() 2. list_add_tail() 3. list_del() 4. list_empty() 5. list_splice()