source: rtems/cpukit/rtems/src/tasksetpriority.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 RTEMS Set Task Priority
5 *  @ingroup ClassicTasks
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
24rtems_status_code rtems_task_set_priority(
25  rtems_id             id,
26  rtems_task_priority  new_priority,
27  rtems_task_priority *old_priority
28)
29{
30  register Thread_Control *the_thread;
31  Objects_Locations        location;
32
33  if ( new_priority != RTEMS_CURRENT_PRIORITY &&
34       !_RTEMS_tasks_Priority_is_valid( new_priority ) )
35    return RTEMS_INVALID_PRIORITY;
36
37  if ( !old_priority )
38    return RTEMS_INVALID_ADDRESS;
39
40  the_thread = _Thread_Get( id, &location );
41  switch ( location ) {
42
43    case OBJECTS_LOCAL:
44      /* XXX need helper to "convert" from core priority */
45      *old_priority = the_thread->current_priority;
46      if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
47        the_thread->real_priority = new_priority;
48        if ( the_thread->resource_count == 0 ||
49             the_thread->current_priority > new_priority )
50          _Thread_Change_priority( the_thread, new_priority, false );
51      }
52      _Objects_Put( &the_thread->Object );
53      return RTEMS_SUCCESSFUL;
54
55#if defined(RTEMS_MULTIPROCESSING)
56    case OBJECTS_REMOTE:
57      _Thread_Executing->Wait.return_argument = old_priority;
58      return _RTEMS_tasks_MP_Send_request_packet(
59          RTEMS_TASKS_MP_SET_PRIORITY_REQUEST,
60          id,
61          new_priority,
62          0,          /* Not used */
63          0           /* Not used */
64      );
65#endif
66
67    case OBJECTS_ERROR:
68      break;
69  }
70
71  return RTEMS_INVALID_ID;
72}
Note: See TracBrowser for help on using the repository browser.