#include <brisc_thread.h>
#include <brisc_sched.h>
#include <string.h>
Go to the source code of this file.
int b_thread_create |
( |
const char * |
name, |
|
|
void(*)(void *) |
thread_fn, |
|
|
void * |
arg, |
|
|
cpu_reg_t * |
stack, |
|
|
size_t |
n_stack_words |
|
) |
| |
Allocate a new thread in the run queue.
- Parameters
-
name | A human readable name for the thread. |
thread_fn | A pointer to the entry point of the thread function. |
arg | This pointer will be passed as a parameter to the thread function. |
stack | Pointer to the base of the thread's program stack space on an even cpu_reg_t word boundary. |
n_stack_words | The number of cpu_reg_t words contained in the stack space. |
- Returns
- a valid thread descriptor >= 0, or < 0 on failure (not enogh thread slots BRISC_THREAD_MAX).
Definition at line 98 of file brisc_thread.c.
volatile brisc_thread_t* b_thread_current |
( |
void |
| ) |
|
- Returns
- a pointer to the current thread context.
Definition at line 167 of file brisc_thread.c.
int b_thread_init |
( |
const char * |
name | ) |
|
Called by the "main()" thread, initializes briscits and inserts an entry in the thread table for the "main()" thread.
- Parameters
-
name | An ASCII name for the thread (ex. "main"). |
Definition at line 41 of file brisc_thread.c.
void b_thread_lock |
( |
void |
| ) |
|
Lock the scheduler such that the current thread will nut yield until thread_unlock() is called.
Definition at line 77 of file brisc_thread.c.
int8_t b_thread_priority |
( |
int |
id | ) |
|
- Returns
- Given a thread descriptor, return the corresponding thread prority or return BRISC_THREAD_PRIO_INVALID if descriptor is invalid.
Definition at line 143 of file brisc_thread.c.
int b_thread_set_prio |
( |
int |
id, |
|
|
int8_t |
prio |
|
) |
| |
set a thread priority. < 0 is inactive, = 0 is active but suspended. > 0 indicates the maximum number of contiguous time slices the thread is allowed to get.
- Parameters
-
id | The thread handle. |
prio | The thread priority -1 .. 127 |
- Returns
- < 0 on failure
Definition at line 132 of file brisc_thread.c.
void b_thread_set_systick_fn |
( |
void(*)(void) |
systick_fn | ) |
|
Insert a callback on systick interrupt.
Definition at line 51 of file brisc_thread.c.
void b_thread_set_yield_fn |
( |
void(*)(void) |
yield_fn | ) |
|
Insert a callback on yield interrupt.
Definition at line 56 of file brisc_thread.c.
void b_thread_start |
( |
int |
id | ) |
|
void b_thread_stop |
( |
int |
id | ) |
|
Stop a thread. The thread remains active in the run queue, yet receives no run time.
- Parameters
-
Definition at line 67 of file brisc_thread.c.
- Returns
- the value of the systick counter.
Definition at line 62 of file brisc_thread.c.
void b_thread_unlock |
( |
void |
| ) |
|
Unlock the current thread (see thread_lock())
Definition at line 82 of file brisc_thread.c.
void b_thread_yield |
( |
void |
| ) |
|
Yield the remainder of the current thread's time slice(s).
Definition at line 87 of file brisc_thread.c.