PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
thread.h File Reference
#include <pbl/mcu/mpu.h>
#include <pbl/kernel/types.h>
#include <pbl/kernel/compiler.h>

Data Structures

struct  pbl_thread_attr
 Thread creation attributes. More...
 
struct  pbl_thread
 Thread object. More...
 

Macros

#define PBL_THREAD_NAME_LEN   16
 Size of a thread name, including the terminating NUL.
 
#define PBL_THREAD_MAX_MEM_REGIONS   4
 Number of MPU regions switched in with each thread.
 
#define PBL_THREAD_STACK_DEFINE(name, size)    static uint8_t name[size] PBL_ALIGNED(CONFIG_KERNEL_STACK_ALIGN)
 Define a thread stack with the alignment the MPU port needs for a guard region.
 

Typedefs

typedef void(* pbl_thread_entry_t) (void *arg)
 Thread entry function.
 

Enumerations

enum  pbl_thread_state {
  PBL_THREAD_READY , PBL_THREAD_RUNNING , PBL_THREAD_BLOCKED , PBL_THREAD_SUSPENDED ,
  PBL_THREAD_DEAD
}
 Thread state. More...
 

Functions

int pbl_thread_create (struct pbl_thread *t, const struct pbl_thread_attr *attr)
 Create and start a thread.
 
void pbl_thread_abort (struct pbl_thread *t)
 End a thread.
 
void pbl_thread_suspend (struct pbl_thread *t)
 Stop scheduling a thread until pbl_thread_resume().
 
void pbl_thread_resume (struct pbl_thread *t)
 Make a suspended thread runnable again.
 
void pbl_thread_yield (void)
 Let other ready threads of the same priority run.
 
void pbl_thread_sleep (pbl_timeout_t timeout)
 Block the calling thread for a while.
 
struct pbl_thread * pbl_thread_current (void)
 Get the calling thread.
 
struct pbl_thread * pbl_thread_idle (void)
 Get the kernel's idle thread.
 
void pbl_thread_prio_set (struct pbl_thread *t, pbl_prio_t prio)
 Change the base priority of a thread.
 
pbl_prio_t pbl_thread_prio_get (const struct pbl_thread *t)
 Get the base priority of a thread.
 
enum pbl_thread_state pbl_thread_state (const struct pbl_thread *t)
 Get the state of a thread.
 
static const char * pbl_thread_name (const struct pbl_thread *t)
 Get the name of a thread.
 
static uint32_t pbl_thread_id (const struct pbl_thread *t)
 Get the creation ID of a thread.
 
void pbl_thread_regions_set (struct pbl_thread *t, const MpuRegion *const *regions)
 Replace the MPU regions of a thread.
 
static void * pbl_thread_tls_get (const struct pbl_thread *t, unsigned int slot)
 Read a thread-local pointer slot.
 
static void pbl_thread_tls_set (struct pbl_thread *t, unsigned int slot, void *v)
 Write a thread-local pointer slot.
 
void pbl_thread_stack_overflow (struct pbl_thread *t, const char *name)
 Handle a thread that overran its stack.
 
bool pbl_kernel_privilege_raise_allowed (uint32_t caller_pc)
 Decide whether code may raise privilege through the kernel's supervisor call.
 
uint32_t * pbl_kernel_syscall_stack (uintptr_t *base_out)
 Provide a dedicated privileged stack for the current thread's syscalls.
 
void pbl_kernel_syscall_entered (uintptr_t orig_sp, uintptr_t *lr_slot)
 Notify the application that privilege is being raised for a syscall.