Process management functions
[Cooperative scheduler]

Functions

int BZ_ProcSelf (void)
 Returns the PID of the caller.
int BZ_ProcSpawn (int pid, int *stack, void(*func)(void *), void *parm)
 Spawn a new thread.

Function Documentation

int BZ_ProcSelf ( void   ) 

Returns the PID of the caller.

Returns:
The process ID of the caller. If called from an interrupt routine, then the returned value is meaningless.
int BZ_ProcSpawn ( int  pid,
int *  stack,
void(*)(void *)  func,
void *  parm 
)

Spawn a new thread.

The function will start a new thread. The function will not suspend the caller, it merely creates a new thread and sets it in a runnable state. It will have the chance to run when the caller voluntarily suspends. The new thread will be started with interrupts enabled.

Parameters:
pid The process ID of the new thread. It must be between 0 and the maximum number of processes specified for the BZ_Init() function when the kernel was started. The process ID should not be identical to the caller. It also should not be the same as any already existing process, but if it is, then that process will be killed and substituted with the new one.
stack A pointer to the end of a memory are that will be the stack for the new thread. It should be at 8-byte aligned, although on the ARM7TDMI core 4-byte alignment is sufficient. Note that if you create the stack by declaring and integer array, the pointer you pass here must be a pointer to the integer after the last element of the array. That is, if you define

 static int stack[ SIZE ]; 

then you must pass stack + SIZE here.

func A pointer to a void function taking a void pointer argument. That will be the entry point of your new thread. That function must never return; if it does, the system will crash.
parm The argument to pass to the new thread when it starts.
Return values:
BZ_ILLEGAL_PID The pid argument was out of bounds or was the same as that of the caller.
0 Success.
Generated on Fri Aug 13 12:02:25 2010 by  doxygen 1.6.3