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

4.104.114.84.95
Last change on this file since c4d69e2 was c4d69e2, checked in by Joel Sherrill <joel.sherrill@…>, on May 17, 1999 at 9:02:16 PM

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

  • Property mode set to 100644
File size: 2.7 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_priority
35 *
36 *  This directive changes the priority of the specified thread.
37 *  The specified thread can be any thread in the system including
38 *  the requesting thread.
39 *
40 *  Input parameters:
41 *    id           - thread id (0 indicates requesting thread)
42 *    new_priority - thread priority (0 indicates current priority)
43 *    old_priority - pointer to previous priority
44 *
45 *  Output parameters:
46 *    old_priority      - previous priority
47 *    RTEMS_SUCCESSFUL - if successful
48 *    error code        - if unsuccessful
49 */
50
51rtems_status_code rtems_task_set_priority(
52  Objects_Id           id,
53  rtems_task_priority  new_priority,
54  rtems_task_priority *old_priority
55)
56{
57  register Thread_Control *the_thread;
58  Objects_Locations               location;
59
60  if ( new_priority != RTEMS_CURRENT_PRIORITY &&
61       !_RTEMS_tasks_Priority_is_valid( new_priority ) )
62    return RTEMS_INVALID_PRIORITY;
63
64  the_thread = _Thread_Get( id, &location );
65  switch ( location ) {
66
67    case OBJECTS_REMOTE:
68#if defined(RTEMS_MULTIPROCESSING)
69      _Thread_Executing->Wait.return_argument = old_priority;
70      return _RTEMS_tasks_MP_Send_request_packet(
71          RTEMS_TASKS_MP_SET_PRIORITY_REQUEST,
72          id,
73          new_priority,
74          0,          /* Not used */
75          0           /* Not used */
76      );
77#endif
78
79    case OBJECTS_ERROR:
80      return RTEMS_INVALID_ID;
81
82    case OBJECTS_LOCAL:
83      *old_priority = the_thread->current_priority;
84      if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
85        the_thread->real_priority = new_priority;
86        if ( the_thread->resource_count == 0 ||
87             the_thread->current_priority > new_priority )
88          _Thread_Change_priority( the_thread, new_priority, FALSE );
89      }
90      _Thread_Enable_dispatch();
91      return RTEMS_SUCCESSFUL;
92  }
93
94  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
95}
Note: See TracBrowser for help on using the repository browser.