Nut/OS  4.10.3
API Reference
GCC Context Switch

Thread context switching for avr-gcc. More...

Collaboration diagram for GCC Context Switch:

Data Structures

 ARM7TDMI GCC context switch frame layout. More...
 Thread entry frame layout. More...


#define LONG_PTR_P(lp, mem_p)


void NutThreadSwitch (void)
 Switch to another thread.
HANDLE NutThreadCreate (char *name, void(*fn)(void *), void *arg, size_t stackSize)
 Create a new thread.

Detailed Description

Thread context switching for avr-gcc.

Define Documentation

#define LONG_PTR_P (   lp,
__asm__ __volatile__("ldi %A0, lo8("#mem_p ")" "\n\t" \
                         "ldi %B0, hi8("#mem_p ")" "\n\t" \
                         "ldi %C0, hh8("#mem_p ")" "\n\t" \
                         "clr %D0" \
                         :"=d" (lp))

Definition at line 196 of file context_gcc.c.

Function Documentation

void NutThreadSwitch ( void  )

Switch to another thread.

Stop the current thread, saving its context. Then start the one with the highest priority, which is ready to run.

Application programs typically do not call this function.

CPU interrupts must be disabled before calling this function.

Definition at line 168 of file context.c.

HANDLE NutThreadCreate ( char *  name,
void(*)(void *)  fn,
void *  arg,
size_t  stackSize 

Create a new thread.

If the current thread's priority is lower or equal than the default priority (64), then the current thread is stopped and the new one is started.

nameString containing the symbolic name of the new thread, up to 8 characters long.
fnThe thread's entry point, typically created by the THREAD macro.
argArgument pointer passed to the new thread.
stackSizeNumber of bytes of the stack space allocated for the new thread.
Pointer to the NUTTHREADINFO structure or 0 to indicate an error.

Definition at line 321 of file context_gcc.c.

References __os_trf, __os_trs, ENTERFRAME::cef_arghi, ENTERFRAME::cef_arglo, ENTERFRAME::cef_pchi, ENTERFRAME::cef_pclo, ENTERFRAME::cef_r1, ENTERFRAME::cef_rampz, ENTERFRAME::cef_sreg, SWITCHFRAME::csf_pchi, SWITCHFRAME::csf_pclo, DEADBEEF, fprintf(), memcpy(), NutDumpThreadList(), NutEnterCritical, NutExitCritical, NutStackAlloc, NutThreadAddPriQueue(), nutThreadList, NutThreadSwitch(), runningThread, runQueue, _NUTTHREADINFO::td_memory, _NUTTHREADINFO::td_name, _NUTTHREADINFO::td_next, _NUTTHREADINFO::td_priority, _NUTTHREADINFO::td_queue, _NUTTHREADINFO::td_sp, _NUTTHREADINFO::td_state, _NUTTHREADINFO::td_timer, and TDS_READY.

Here is the call graph for this function: