EVE 1.0
Thread emulation
Collaboration diagram for Thread emulation:

Data Structures

struct  stack_pool_state_t
 
struct  stack_pool_t
 
struct  thread_t
 

Macros

#define EVE_THREAD_EMBEDDED_CSTATE   0
 
#define EVE_THREAD_FPU_SUPPORT   1
 
#define THREAD_CPU_REGISTERS_COUNT   (16 + 9) /* {s16-s31, r4-r11, r15} */
 

Functions

uint32_t ThreadBegin (struct thread_t *Thread)
 
void ThreadYield (struct thread_t *Thread, uint32_t Value)
 
void ThreadEnd (struct thread_t *Thread)
 

Detailed Description

Thread emulation layer provides RTOS-like thread abstraction on top of Contiki protothreads. The threads use a common physical call stack, exactly like the Contiki protothreads do, but the stack content can be saved in an external buffer at thread yield. The stored stack state can be restored later, emulating resuming of the thread. In general it resembles setjmp() / longjmp() semantic, but with addition to stack snapshoting and "return to jump point" functionality.

Macro Definition Documentation

#define EVE_THREAD_EMBEDDED_CSTATE   0

Normally disabled, reduces static RAM usage but increrases dynaamic one and CPU clocks required.

Definition at line 62 of file thread.h.

#define EVE_THREAD_FPU_SUPPORT   1

Normally enabled, allows FPU usage in the treads

Definition at line 68 of file thread.h.

#define THREAD_CPU_REGISTERS_COUNT   (16 + 9) /* {s16-s31, r4-r11, r15} */

Number of registers stored in the context

Definition at line 75 of file thread.h.

Function Documentation

uint32_t ThreadBegin ( struct thread_t Thread)

Starts or resumes thread execution

Parameters
Threadpointer to the thread instance
void ThreadYield ( struct thread_t Thread,
uint32_t  Value 
)

Yields the thread and returns control to the return of ThreadBegin

Parameters
Threadpointer to the thread instance
Valuevalue to be passed as the return code of ThreadBegin
void ThreadEnd ( struct thread_t Thread)

Ends the thread ans deallocates stack from the stack pool

Parameters
Threadpointer to the thread instance