source: rtems/cpukit/rtems/src/tasksetpriority.c @ c05d7502

4.115
Last change on this file since c05d7502 was c05d7502, checked in by Mathew Kallada <matkallada@…>, on 12/02/12 at 22:59:17

score misc: Clean up Doxygen #14 (GCI 2012)

This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.

http://www.google-melange.com/gci/task/view/google/gci2012/8025204

  • Property mode set to 100644
File size: 2.2 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/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/rtems/modes.h>
25#include <rtems/score/object.h>
26#include <rtems/score/stack.h>
27#include <rtems/score/states.h>
28#include <rtems/rtems/tasks.h>
29#include <rtems/score/thread.h>
30#include <rtems/score/threadq.h>
31#include <rtems/score/tod.h>
32#include <rtems/score/wkspace.h>
33#include <rtems/score/apiext.h>
34#include <rtems/score/sysstate.h>
35
36rtems_status_code rtems_task_set_priority(
37  rtems_id             id,
38  rtems_task_priority  new_priority,
39  rtems_task_priority *old_priority
40)
41{
42  register Thread_Control *the_thread;
43  Objects_Locations        location;
44
45  if ( new_priority != RTEMS_CURRENT_PRIORITY &&
46       !_RTEMS_tasks_Priority_is_valid( new_priority ) )
47    return RTEMS_INVALID_PRIORITY;
48
49  if ( !old_priority )
50    return RTEMS_INVALID_ADDRESS;
51
52  the_thread = _Thread_Get( id, &location );
53  switch ( location ) {
54
55    case OBJECTS_LOCAL:
56      /* XXX need helper to "convert" from core priority */
57      *old_priority = the_thread->current_priority;
58      if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
59        the_thread->real_priority = new_priority;
60        if ( the_thread->resource_count == 0 ||
61             the_thread->current_priority > new_priority )
62          _Thread_Change_priority( the_thread, new_priority, false );
63      }
64      _Thread_Enable_dispatch();
65      return RTEMS_SUCCESSFUL;
66
67#if defined(RTEMS_MULTIPROCESSING)
68    case OBJECTS_REMOTE:
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      break;
81  }
82
83  return RTEMS_INVALID_ID;
84}
Note: See TracBrowser for help on using the repository browser.