Task

A process.

Description

A task item contains all the information needed by the kernel to support multitasking. It contains room to store CPU registers when the associated task context goes to sleep, it contains pointers to various resources used by the task, and it specifies the task's priority. There is one task item for every task or thread that exists.

Folio

kernel

Item Type

TASKNODE

Create Call

CreateThread(), ExecuteAsThread(), LoadProgram(), CreateItem()

Delete

DeleteThread(), DeleteItem()

Query

FindTask(), FindItem()

Modify

SetItemOwner(), SetItemPri()

Tags

CREATETASK_TAG_MAXQ-a value indicating the maximum quanta for the task.

CREATETASK_TAG_PC-initial PC.

CREATETASK_TAG_STACKSIZE-the size of a task's call stack.

CREATETASK_TAG_ARGC-the initial argc value passed to the task when it starts up.

CREATETASK_TAG_ARGP-the initial argp value passed to the task when it starts up.

CREATETASK_TAG_SP-initial stack pointer value (thread only).

CREATETASK_TAG_BASE-the initial r9 value.

TAG_ITEM_NAME
(char *) Create. Provide a pointer to the name of the task.
TAG_ITEM_PRI
(uint8) Create. Provide a priority for the taskin the range 10 to 199. If this tag is not given, the task will inherit the priority of the current context.
CREATETASK_TAG_PC
(void *) Create. Provide a pointer to the code to be executed.
CREATETASK_TAG_SP
(void *) Create. Provide a pointer to the memory buffer to use as stack for a thread. When this tag is present, a thread is created. If the tag is not present, then a task is created.
CREATETASK_TAG_STACKSIZE
(uint32) Create. Specifies the size in bytes of the memory buffer reserved for a thread's stack.
CREATETASK_TAG_ARGC
(uint32) Create. A 32-bit value that will be passed to the task or thread being launched as a first argument. If this is omitted, the first argument will be 0.
CREATETASK_TAG_ARGP
(void *) Create. A 32-bit value that will be passed to the task or thread being launched as a second argument. If this is omitted, the second argument will be 0.
CREATETASK_TAG_USERONLY
Create. Specifies that a thread being launched will not make any folio calls. This will be the case for some threads which are used as pure computation engines. Specifying this tag causes the thread to use fewer system resources (no supervisor stack is allocated), but prevents the task from making any calls to a folio.
CREATETASK_TAG_MSGFROMCHILD
(Item) Create. Provides the item number of a message port. The kernel will send a status message to this port whenever the thread or task being created exits. The message is sent by the kernel after the task has been deleted. The msg_Result field of the message contains the exit status of the task. This is the value the task provided to exit(), or the value returned by the task's primary function. The msg_DataPtr field of the message contains the item number of the task that just terminated. Finally, the msg_DataSize field contains the item number of the thread or task that terminated the task. If the task exited on its own, this will be the item number of the task itself. It is the responsibility of the task that receives the status message to delete it when it is no longer needed by using DeleteMsg().
CREATETASK_TAG_ALLOCDTHREADSP
Create. When this tag is supplied, it tells the kernel that if this thread dies by itself, by either returning to the kernel or by calling exit(), then the memory used for its stack must be freed automatically. When this tag is not provided, you are responsible for freeing the stack whenever the thread terminates.