agileRTOS (zrtos)  Version 0.8.0 (ghostbuster)
task_scheduler.h File Reference
#include <zrtos/zrtos.h>
#include <zrtos/types.h>
#include <zrtos/clist.h>
#include <zrtos/error.h>
#include <zrtos/task.h>
Include dependency graph for task_scheduler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _zrtos_task_scheduler_t
 

Macros

#define ZRTOS_TASK_SCHEDULER__DO_NOT_DISTURB(code)
 
#define ZRTOS_TASK_SCHEDULER__DO_NOT_DISTURB_EX(is_locked, code)
 
#define ZRTOS_TASK_SCHEDULER__EACH_TASK(node)
 

Typedefs

typedef struct _zrtos_task_scheduler_t zrtos_task_scheduler_t
 

Functions

zrtos_task_t_zrtos_task_scheduler__get_active_task (void)
 
bool zrtos_task_scheduler__add_task (zrtos_task_t *task)
 
bool zrtos_task_scheduler__remove_task (zrtos_task_t *task)
 
bool zrtos_task_scheduler__has_task (zrtos_task_t *task)
 
static zrtos_task_t_zrtos_task_scheduler__get_sleep_task (void)
 
static void zrtos_task_scheduler__page_task_out (void)
 
static void zrtos_task_scheduler__page_task_in (zrtos_task_t *task)
 
static bool _zrtos_task_scheduler__set_active_task (zrtos_task_t *task)
 
static bool _zrtos_task_scheduler__switch_task (void)
 
void _zrtos_task_scheduler__on_tick (void)
 
static void _zrtos_task_scheduler__on_tick_ex (void)
 
void zrtos_task_scheduler__delay_ms (zrtos_task_tick_t ms)
 
void zrtos_task_scheduler__start (void)
 
void zrtos_task_scheduler__stop (void)
 
void zrtos_task_scheduler__init ()
 
static zrtos_task_tzrtos_task_scheduler__get_any_child (zrtos_task_t *task)
 

Variables

zrtos_task_scheduler_t zrtos_task_scheduler = {}
 

Macro Definition Documentation

◆ ZRTOS_TASK_SCHEDULER__DO_NOT_DISTURB

#define ZRTOS_TASK_SCHEDULER__DO_NOT_DISTURB (   code)
Value:
do{ \
ZRTOS_ARCH__DISABLE_INTERRUPTS(); \
zrtos_task_scheduler.do_not_disturb++; \
ZRTOS_ARCH__ENABLE_INTERRUPTS(); \
do{ \
code; \
}while(0); \
ZRTOS_ARCH__DISABLE_INTERRUPTS(); \
zrtos_task_scheduler.do_not_disturb--; \
ZRTOS_ARCH__ENABLE_INTERRUPTS(); \
}while(0);

Definition at line 32 of file task_scheduler.h.

◆ ZRTOS_TASK_SCHEDULER__DO_NOT_DISTURB_EX

#define ZRTOS_TASK_SCHEDULER__DO_NOT_DISTURB_EX (   is_locked,
  code 
)
Value:
do{ \
ZRTOS_ARCH__DISABLE_INTERRUPTS(); \
is_locked = (zrtos_task_scheduler.do_not_disturb == 0); \
zrtos_task_scheduler.do_not_disturb++; \
ZRTOS_ARCH__ENABLE_INTERRUPTS(); \
do{ \
code; \
}while(0); \
ZRTOS_ARCH__DISABLE_INTERRUPTS(); \
zrtos_task_scheduler.do_not_disturb--; \
ZRTOS_ARCH__ENABLE_INTERRUPTS(); \
}while(0);
zrtos_task_scheduler_t zrtos_task_scheduler

Definition at line 46 of file task_scheduler.h.

◆ ZRTOS_TASK_SCHEDULER__EACH_TASK

#define ZRTOS_TASK_SCHEDULER__EACH_TASK (   node)
Value:
,*sentinel = node \
,*next \
;({ \
next = zrtos_task__get_next_task(node); \
node != sentinel; \
}) \
;node = next \
)
zrtos_task_t * zrtos_task__get_next_task(zrtos_task_t *thiz)
Definition: task.h:114
zrtos_task_t * _zrtos_task_scheduler__get_active_task(void)

Definition at line 209 of file task_scheduler.h.

Typedef Documentation

◆ zrtos_task_scheduler_t

Function Documentation

◆ _zrtos_task_scheduler__get_active_task()

zrtos_task_t* _zrtos_task_scheduler__get_active_task ( void  )

Definition at line 61 of file task_scheduler.h.

61  {
64  );
66 }
zrtos_clist_node_t * zrtos_clist__get_root(zrtos_clist_t *thiz)
Definition: clist.h:25
#define zrtos_types__get_container_of(ptr, type, member)
Definition: types.h:69
zrtos_task_scheduler_t zrtos_task_scheduler
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _zrtos_task_scheduler__get_sleep_task()

