source: rtems/cpukit/rtems/src/taskvariableget.c @ 5618c37a

4.115
Last change on this file since 5618c37a was 5618c37a, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 13:14:48

score: Create thread implementation header

Move implementation specific parts of thread.h and thread.inl into new
header file threadimpl.h. The thread.h contains now only the
application visible API.

Remove superfluous header file includes from various files.

  • Property mode set to 100644
File size: 1.8 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/rtems/tasksimpl.h>
22#include <rtems/score/threadimpl.h>
23#include <rtems/score/wkspace.h>
24#include <rtems/config.h>
25
26/*
27 *  rtems_task_variable_get
28 *
29 *  This directive gets the value of a task variable.
30 */
31
32rtems_status_code rtems_task_variable_get(
33  rtems_id tid,
34  void **ptr,
35  void **result
36)
37{
38  Thread_Control        *the_thread;
39  Objects_Locations      location;
40  rtems_task_variable_t *tvp;
41
42#if defined( RTEMS_SMP )
43  if ( rtems_configuration_is_smp_enabled() ) {
44    return RTEMS_NOT_IMPLEMENTED;
45  }
46#endif
47
48  if ( !ptr )
49    return RTEMS_INVALID_ADDRESS;
50
51  if ( !result )
52    return RTEMS_INVALID_ADDRESS;
53
54  the_thread = _Thread_Get (tid, &location);
55  switch (location) {
56
57    case OBJECTS_LOCAL:
58      /*
59       *  Figure out if the variable is in this task's list.
60       */
61      tvp = the_thread->task_variables;
62      while (tvp) {
63        if (tvp->ptr == ptr) {
64          /*
65           * Should this return the current (i.e not the
66           * saved) value if `tid' is the current task?
67           */
68          *result = tvp->tval;
69          _Objects_Put( &the_thread->Object );
70          return RTEMS_SUCCESSFUL;
71        }
72        tvp = (rtems_task_variable_t *)tvp->next;
73      }
74      _Objects_Put( &the_thread->Object );
75      return RTEMS_INVALID_ADDRESS;
76
77#if defined(RTEMS_MULTIPROCESSING)
78    case OBJECTS_REMOTE:
79      _Thread_Dispatch();
80      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
81#endif
82
83    case OBJECTS_ERROR:
84      break;
85  }
86  return RTEMS_INVALID_ID;
87}
Note: See TracBrowser for help on using the repository browser.