OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [src/] [tasksetpriority.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  RTEMS Task Manager
3
 *
4
 *
5
 *  COPYRIGHT (c) 1989-1999.
6
 *  On-Line Applications Research Corporation (OAR).
7
 *
8
 *  The license and distribution terms for this file may be
9
 *  found in the file LICENSE in this distribution or at
10
 *  http://www.OARcorp.com/rtems/license.html.
11
 *
12
 *  $Id: tasksetpriority.c,v 1.2 2001-09-27 11:59:19 chris Exp $
13
 */
14
 
15
#include <rtems/system.h>
16
#include <rtems/rtems/status.h>
17
#include <rtems/rtems/support.h>
18
#include <rtems/rtems/modes.h>
19
#include <rtems/score/object.h>
20
#include <rtems/score/stack.h>
21
#include <rtems/score/states.h>
22
#include <rtems/rtems/tasks.h>
23
#include <rtems/score/thread.h>
24
#include <rtems/score/threadq.h>
25
#include <rtems/score/tod.h>
26
#include <rtems/score/userext.h>
27
#include <rtems/score/wkspace.h>
28
#include <rtems/score/apiext.h>
29
#include <rtems/score/sysstate.h>
30
 
31
/*PAGE
32
 *
33
 *  rtems_task_set_priority
34
 *
35
 *  This directive changes the priority of the specified thread.
36
 *  The specified thread can be any thread in the system including
37
 *  the requesting thread.
38
 *
39
 *  Input parameters:
40
 *    id           - thread id (0 indicates requesting thread)
41
 *    new_priority - thread priority (0 indicates current priority)
42
 *    old_priority - pointer to previous priority
43
 *
44
 *  Output parameters:
45
 *    old_priority      - previous priority
46
 *    RTEMS_SUCCESSFUL - if successful
47
 *    error code        - if unsuccessful
48
 */
49
 
50
rtems_status_code rtems_task_set_priority(
51
  Objects_Id           id,
52
  rtems_task_priority  new_priority,
53
  rtems_task_priority *old_priority
54
)
55
{
56
  register Thread_Control *the_thread;
57
  Objects_Locations               location;
58
 
59
  if ( new_priority != RTEMS_CURRENT_PRIORITY &&
60
       !_RTEMS_tasks_Priority_is_valid( new_priority ) )
61
    return RTEMS_INVALID_PRIORITY;
62
 
63
  if ( !old_priority )
64
    return RTEMS_INVALID_ADDRESS;
65
 
66
  the_thread = _Thread_Get( id, &location );
67
  switch ( location ) {
68
 
69
    case OBJECTS_REMOTE:
70
#if defined(RTEMS_MULTIPROCESSING)
71
      _Thread_Executing->Wait.return_argument = old_priority;
72
      return _RTEMS_tasks_MP_Send_request_packet(
73
          RTEMS_TASKS_MP_SET_PRIORITY_REQUEST,
74
          id,
75
          new_priority,
76
          0,          /* Not used */
77
 
78
      );
79
#endif
80
 
81
    case OBJECTS_ERROR:
82
      return RTEMS_INVALID_ID;
83
 
84
    case OBJECTS_LOCAL:
85
      /* XXX convert from core priority */
86
      *old_priority = the_thread->current_priority;
87
      if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
88
        the_thread->real_priority = new_priority;
89
        if ( the_thread->resource_count == 0 ||
90
             the_thread->current_priority > new_priority )
91
          _Thread_Change_priority( the_thread, new_priority, FALSE );
92
      }
93
      _Thread_Enable_dispatch();
94
      return RTEMS_SUCCESSFUL;
95
  }
96
 
97
  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
98
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.