a0NewSlave()

Starts a new slave thread.


Syntax

a0tError a0NewSlave(
a0tThread *thread,
a0tScheduling sched,
int prio,
size_t stack,
a0tFunction function,
void *value );

Arguments

Namerd/wrDescription
thread write Address of the slave thread desciptor.
sched read Scheduling rule to be used .
prio read Priority of the slave thread.
stack read Size of daemon thread stack.
function read Function to be executed by the thread.
value read Parameter passed to the thread.

Description

This function creates a slave thread with scheduling rule sched, priority prio, stack bytes at the stack. This thread executes the function function with argument value.

The scheduling rule, priority and stack size may be inherited from the calling thread by using the A0InheritScheduling, A0InheritPriority and A0InheritStack values, respectively. There's a little bug: when you use A0InheritScheduling for the scheduling, the priority passed can only be A0InheritPriority (i.e.: even if it's something else, it will act as if it were A0InheritPriority :-). See A0DefaultScheduling, A0DefaultPriority and A0DefaultStack for other possible values.

The function passed as parameter should correspond to the following prototype: a0tError function(void *argument);

A slave thread can have its end waited by any other thread with a0JoinSlave().

On return of this function, the variable pointed by thread contains a thread descriptor to the new thread.


Return Values

If an error condition occurs, it returns the error code, otherwise it returns A0ErrOk. Possible values are as follows:
Error CodeDescription
A0ErrNoMem No memory (or other resources) available.
A0Err...Some error occurred.
A0ErrOkSuccessful completion.

See Also

a0JoinSlave() a0DetachSlave() a0ExitThread()