103 return thread_to_add;
109 tcb_t* thread_to_remove;
113 status = StartCritical();
139 return thread_to_remove;
168 asm volatile(
"LDR R0, =OS_NEXT_THREAD");
171 asm volatile(
"LDR R0, [R0]");
172 asm volatile(
"LDR R0, [R0]");
175 asm volatile(
"MSR MSP, R0");
185 asm volatile(
"POP {R4-R11}");
187 asm volatile(
"POP {LR}");
188 asm volatile(
"POP {R0-R3}");
190 asm volatile(
"pop {r12, lr}");
191 asm volatile(
"pop {pc}");
193 asm volatile (
"BX LR");
206 hwcontext->
pc = (uint32_t)(task);
207 hwcontext->
psr = 0x01000000;
209 swcontext->
lr = 0xfffffff9;
211 #ifdef OS_REGISTER_DEBUGGING_ENABLED
212 hwcontext->
r0 = 0x00000000;
213 hwcontext->
r1 = 0x01010101;
214 hwcontext->
r2 = 0x02020202;
215 hwcontext->
r3 = 0x03030303;
217 swcontext->
r4 = 0x04040404;
218 swcontext->
r5 = 0x05050505;
219 swcontext->
r6 = 0x06060606;
220 swcontext->
r7 = 0x07070707;
221 swcontext->
r8 = 0x08080808;
222 swcontext->
r9 = 0x09090909;
223 swcontext->
r10 = 0x10101010;
224 swcontext->
r11 = 0x11111111;
227 tcb->
sp = (uint32_t*)(((uint32_t)hwcontext) -
sizeof(
swcontext_t));
228 asm volatile (
"PUSH {R9, R10, R11, R12}");
229 asm volatile (
"mrs r12, msp" );
230 asm volatile (
"mrs r11, msp" );
231 asm volatile (
"mrs r10, control" );
233 asm volatile (
"POP {R9, R10, R11, R12}");
244 while (pool->
queue != executing) {
284 asm volatile(
"CPSID I");
288 asm volatile(
"CPSIE I");
293 asm volatile(
"CPSID I");
300 asm volatile(
"mrs r12, msp" );
303 asm volatile(
"stmdb r12!, {r4 - r11, lr}");
311 #ifdef OS_TIME_PROFILING_ENABLED
338 asm volatile(
"LDR R2, =os_running_threads");
341 asm volatile(
"LDR R3, [R2]");
344 asm volatile(
"LDR R1, =OS_NEXT_THREAD");
345 asm volatile(
"LDR R1, [R1]");
348 asm volatile(
"STR R1, [R2]");
355 asm volatile(
"str r12, [r3, #0]");
358 asm volatile(
"ldr r12, [r1]");
361 #ifdef OS_TIME_PROFILING_ENABLED
366 asm volatile(
"ldmia r12!, {r4 - r11, lr}");
369 asm volatile(
"msr msp, r12");
372 asm volatile(
"CPSIE I");
374 asm volatile (
"bx lr");
396 ready_task->
task = task;
461 if (!inspect) {
return NULL; }
464 if(inspect->
deadline == target_frequency) {
467 inspect = inspect->
next;
468 }
while (inspect != start);
484 while(next && next != start) {
500 if (elt == EDF_QUEUE) {
522 while (pool->
queue != executing) {
535 return executing->
tcb;
static volatile sched_task_pool * SCHEDULER_UNUSED_QUEUES
#define DL_EDF_INSERT(head, add)
tcb_t * os_add_thread(task_t task)
void SysTickDisable(void)
always void scheduler_reschedule(void)
#define MAX_SYSTICKS_PER_HZ
volatile sched_task_pool * pool
always void _os_reset_thread_stack(tcb_t *tcb, task_t task)
DEADLINE_TYPE seriousness
volatile sched_task * executing
void edf_insert(sched_task *task)
static int32_t OS_PROGRAM_STACKS[SCHEDULER_MAX_THREADS][100]
volatile sched_task * EDF_QUEUE
#define DL_PREPEND(head, add)
static tcb_t * OS_THREAD_POOL[2]
static tcb_t * os_running_threads
uint32_t SysCtlClockGet(void)
static sched_task SCHEDULER_TASKS[5]
#define DL_EDF_PREPEND(head, add)
static tcb_t * os_dead_threads
void schedule(task_t task, frequency_t frequency, DEADLINE_TYPE seriousness)
void IntPendSet(uint32_t ui32Interrupt)
sched_task * edf_get_edf_queue()
static sched_task * SCHEDULER_UNUSED_TASKS
#define CDL_DELETE(head, del)
tcb_t * os_remove_thread(task_t task)
int8_t get_os_num_threads()
struct sched_task * pri_next
struct sched_task_pool * next
bool OS_THREADING_INITIALIZED
void _hw_subscribe(HW_TYPE type, hw_metadata metadata, void(*isr)(notification note), bool single_shot)
void SysTickIntEnable(void)
#define SCHEDULER_MAX_THREADS
static sched_task_pool SCHEDULER_TASK_QUEUES[5]
static tcb_t OS_THREADS[SCHEDULER_MAX_THREADS]
tcb_t * os_tcb_of(const task_t task)
void(* pisr_t)(notification note)
sched_task_pool * schedule_hash_find_int(sched_task_pool *queues, frequency_t target_frequency)
static tcb_t * OS_NEXT_THREAD
volatile sched_task EDF[SCHEDULER_MAX_THREADS]
void _os_choose_next_thread()
int32_t os_running_thread_id()
#define CDL_APPEND(head, add)
struct sched_task_pool * prev
static volatile sched_task_pool * SCHEDULER_QUEUES
void SysTickPeriodSet(uint32_t ui32Period)
#define CDL_PREPEND(head, add)
void schedule_aperiodic(pisr_t pisr, HW_TYPE hw_type, hw_metadata metadata, microseconds_t allowed_run_time, DEADLINE_TYPE seriousness)