Context Switching
[System Support]

Context Switching for the UNIX emulator. More...

Collaboration diagram for Context Switching:

Functions

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

Variables

pthread_attr_t attr
pthread_mutex_t thread_mutex
pthread_cond_t main_cv
uint16_t main_cs_level

Detailed Description

Context Switching for the UNIX emulator.

Function Documentation

void NutThreadInit ( void   ) 

Definition at line 78 of file thread.c.

References attr, main_cv, and thread_mutex.

Referenced by main().

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.

Note:
CPU interrupts must be disabled before calling this function.

which means NutEnterCritical was called before

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.

Note:
CPU interrupts must be disabled before calling this function.

Definition at line 196 of file context_icc.c.

References runningThread, runQueue, and TDS_RUNNING.

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.

Parameters:
name String containing the symbolic name of the new thread, up to 8 characters long.
fn The thread's entry point, typically created by the THREAD macro.
arg Argument pointer passed to the new thread.
stackSize Number of bytes of the stack space allocated for the new thread.
Returns:
Pointer to the NUTTHREADINFO structure or 0 to indicate an error.

Definition at line 191 of file thread.c.

References __os_trf, __os_trs, attr, fprintf(), irq_signal, main_cv, memcpy(), NutDumpThreadList(), NutEnterCritical, NutExitCritical, NutHeapAlloc, NutThreadAddPriQueue(), nutThreadList, NutThreadSwitch(), printf, runningThread, runQueue, TDS_READY, TDS_RUNNING, and thread_mutex.

Referenced by AhdlcAt91Init(), AhdlcAvrInit(), AsixInit(), cs8900Init(), CSNicInit(), DisplayInit(), DmInit(), EmacInit(), IDEInit(), LancInit(), main(), NicInit(), NutIdle(), NutInit(), NutPppInitStateMachine(), NutRegisterDiscovery(), NutSNTPStartThread(), NutTcpInitStateMachine(), Sc16is752UsartInit(), ScannerInit(), SJAInit(), and wlandrv_Init().


Variable Documentation

pthread_attr_t attr

Definition at line 66 of file thread.c.

Referenced by NutThreadCreate(), NutThreadInit(), and UxmlNodeAddAttrib().

pthread_mutex_t thread_mutex

Definition at line 69 of file thread.c.

Referenced by NutThreadCreate(), and NutThreadInit().

pthread_cond_t main_cv

Definition at line 72 of file thread.c.

Referenced by NutThreadCreate(), and NutThreadInit().

Definition at line 75 of file thread.c.


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/