source: rtems/cpukit/rtems/src/tasksetnote.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: 2.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Set Task Note
5 *  @ingroup ClassicTasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2009.
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/config.h>
23#include <rtems/rtems/status.h>
24#include <rtems/rtems/support.h>
25#include <rtems/rtems/modes.h>
26#include <rtems/score/object.h>
27#include <rtems/score/stack.h>
28#include <rtems/score/states.h>
29#include <rtems/rtems/tasks.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/threadq.h>
32#include <rtems/score/tod.h>
33#include <rtems/score/wkspace.h>
34#include <rtems/score/apiext.h>
35#include <rtems/score/sysstate.h>
36
37rtems_status_code rtems_task_set_note(
38  rtems_id id,
39  uint32_t notepad,
40  uint32_t note
41)
42{
43  register Thread_Control *the_thread;
44  Objects_Locations        location;
45  RTEMS_API_Control       *api;
46
47  if ( !rtems_configuration_get_notepads_enabled() )
48    return RTEMS_NOT_CONFIGURED;
49
50  /*
51   *  NOTE:  There is no check for < RTEMS_NOTEPAD_FIRST because that would
52   *         be checking an unsigned number for being negative.
53   */
54
55  if ( notepad > RTEMS_NOTEPAD_LAST )
56    return RTEMS_INVALID_NUMBER;
57
58  /*
59   *  Optimize the most likely case to avoid the Thread_Dispatch.
60   */
61
62  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ||
63       _Objects_Are_ids_equal( id, _Thread_Executing->Object.id ) ) {
64      api = _Thread_Executing->API_Extensions[ THREAD_API_RTEMS ];
65      api->Notepads[ notepad ] = note;
66      return RTEMS_SUCCESSFUL;
67  }
68
69  the_thread = _Thread_Get( id, &location );
70  switch ( location ) {
71
72    case OBJECTS_LOCAL:
73      api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
74      api->Notepads[ notepad ] = note;
75      _Objects_Put( &the_thread->Object );
76      return RTEMS_SUCCESSFUL;
77
78#if defined(RTEMS_MULTIPROCESSING)
79    case OBJECTS_REMOTE:
80      return _RTEMS_tasks_MP_Send_request_packet(
81        RTEMS_TASKS_MP_SET_NOTE_REQUEST,
82        id,
83        0,          /* Not used */
84        notepad,
85        note
86      );
87#endif
88
89    case OBJECTS_ERROR:
90      break;
91  }
92
93  return RTEMS_INVALID_ID;
94}
Note: See TracBrowser for help on using the repository browser.