static zrtos_task_t* _zrtos_task_scheduler__get_sleep_task ( void  )
static

Definition at line 105 of file task_scheduler.h.

105  {
107 }
zrtos_task_scheduler_t zrtos_task_scheduler
Here is the caller graph for this function:

◆ _zrtos_task_scheduler__on_tick()

void _zrtos_task_scheduler__on_tick ( void  )

Definition at line 158 of file task_scheduler.h.

158  {
162  }
165 }
#define ZRTOS_ARCH__LOAD_CPU_STATE_EX(ptr)
Definition: atmega2560.h:283
#define ZRTOS_ARCH__RETURN_FROM_INTERRUPT()
Definition: atmega2560.h:293
#define ZRTOS_ARCH__SAVE_CPU_STATE_EX(ptr)
Definition: atmega2560.h:235
zrtos_task_scheduler_t zrtos_task_scheduler
static bool _zrtos_task_scheduler__switch_task(void)
zrtos_arch_stack_t * tmp_stack_ptr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _zrtos_task_scheduler__on_tick_ex()

static void _zrtos_task_scheduler__on_tick_ex ( void  )
static

Definition at line 168 of file task_scheduler.h.

168  {
170 }
void _zrtos_task_scheduler__on_tick(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _zrtos_task_scheduler__set_active_task()

static bool _zrtos_task_scheduler__set_active_task ( zrtos_task_t task)
static

Definition at line 126 of file task_scheduler.h.

126  {
129  return true;
130 }
static void zrtos_task_scheduler__page_task_in(zrtos_task_t *task)
static void zrtos_task_scheduler__page_task_out(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _zrtos_task_scheduler__switch_task()

static bool _zrtos_task_scheduler__switch_task ( void  )
static

Definition at line 132 of file task_scheduler.h.

132  {
134  zrtos_task_t *task = active_task;
135 
136  do{
137  zrtos_task__on_tick(task);
138  task = zrtos_task__get_next_task(task);
139  }while(task != active_task);
140 
141  task = active_task;
142  do{
143  task = zrtos_task__get_next_task(task);
144  if(zrtos_task__is_ready(task)){
146  }
147  }while(task != active_task);
148 
151  );
152 
153  return true;
154 }
void zrtos_task__on_tick(zrtos_task_t *thiz)
Definition: task.h:83
static bool _zrtos_task_scheduler__set_active_task(zrtos_task_t *task)
zrtos_task_t * zrtos_task__get_next_task(zrtos_task_t *thiz)
Definition: task.h:114
bool zrtos_task__is_ready(zrtos_task_t *thiz)
Definition: task.h:90
zrtos_task_t * _zrtos_task_scheduler__get_active_task(void)
static zrtos_task_t * _zrtos_task_scheduler__get_sleep_task(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_task_scheduler__add_task()

bool zrtos_task_scheduler__add_task ( zrtos_task_t task)

Definition at line 68 of file task_scheduler.h.

68  {
72  });
73 
74  return true;
75 }
#define ZRTOS_TASK_SCHEDULER__DO_NOT_DISTURB(code)
void zrtos_task__set_parent(zrtos_task_t *thiz, zrtos_task_t *parent)
Definition: task.h:140
zrtos_clist_node_t node
Definition: task.h:37
zrtos_task_scheduler_t zrtos_task_scheduler
zrtos_task_t * _zrtos_task_scheduler__get_active_task(void)
bool zrtos_clist__push(zrtos_clist_t *thiz, zrtos_clist_node_t *node)
Definition: clist.h:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_task_scheduler__delay_ms()

void zrtos_task_scheduler__delay_ms ( zrtos_task_tick_t  ms)

Definition at line 172 of file task_scheduler.h.

172  {
175  ,ms
176  );
178 }
void zrtos_task__set_delay_ms(zrtos_task_t *thiz, zrtos_task_tick_t ms)
Definition: task.h:75
zrtos_task_t * _zrtos_task_scheduler__get_active_task(void)
static void _zrtos_task_scheduler__on_tick_ex(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_task_scheduler__get_any_child()

static zrtos_task_t* zrtos_task_scheduler__get_any_child ( zrtos_task_t task)
static

Definition at line 220 of file task_scheduler.h.

220  {
222  if(zrtos_task__get_parent(node) == task){
223  return node;
224  }
225  }
226  return 0;
227 }
#define ZRTOS_TASK_SCHEDULER__EACH_TASK(node)
zrtos_task_t * zrtos_task__get_parent(zrtos_task_t *thiz)
Definition: task.h:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_task_scheduler__has_task()

bool zrtos_task_scheduler__has_task ( zrtos_task_t task)

