position of task variable codes
Eric Norum
e.norum at sk.sympatico.ca
Sat Apr 13 17:26:24 UTC 2002
On Friday, April 12, 2002, at 08:38 PM, Joe Black wrote:
> Hi, all
>
> Dose the position of rtems_task_variable_add must be in the task?
Yes, the rtems_task_variable_add directive tells RTEMS to add the
specified variable to the task-switch context of the*calling* task.
>
> -----------------------------------------------------------------------------------
>
> my case:
> in init_task
> create task1
> call rtems_task_variable_add to add task1's variable
> start task1
>
> create task2 (with the same priority of task1)
> call rtems_task_variable_add to add task2's variable
> start task2
>
The above code adds the variable to the `init' task twice, so task1 and
task2 still use the `global' (not per-task) value of the variable.
> delete init_task and task1 run
>
> printf task1's variable
>
> suspend task1 and task2 run
>
> printf task2's variable
>
> resume task1
>
> suspend task2 and task1 run
>
> in task1, printf its variable, it failed :(
>
> resume task2 and suspend task1
>
> in task2, printf its variable, failed too
>
> -----------------------------------------------------------------------------------
>
> I can guarantee the parameters passed to rtems_task_variable_add
> are OK in the case above.
> If I put the rtems_task_variable_add in task1 or task2, it works well
>
> Could anyone tell me how I can resolve the problem? 3x.
It sounds like you have already solved it. To add a variable to a
task's context you must call rtems_task_variable_add from that task.
From then on any changes made to that variable by that task will be
local to the task.
--
Eric Norum <eric.norum at usask.ca>
Department of Electrical Engineering
University of Saskatchewan
Saskatoon, Canada.
Phone: (306) 966-5394 FAX: (306) 966-5407
More information about the users
mailing list