RTEMS Logo

RTEMS 4.9.0 On-Line Library


Task Manager TASK_VARIABLE_ADD - Associate per task variable

PREV UP NEXT Bookshelf RTEMS Ada User's Guide

5.4.17: TASK_VARIABLE_ADD - Associate per task variable

CALLING SEQUENCE:

type Task_Variable_Dtor is access procedure (
   Argument : in     RTEMS.Address;
);

procedure Task_Variable_Add (
   ID            : in     RTEMS.ID;
   Task_Variable : in     RTEMS.Address;
   Dtor          : in     RTEMS.Task_Variable_Dtor;
   Result        :    out RTEMS.Status_Codes
);

DIRECTIVE STATUS CODES:

RTEMS.SUCCESSFUL - per task variable added successfully
RTEMS.INVALID_ADDRESS - task_variable is NULL
RTEMS.INVALID_ID - invalid task id
RTEMS.NO_MEMORY - invalid task id
RTEMS.ILLEGAL_ON_REMOTE_OBJECT - not supported on remote tasks

DESCRIPTION:

This directive adds the memory location specified by the ptr argument to the context of the given task. The variable will then be private to the task. The task can access and modify the variable, but the modifications will not appear to other tasks, and other tasks' modifications to that variable will not affect the value seen by the task. This is accomplished by saving and restoring the variable's value each time a task switch occurs to or from the calling task. If the dtor argument is non-NULL it specifies the address of a `destructor' function which will be called when the task is deleted. The argument passed to the destructor function is the task's value of the variable.

NOTES:

Task variables increase the context switch time to and from the tasks that own them so it is desirable to minimize the number of task variables. One efficient method is to have a single task variable that is a pointer to a dynamically allocated structure containing the task's private `global' data. In this case the destructor function could be `free'.


PREV UP NEXT Bookshelf RTEMS Ada User's Guide

Copyright © 1988-2008 OAR Corporation