34 #ifndef _BRISC_THREAD_H_ 35 #define _BRISC_THREAD_H_ 147 #ifndef BRISC_THREAD_MAX 148 #define BRISC_THREAD_MAX 8 151 #ifndef BRISC_THREAD_NAME_MAX 152 #define BRISC_THREAD_NAME_MAX 8 155 #define BRISC_THREAD_PRIO_INVALID (-1) 156 #define BRISC_THREAD_PRIO_SUSPEND (0) 157 #define BRISC_THREAD_PRIO_MIN (1) 158 #define BRISC_THREAD_PRIO_MAX (127) 160 #define brisc_systick_t uint32_t 169 #define b_int_enabled() cpu_int_enabled() 170 #define b_int_enable() cpu_int_enable() 171 #define b_int_disable() cpu_int_disable() 172 #define b_int_set(s) cpu_int_set((s)) 174 #define b_atomic_acquire(s) cpu_atomic_acquire((s)) 175 #define b_atomic_release(s) cpu_atomic_release((s)) 177 #define b_wfi() cpu_wfi(); 183 #define b_thread_block_while(cond) while((cond)) b_thread_yield() 189 #define b_thread_prio_clear() (brisc_scheduler_state.prio = 0) 210 extern int b_thread_create(
const char*
name,
void (*thread_fn)(
void*),
void* arg, cpu_reg_t* stack,
size_t n_stack_words );
int8_t b_thread_priority(int id)
struct brisc_thread __attribute__((aligned(8)))
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...
int b_thread_init(const char *name)
Called by the "main()" thread, initializes briscits and inserts an entry in the thread table for the ...
void b_thread_lock(void)
Lock the scheduler such that the current thread will nut yield until thread_unlock() is called...
void b_thread_set_yield_fn(void(*yield_fn)(void))
Insert a callback on yield interrupt.
#define BRISC_THREAD_NAME_MAX
int b_thread_create(const char *name, void(*thread_fn)(void *), void *arg, cpu_reg_t *stack, size_t n_stack_words)
Allocate a new thread in the run queue.
void b_thread_stop(int id)
Stop a thread. The thread remains active in the run queue, yet receives no run time.
void b_thread_yield(void)
Yield the remainder of the current thread's time slice(s).
void b_thread_start(int id)
Start a thread with the default priority of BRISC_THREAD_PRIO_MIN. TO start thread with other priorit...
char name[BRISC_THREAD_NAME_MAX+1]
brisc_systick_t b_thread_systick(void)
void b_thread_set_systick_fn(void(*systick_fn)(void))
Insert a callback on systick interrupt.
volatile brisc_thread_t * b_thread_current(void)
void b_thread_unlock(void)
Unlock the current thread (see thread_lock())