Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

include/sys/thread.h File Reference


Detailed Description

Thread management definitions.


Data Structures

struct  _NUTTHREADINFO
 Thread information structure. More...


Defines

#define DEADBEEF
#define TDS_TERM
#define TDS_RUNNING
#define TDS_READY
#define TDS_SLEEP
#define SLEEP_MODE_NONE
#define THREAD(threadfn, arg)
 Macro for thread entry definitions.


Typedefs

typedef _NUTTHREADINFO NUTTHREADINFO

Functions

HANDLE NutThreadCreate (u_char *name, void(*fn)(void *), void *arg, size_t stackSize)
 Create a new thread.

u_char NutThreadSetPriority (u_char level)
 Set the current thread's priority.

void NutThreadKill (void)
 Kill the running thread.

void NutThreadDestroy (void)
 Free a thread that was previously killed and release memory back to the OS.

void NutThreadExit (void)
 End the current thread.

void NutThreadResumeAsync (HANDLE th)
 Make a previously suspended thread ready to run.

void NutThreadWake (HANDLE timer, HANDLE th)
 Resume a previously suspended thread.

void NutThreadYield (void)
 Give up the CPU.

void NutThreadAddPriQueue (NUTTHREADINFO *td, NUTTHREADINFO **tqpp)
 Add a thread to a prioritiy ordered queue.

void NutThreadRemoveQueue (NUTTHREADINFO *td, NUTTHREADINFO *volatile *tqpp)
 Remove a thread from a specified queue.

void NutThreadSwitch (void)
 Switch to another thread.

HANDLE GetThreadByName (u_char *name)
void DumpThreads (HANDLE handle)

Variables

NUTTHREADINFO *volatile runningThread
 Currently running thread.

NUTTHREADINFO *volatile nutThreadList
 List of all created threads.

NUTTHREADINFO *volatile runQueue
 List of ready-to-run threads.


Function Documentation

HANDLE NutThreadCreate u_char name,
void(*  fn)(void *),
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.

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.


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