source: rtems/cpukit/rtems/src/taskvariabledelete.c @ a3b4632

Last change on this file since a3b4632 was a3b4632, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 4, 2005 at 9:53:58 PM

2005-10-04 Till Straumann <strauman@…>

PR 829/rtems

  • src/tasks.c, src/taskvariabledelete.c: If task variables are deleted from a different context (i.e., executing context != owner of the task variable. The owner meaning the task that registered the dtor in question) the argument passed to the task variable dtor must be tvar and not *ptr which yields the executing task's value of the task variable instead of the owner's.
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  rtems_task_variable_delete - Delete a per-task variable
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/rtems/tasks.h>
17#include <rtems/score/wkspace.h>
18
19/*
20 *  rtems_task_variable_delete
21 *
22 *  This directive removes a task variable.
23 */
24
25rtems_status_code rtems_task_variable_delete(
26  rtems_id  tid,
27  void    **ptr
28)
29{
30  Thread_Control        *the_thread;
31  Objects_Locations      location;
32  rtems_task_variable_t *tvp, *prev;
33
34  if ( !ptr )
35    return RTEMS_INVALID_ADDRESS;
36
37  prev = NULL;
38
39  the_thread = _Thread_Get (tid, &location);
40  switch (location) {
41  case OBJECTS_REMOTE:
42#if defined(RTEMS_MULTIPROCESSING)
43    _Thread_Dispatch();
44    return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
45#endif
46
47  case OBJECTS_ERROR:
48    return RTEMS_INVALID_ID;
49
50  default:
51    return RTEMS_INTERNAL_ERROR;
52
53  case OBJECTS_LOCAL:
54    tvp = the_thread->task_variables;
55    while (tvp) {
56      if (tvp->ptr == ptr) {
57        if (prev) prev->next = tvp->next;
58        else      the_thread->task_variables = tvp->next;
59        if (_Thread_Is_executing(the_thread)) {
60          if (tvp->dtor)
61            (*tvp->dtor)(*tvp->ptr);
62          *tvp->ptr = tvp->gval;
63        } else {
64          if (tvp->dtor)
65            (*tvp->dtor)(tvp->tval);
66        }
67        _Workspace_Free(tvp);
68        _Thread_Enable_dispatch();
69        return RTEMS_SUCCESSFUL;
70      }
71      prev = tvp;
72      tvp = tvp->next;
73    }
74    _Thread_Enable_dispatch();
75    return RTEMS_INVALID_ADDRESS;
76  }
77
78  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
79}
Note: See TracBrowser for help on using the repository browser.