My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Macros | Typedefs | Functions
sw_wait.h File Reference
#include <sw_types.h>
#include <sw_semaphores.h>
#include <sw_list.h>
#include <sw_timer.h>
#include <task.h>

Go to the source code of this file.

Classes

struct  wait_queue_head
 Wait queue list head. Wait queue elements are added to this. More...
 
struct  wait_queue
 Wait queue element. More...
 

Macros

#define TASK_INTERRUPTIBLE   0
 
#define TASK_UNINTERRUPTIBLE   1
 
#define WAKE_UP   0
 
#define WAKE_UP_IMMEDIATE   1
 
#define __sw_wait_event(wq_head, condition)
 
#define sw_wait_event(wq_head, condition)
 This is called to put the current task in a waitqueue. When the condition is satisfied the task is woken up. More...
 

Typedefs

typedef void(* wait_queue_function )(struct wait_queue *, u32)
 

Functions

void sw_wakeup (struct wait_queue_head *wq_head, u32 wakeup_flag)
 This function wakes up an element from the given waitqueue. More...
 
void sw_wakeup_all (struct wait_queue_head *wq_head, u32 wakeup_flag)
 This function wakes up all the elements attached to the given waitqueue head. More...
 
void sw_default_wake_function (struct wait_queue *wq, u32 flag)
 This function wakes up a task by changing the state of the task and adding it to the ready to run list. More...
 
void sw_init_waitqueue_entry_func (struct wait_queue *wq, wait_queue_function func)
 Initializes the wait queue element. More...
 
void sw_init_waitqueue_entry (struct wait_queue *wq)
 Initializes the wait queue element. More...
 
void sw_add_to_waitqueue (struct wait_queue_head *wq_head, struct wait_queue *wq)
 This function is called to add the wait queue element to the wait queue head. More...
 
void sw_remove_from_waitqueue (struct wait_queue_head *wq_head, struct wait_queue *wq)
 This function is called to remove the wait queue element from the wait queue head. More...
 
void sw_set_task_state (int state)
 This function sets the state of the TASK. More...
 
void sw_prepare_for_wait (struct wait_queue_head *wq_head, struct wait_queue *wq, u32 state)
 This function sets the state of the TASK to the given state and adds the element to the waitqueue. More...
 
void sw_complete_wait (struct wait_queue_head *wq_head, struct wait_queue *wq)
 This function is called when the task is woken up and this function removes the waitqueue element from the waitqueue. More...
 

Macro Definition Documentation

#define __sw_wait_event (   wq_head,
  condition 
)
Value:
do { \
\
struct wait_queue wq; \
INIT_LIST_HEAD(&wq.head); \
wq.data = get_current_task(); \
\
while(1){ \
\
if(condition) \
break; \
} \
sw_complete_wait(wq_head, &wq); \
\
\
}while(0)
Definition: task.h:71
void sw_prepare_for_wait(struct wait_queue_head *wq_head, struct wait_queue *wq, u32 state)
This function sets the state of the TASK to the given state and adds the element to the waitqueue...
Definition: sw_wait.c:144
struct sw_task * get_current_task(void)
Get the current task.
Definition: global.c:177
void schedule(void)
Invoke scheduler.
Definition: cpu_api.c:230
void sw_default_wake_function(struct wait_queue *wq, u32 flag)
This function wakes up a task by changing the state of the task and adding it to the ready to run lis...
Definition: sw_wait.c:253
void sw_complete_wait(struct wait_queue_head *wq_head, struct wait_queue *wq)
This function is called when the task is woken up and this function removes the waitqueue element fro...
Definition: sw_wait.c:170
#define INIT_LIST_HEAD(ptr)
Definition: sw_list.h:62
Wait queue element.
Definition: sw_wait.h:70
#define sw_wait_event (   wq_head,
  condition 
)
Value:
do { \
if(condition) \
break; \
__sw_wait_event(wq_head, condition); \
}while(0)
#define __sw_wait_event(wq_head, condition)
Definition: sw_wait.h:77

This is called to put the current task in a waitqueue. When the condition is satisfied the task is woken up.

Parameters
wq_headThe waitqueue head to which the current task need to be added
conditionThe condition which needs to be satisfied to resume the task
Returns
Returns nothing
#define TASK_INTERRUPTIBLE   0
#define TASK_UNINTERRUPTIBLE   1
#define WAKE_UP   0
#define WAKE_UP_IMMEDIATE   1

Typedef Documentation

typedef void(* wait_queue_function)(struct wait_queue *, u32)
Parameters
@paramu32
Returns

Function Documentation

void sw_add_to_waitqueue ( struct wait_queue_head wq_head,
struct wait_queue wq 
)

This function is called to add the wait queue element to the wait queue head.

Parameters
wq_headWait queue list head to which the element need to be added
wqThe waitqueue element
void sw_complete_wait ( struct wait_queue_head wq_head,
struct wait_queue wq 
)

This function is called when the task is woken up and this function removes the waitqueue element from the waitqueue.

Parameters
wq_headThe waitqueue head to which this element is attached
wqThe wait queue element
void sw_default_wake_function ( struct wait_queue wq,
u32  wakeup_flag 
)

This function wakes up a task by changing the state of the task and adding it to the ready to run list.

Parameters
wqThe waitqueue element which need to be waken up
wakeup_flagIt says whether the element need to be woken up immediately or can be woken up later
void sw_init_waitqueue_entry ( struct wait_queue wq)

Initializes the wait queue element.

Parameters
wqThe wait queue element
void sw_init_waitqueue_entry_func ( struct wait_queue wq,
wait_queue_function  func 
)

Initializes the wait queue element.

Parameters
wqThe wait queue element
funcThe function to be called while waking up the element fom waitqueue
void sw_prepare_for_wait ( struct wait_queue_head wq_head,
struct wait_queue wq,
u32  state 
)

This function sets the state of the TASK to the given state and adds the element to the waitqueue.

Parameters
wq_headThe list head to which the element need to be added
wqThe waitqueue element
stateThe state to which the current TASK need to be set
void sw_remove_from_waitqueue ( struct wait_queue_head wq_head,
struct wait_queue wq 
)

This function is called to remove the wait queue element from the wait queue head.

Parameters
wq_headWait queue list head from which the element needs to be deleted
wqThe waitqueue element
void sw_set_task_state ( int  state)

This function sets the state of the TASK.

Parameters
stateThe state to which the current task need to be moved
void sw_wakeup ( struct wait_queue_head wq_head,
u32  wakeup_flag 
)

This function wakes up an element from the given waitqueue.

Parameters
wq_headThe waitqueue head from which all the elements need to be woken up
wakeup_flagIt says whether the element need to be woken up immediately or can be woken up later
void sw_wakeup_all ( struct wait_queue_head wq_head,
u32  wakeup_flag 
)

This function wakes up all the elements attached to the given waitqueue head.

Parameters
wq_headThe waitqueue head from which all the elements need to be woken up
wakeup_flagIt says whether the element need to be woken up immediately or can be woken up later