source: rtems/c/src/exec/rtems/src/tasksetnote.c @ c4d69e2

4.104.114.84.95
Last change on this file since c4d69e2 was c4d69e2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/17/99 at 21:02:16

Split Task Manager into multiple files. Eventually this effort will
reduce the size of executables.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  RTEMS Task Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/rtems/status.h>
18#include <rtems/rtems/support.h>
19#include <rtems/rtems/modes.h>
20#include <rtems/score/object.h>
21#include <rtems/score/stack.h>
22#include <rtems/score/states.h>
23#include <rtems/rtems/tasks.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/threadq.h>
26#include <rtems/score/tod.h>
27#include <rtems/score/userext.h>
28#include <rtems/score/wkspace.h>
29#include <rtems/score/apiext.h>
30#include <rtems/score/sysstate.h>
31
32/*PAGE
33 *
34 * rtems_task_set_note
35 *
36 *  This directive sets the specified notepad contents to the given
37 *  note.
38 *
39 *  Input parameters:
40 *    id      - thread id
41 *    notepad - notepad number
42 *    note    - note value
43 *
44 *  Output parameters:
45 *    RTEMS_SUCCESSFUL - if successful
46 *    error code        - if unsuccessful
47 */
48
49rtems_status_code rtems_task_set_note(
50  Objects_Id id,
51  unsigned32 notepad,
52  unsigned32 note
53)
54{
55  register Thread_Control *the_thread;
56  Objects_Locations        location;
57  RTEMS_API_Control       *api;
58
59  /*
60   *  NOTE:  There is no check for < RTEMS_NOTEPAD_FIRST because that would
61   *         be checking an unsigned number for being negative.
62   */
63
64  if ( notepad > RTEMS_NOTEPAD_LAST )
65    return RTEMS_INVALID_NUMBER;
66
67  /*
68   *  Optimize the most likely case to avoid the Thread_Dispatch.
69   */
70
71  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ||
72       _Objects_Are_ids_equal( id, _Thread_Executing->Object.id ) ) {
73      api = _Thread_Executing->API_Extensions[ THREAD_API_RTEMS ];
74      api->Notepads[ notepad ] = note;
75      return RTEMS_SUCCESSFUL;
76  }
77
78  the_thread = _Thread_Get( id, &location );
79  switch ( location ) {
80
81    case OBJECTS_REMOTE:
82#if defined(RTEMS_MULTIPROCESSING)
83      return _RTEMS_tasks_MP_Send_request_packet(
84        RTEMS_TASKS_MP_SET_NOTE_REQUEST,
85        id,
86        0,          /* Not used */
87        notepad,
88        note
89      );
90#endif
91
92    case OBJECTS_ERROR:
93      return RTEMS_INVALID_ID;
94
95    case OBJECTS_LOCAL:
96      api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
97      api->Notepads[ notepad ] = note;
98      _Thread_Enable_dispatch();
99      return RTEMS_SUCCESSFUL;
100  }
101
102  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
103}
Note: See TracBrowser for help on using the repository browser.