Definition at line 86 of file task_scheduler.h.

86  {
87  bool ret = false;
88 
91  zrtos_task_t *sentinel = node;
92 
93  do{
94  if(node == task){
95  ret = true;
96  break;
97  }
98  node = zrtos_task__get_next_task(node);
99  }while(node != sentinel);
100  });
101 
102  return ret;
103 }
#define ZRTOS_TASK_SCHEDULER__DO_NOT_DISTURB(code)
zrtos_task_t * zrtos_task__get_next_task(zrtos_task_t *thiz)
Definition: task.h:114
zrtos_task_t * _zrtos_task_scheduler__get_active_task(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_task_scheduler__init()

void zrtos_task_scheduler__init ( )

Definition at line 193 of file task_scheduler.h.

193  {
197  ,(zrtos_arch_stack_t*)0
198  );
202  );
203  //zrtos_task_scheduler__add_task(&zrtos_task_scheduler.sleep_task);
204  //zrtos_task_scheduler.tmp_stack_ptr = 0;
207 }
uint8_t zrtos_arch_stack_t
Definition: atmega2560.h:19
bool zrtos_task__init(zrtos_task_t *thiz, zrtos_arch_stack_t *stack_ptr)
Definition: task.h:44
bool zrtos_clist__init(zrtos_clist_t *thiz)
Definition: clist.h:61
zrtos_clist_node_t node
Definition: task.h:37
zrtos_task_scheduler_t zrtos_task_scheduler
bool zrtos_clist__push(zrtos_clist_t *thiz, zrtos_clist_node_t *node)
Definition: clist.h:85
static void _zrtos_task_scheduler__on_tick_ex(void)
Here is the call graph for this function:

◆ zrtos_task_scheduler__page_task_in()

static void zrtos_task_scheduler__page_task_in ( zrtos_task_t task)
static

Definition at line 118 of file task_scheduler.h.

120  {
124 }
zrtos_arch_stack_t * zrtos_task__get_stack_ptr(zrtos_task_t *thiz)
Definition: task.h:128
zrtos_clist_node_t node
Definition: task.h:37
zrtos_task_scheduler_t zrtos_task_scheduler
zrtos_arch_stack_t * tmp_stack_ptr
zrtos_error_t errno
Definition: errno.h:17
zrtos_error_t zrtos_task__get_errno(zrtos_task_t *thiz)
Definition: task.h:136
void zrtos_clist__set_root(zrtos_clist_t *thiz, zrtos_clist_node_t *node)
Definition: clist.h:29
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_task_scheduler__page_task_out()

static void zrtos_task_scheduler__page_task_out ( void  )
static

Definition at line 109 of file task_scheduler.h.

109  {
112  active_task
114  );
115  zrtos_task__set_errno(active_task,errno);
116 }
void zrtos_task__set_stack_ptr(zrtos_task_t *thiz, zrtos_arch_stack_t *stack_ptr)
Definition: task.h:124
zrtos_task_scheduler_t zrtos_task_scheduler
zrtos_arch_stack_t * tmp_stack_ptr
zrtos_task_t * _zrtos_task_scheduler__get_active_task(void)
zrtos_error_t errno
Definition: errno.h:17
void zrtos_task__set_errno(zrtos_task_t *thiz, zrtos_error_t error_code)
Definition: task.h:132
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_task_scheduler__remove_task()

bool zrtos_task_scheduler__remove_task ( zrtos_task_t task)

Definition at line 77 of file task_scheduler.h.

77  {
80  zrtos_task__set_parent(task,0);
81  });
82 
83  return true;
84 }
#define ZRTOS_TASK_SCHEDULER__DO_NOT_DISTURB(code)
void zrtos_task__set_parent(zrtos_task_t *thiz, zrtos_task_t *parent)
Definition: task.h:140
bool zrtos_clist__delete(zrtos_clist_t *thiz, zrtos_clist_node_t *node)
Definition: clist.h:95
zrtos_clist_node_t node
Definition: task.h:37
zrtos_task_scheduler_t zrtos_task_scheduler
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_task_scheduler__start()

void zrtos_task_scheduler__start ( void  )

Definition at line 180 of file task_scheduler.h.

180  {
181 /*
182  while(true){
183  _zrtos_task_scheduler__on_tick_ex();
184  }
185  __builtin_unreachable();
186 */
187 }

◆ zrtos_task_scheduler__stop()

void zrtos_task_scheduler__stop ( void  )

Definition at line 189 of file task_scheduler.h.

189  {
190  //_zrtos_task_scheduler__isr_stop();
191 }

Variable Documentation

◆ zrtos_task_scheduler

zrtos_task_scheduler_t zrtos_task_scheduler = {}

Definition at line 29 of file task_scheduler.h.