source: rtems/cpukit/itron/src/chg_pri.c @ eb02f47

4.104.114.84.95
Last change on this file since eb02f47 was eb02f47, checked in by Joel Sherrill <joel.sherrill@…>, on 11/10/99 at 13:48:27

Committed modifications from ITRON Task and Task Dependendent Synchronization
Working Group. Included are tests.

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[352c9b2]1/*
2 *  The license and distribution terms for this file may be
3 *  found in the file LICENSE in this distribution or at
4 *  http://www.OARcorp.com/rtems/license.html.
5 *
6 *  $Id$
7 */
8
9#include <itron.h>
10
11#include <rtems/score/thread.h>
12#include <rtems/score/userext.h>
13#include <rtems/score/wkspace.h>
14#include <rtems/score/apiext.h>
15#include <rtems/score/sysstate.h>
16
17#include <rtems/itron/task.h>
18
19/*
20 *  chg_pri - Change Task Priority
21 */
22
23ER chg_pri(
24  ID  tskid,
25  PRI tskpri
26)
27{
[eb02f47]28  register Thread_Control *the_thread;
29  Objects_Locations        location;
30  Priority_Control         new_priority; 
31
32  the_thread = _ITRON_Task_Get( tskid, &location );
33  if (!the_thread)
34    _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) );
35
36  if (_States_Is_dormant( the_thread->current_state ))
37    return -1;
38
39  if (( tskpri <= 0 ) || ( tskpri >= 256 ))
40    _ITRON_return_errorno( E_PAR );
41
42  switch ( location ) {
43    case OBJECTS_REMOTE:
44    case OBJECTS_ERROR:
45      _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ));
46
47    case OBJECTS_LOCAL:
48      new_priority = _ITRON_Task_Priority_to_Core( tskpri );
49      the_thread->real_priority = new_priority;
50
51      /*
52       * XXX This is from the rtems side and I'm not sure what this is for.
53       * XXX Is this check right or should change priority be called
54       *     regardless?
55       */
56
57      if ( the_thread->resource_count == 0 ||
58           the_thread->current_priority > new_priority )
59        _Thread_Change_priority( the_thread, new_priority, FALSE );
60
61      _Thread_Enable_dispatch();
62      return E_OK;
63  }
64
65  return E_OBJ;  /* XXX - Should never get here */
[352c9b2]66}
67
[eb02f47]68
Note: See TracBrowser for help on using the repository browser.