ExecuteAsThread

Executes previously loaded code as a thread.

Synopsis

Item ExecuteAsThread(CodeHandle code,int32 argc, char **argv,char *threadName, int32 priority);

Description

This function lets you execute a chunk of code that was previously loaded from disk using LoadCode(). The code will execute as a thread of the current task.

In order to function correctly, code being run as a thread should be linked with threadstartup.o instead of the usual cstartup.o.

The argc and argv parameters are passed directly to the main() entry point of the loaded code.

The values you supply for argc and argv are irrelevant to this function. They are simply passed through to the loaded code. Therefore, their meaning must be agreed upon by the caller of this function and by the loaded code.

threadName specifies the name of the thread.

priority specifies the priority the new thread should have. Providing a negative priority makes the thread inherit the priority of the current task or thread.

Arguments

code
A code handle filled in by a previous call to LoadCode().
argc
A value that is passed directly as the argc parameter to the loaded code's main() entry point. This function doesn't use the value of this argument, it is simply passed through to the loaded code.
argv
A value that is passed directly as the argv parameter to the loaded code's main() entry point. This function doesn't use the value of this argument; it is simply passed through to the loaded code.
threadName
The name of the thread. Should be a descriptive string that identifies this thread.
priority
The priority for the new thread. Supply a negative value to have the thread inherit the priority of the current task or thread. Priorities for user threads can be in the range of 10 to 199.

Return Value

Returns the item number of the new thread, or a negative error code if the thread could not be created.

Implementation

Folio call implemented in file folio V21.

Associated Files

filefunctions.h

See Also

LoadCode(), UnloadCode(), ExecuteAsSubroutine()