source: rtems/cpukit/rtems/src/taskvariableget.c @ 2d2352b

4.115
Last change on this file since 2d2352b was 2d2352b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/13 at 09:48:57

score: Add and use _Objects_Put()

Add and use _Objects_Put_without_thread_dispatch(). These two functions
pair with the _Objects_Get() function. This helps to introduce object
specific SMP locks to avoid lock contention.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief Get a per-task variable
5 * @ingroup ClassicTasks Tasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/rtems/tasks.h>
23#include <rtems/score/wkspace.h>
24
25/*
26 *  rtems_task_variable_get
27 *
28 *  This directive gets the value of a task variable.
29 */
30
31rtems_status_code rtems_task_variable_get(
32  rtems_id tid,
33  void **ptr,
34  void **result
35)
36{
37  Thread_Control        *the_thread;
38  Objects_Locations      location;
39  rtems_task_variable_t *tvp;
40
41  if ( !ptr )
42    return RTEMS_INVALID_ADDRESS;
43
44  if ( !result )
45    return RTEMS_INVALID_ADDRESS;
46
47  the_thread = _Thread_Get (tid, &location);
48  switch (location) {
49
50    case OBJECTS_LOCAL:
51      /*
52       *  Figure out if the variable is in this task's list.
53       */
54      tvp = the_thread->task_variables;
55      while (tvp) {
56        if (tvp->ptr == ptr) {
57          /*
58           * Should this return the current (i.e not the
59           * saved) value if `tid' is the current task?
60           */
61          *result = tvp->tval;
62          _Objects_Put( &the_thread->Object );
63          return RTEMS_SUCCESSFUL;
64        }
65        tvp = (rtems_task_variable_t *)tvp->next;
66      }
67      _Objects_Put( &the_thread->Object );
68      return RTEMS_INVALID_ADDRESS;
69
70#if defined(RTEMS_MULTIPROCESSING)
71    case OBJECTS_REMOTE:
72      _Thread_Dispatch();
73      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
74#endif
75
76    case OBJECTS_ERROR:
77      break;
78  }
79  return RTEMS_INVALID_ID;
80}
Note: See TracBrowser for help on using the repository browser.