EE445M RTOS
Taken at the University of Texas Spring 2015
|
Operating system routines. More...
Data Structures | |
struct | hwcontext |
struct | swcontext |
Macros | |
#define | PIDWORK_BUFFER_SIZE 32 |
#define | OS_STACK_SIZE 100 |
#define | OS_NUM_POOLS 2 |
#define | OS_SYSTEM_POOL 0 |
#define | OS_REAL_TIME_POOL 0 |
#define | OS_INTERACTIVE_POOL 1 |
#define | os_spawn_thread(_thread, _priority) os_add_thread(_thread, priority) |
#define | os_kill_thread(_thread) os_remove_thread(_thread) |
#define | os_surrender_context() os_suspend() |
Typedefs | |
typedef struct hwcontext | hwcontext_t |
typedef struct swcontext | swcontext_t |
Functions | |
void | pidwork_increment () |
void | pidwork_record () |
void | os_threading_init (void) |
void | _os_reset_thread_stack (tcb_t *tcb, task_t task) |
int8_t | get_os_num_threads () |
tcb_t * | os_add_thread (task_t) |
tcb_t * | os_remove_thread (task_t) |
tcb_t * | os_tcb_of (task_t) |
tcb_t * | _os_next_dead_thread () |
int32_t | os_running_thread_id () |
void | os_launch () |
void | os_suspend () |
Variables | |
static volatile uint32_t | PIDWORK |
static volatile uint32_t | HIGHEST_PIDWORK |
static volatile uint32_t | LOWEST_PIDWORK |
static volatile uint32_t | PIDWORK_IDX |
static volatile uint32_t | PIDWORK_BUFFER [32] |
static tcb_t * | os_running_threads = NULL |
static tcb_t * | os_dead_threads = NULL |
static tcb_t * | OS_NEXT_THREAD |
static tcb_t | OS_THREADS [SCHEDULER_MAX_THREADS] |
static tcb_t * | OS_THREAD_POOL [2] |
Operating system routines.
''
#define OS_INTERACTIVE_POOL 1 |
#define os_kill_thread | ( | _thread | ) | os_remove_thread(_thread) |
#define OS_NUM_POOLS 2 |
Static number of thread pools of distinct priority in use
Definition at line 25 of file os.h.
Referenced by os_threading_init().
#define os_spawn_thread | ( | _thread, | |
_priority | |||
) | os_add_thread(_thread, priority) |
#define OS_STACK_SIZE 100 |
Maximum number of 32-bit values allowed in each thread's stack
Definition at line 22 of file os.h.
Referenced by _os_reset_thread_stack().
#define os_surrender_context | ( | ) | os_suspend() |
A convenience alias to to circumnavigate the naming conventions chosen by the couse Administrators.
Definition at line 142 of file os.h.
Referenced by hw_daemon(), led_blink_blue(), led_blink_green(), led_blink_red(), and postpone_suicide().
#define OS_SYSTEM_POOL 0 |
typedef struct hwcontext hwcontext_t |
The contents of the stack immediately after a function call.
typedef struct swcontext swcontext_t |
The contents of the stack during a context switch.
tcb_t* _os_next_dead_thread | ( | ) |
Returns the next dead thread in the dead thread circle. If the length of the dead thread circle is greater than 1, then the current dead thread is removed and the circle is relinked with the next dead thread. If the circle contains only one dead thread, then that thread is removed and the current dead thread is set to null. If there is no thread in the dead thread circle, then it retuns null.
Resets the thread stack for a given tcb to run a given task.
thread | the thread whose stack is to be reset |
the | task for which the thread should run |
Definition at line 197 of file os.c.
References tcb_t::id, swcontext::lr, OS_PROGRAM_STACKS, OS_STACK_SIZE, hwcontext::pc, hwcontext::psr, hwcontext::r0, hwcontext::r1, swcontext::r10, swcontext::r11, hwcontext::r2, hwcontext::r3, swcontext::r4, swcontext::r5, swcontext::r6, swcontext::r7, swcontext::r8, swcontext::r9, and tcb_t::sp.
Referenced by os_add_thread().
int8_t get_os_num_threads | ( | ) |
Definition at line 68 of file os.c.
References OS_NUM_THREADS.
Adds a new thread with the specified task.
Definition at line 72 of file os.c.
References _os_reset_thread_stack(), atomic_end, atomic_start, CDL_DELETE, tcb_t::entry_point, and os_dead_threads.
Referenced by hw_init_daemon(), main(), and schedule().
void os_launch | ( | ) |
Launches the operating system.
Definition at line 161 of file os.c.
References _os_choose_next_thread(), edf_init(), OS_NEXT_THREAD, and os_running_threads.
Referenced by main().
Remove a thread from the queue the schedule will choose from.
The | task to kill. This should be the task that was used to start the thread to remove via . |
Definition at line 106 of file os.c.
References CDL_APPEND, CDL_DELETE, tcb_t::entry_point, tcb_t::next, NULL, os_dead_threads, OS_NUM_THREADS, os_tcb_of(), OS_THREAD_POOL, tcb_t::prev, and tcb_t::priority.
int32_t os_running_thread_id | ( | ) |
void os_suspend | ( | ) |
Put the invoking thread to sleep and let another thread take over. This s another way to say "set the interrupt bit of the \PendSV_Handler".
Definition at line 380 of file os.c.
References scheduler_reschedule().
Return the tcb used to control the specified task_t.
The | task to lookup the tcb of |
Definition at line 147 of file os.c.
References NULL, OS_THREADS, postpone_death, and SCHEDULER_MAX_THREADS.
Referenced by os_remove_thread().
void os_threading_init | ( | void | ) |
Initialize the threading engine, setting all threads to dead. This initializes the dead thread circle appropriately and sets the running thread circle to null.
Definition at line 34 of file os.c.
References CDL_APPEND, tcb_t::entry_point, tcb_t::id, NULL, os_dead_threads, OS_NUM_POOLS, OS_PROGRAM_STACKS, os_running_threads, OS_THREAD_POOL, OS_THREADING_INITIALIZED, OS_THREADS, schedule_init(), SCHEDULER_MAX_THREADS, and tcb_t::sp.
Referenced by main().
void pidwork_increment | ( | ) |
void pidwork_record | ( | ) |
A thread that continuously toggles GPIO pin 2 on GPIO_PORT_F.
Definition at line 25 of file jitter.c.
References HIGHEST_PIDWORK, LOWEST_PIDWORK, PIDWORK, PIDWORK_BUFFER, PIDWORK_BUFFER_SIZE, and PIDWORK_IDX.
|
static |
Definition at line 17 of file jitter.h.
Referenced by pidwork_init(), and pidwork_record().
|
static |
Definition at line 18 of file jitter.h.
Referenced by pidwork_init(), and pidwork_record().
A circular doubly linked list of currently dead threads.
Definition at line 48 of file os.h.
Referenced by os_add_thread(), os_remove_thread(), and os_threading_init().
|
static |
Communication mailbox from the SysTick_Handler to the PendSV_Handler; will contain the tcb_t* of the next thread to execute come PendSV_Handler execution time.
Definition at line 78 of file os.h.
Referenced by os_launch(), and scheduler_reschedule().
A circular doubly linked list of currently running threads.
Definition at line 45 of file os.h.
Referenced by os_launch(), os_running_thread_id(), os_threading_init(), and PendSV_Handler().
|
static |
An array of thread pools to place OS_THREADS into.
Definition at line 84 of file os.h.
Referenced by os_remove_thread(), and os_threading_init().
|
static |
An array of statically allocated threads.
Definition at line 81 of file os.h.
Referenced by os_tcb_of(), and os_threading_init().
|
static |
Definition at line 16 of file jitter.h.
Referenced by pidwork_increment(), pidwork_init(), and pidwork_record().
|
static |
Definition at line 20 of file jitter.h.
Referenced by pidwork_record().
|
static |
Definition at line 19 of file jitter.h.
Referenced by pidwork_init(), and pidwork_record().