source: rtems/cpukit/score/src/scheduleredfunblock.c @ b20b736

5
Last change on this file since b20b736 was b20b736, checked in by Sebastian Huber <sebastian.huber@…>, on 06/28/16 at 04:54:50

score: Introduce _Thread_Get_priority()

Avoid direct access to thread internal data fields.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief Scheduler EDF Unblock
5 * @ingroup ScoreScheduler
6 */
7
8/*
9 *  Copyright (C) 2011 Petr Benes.
10 *  Copyright (C) 2011 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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/scheduleredfimpl.h>
22#include <rtems/score/schedulerimpl.h>
23#include <rtems/score/thread.h>
24
25Scheduler_Void_or_thread _Scheduler_EDF_Unblock(
26  const Scheduler_Control *scheduler,
27  Thread_Control          *the_thread
28)
29{
30  Scheduler_EDF_Context *context;
31  Scheduler_EDF_Node    *node;
32  Priority_Control       priority;
33  bool                   prepend_it;
34
35  context = _Scheduler_EDF_Get_context( scheduler );
36  node = _Scheduler_EDF_Thread_get_node( the_thread );
37  priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it );
38  (void) prepend_it;
39
40  node->current_priority = priority;
41  _Scheduler_EDF_Enqueue( context, node, priority );
42
43  /*
44   *  If the thread that was unblocked is more important than the heir,
45   *  then we have a new heir.  This may or may not result in a
46   *  context switch.
47   *
48   *  Normal case:
49   *    If the current thread is preemptible, then we need to do
50   *    a context switch.
51   *  Pseudo-ISR case:
52   *    Even if the thread isn't preemptible, if the new heir is
53   *    a pseudo-ISR system task, we need to do a context switch.
54   */
55  if ( priority < _Thread_Get_priority( _Thread_Heir ) ) {
56    _Scheduler_Update_heir(
57      the_thread,
58      priority == ( SCHEDULER_EDF_PRIO_MSB | PRIORITY_PSEUDO_ISR )
59    );
60  }
61
62  SCHEDULER_RETURN_VOID_OR_NULL;
63}
Note: See TracBrowser for help on using the repository browser.