source: rtems/cpukit/score/src/schedulercbsunblock.c @ a936aa49

4.115
Last change on this file since a936aa49 was f839bf5a, checked in by Christopher Kerl <zargyyoyo@…>, on 12/01/12 at 14:47:07

score misc: Score misc: Clean up Doxygen #10 (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/7983216

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Unblocks a Thread from the Queue
5 *
6 * @ingroup ScoreScheduler
7 */
8
9/*
10 *  Copyright (C) 2011 Petr Benes.
11 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/system.h>
23#include <rtems/score/scheduler.h>
24#include <rtems/score/schedulercbs.h>
25
26void _Scheduler_CBS_Unblock(
27  Thread_Control    *the_thread
28)
29{
30  Scheduler_CBS_Per_thread *sched_info;
31  Scheduler_CBS_Server *serv_info;
32  Priority_Control new_priority;
33
34  _Scheduler_EDF_Enqueue(the_thread);
35  /* TODO: flash critical section? */
36
37  sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
38  serv_info = (Scheduler_CBS_Server *) sched_info->cbs_server;
39
40  /*
41   * Late unblock rule for deadline-driven tasks. The remaining time to
42   * deadline must be sufficient to serve the remaining computation time
43   * without increased utilization of this task. It might cause a deadline
44   * miss of another task.
45   */
46  if (serv_info) {
47    time_t deadline = serv_info->parameters.deadline;
48    time_t budget = serv_info->parameters.budget;
49    time_t deadline_left = the_thread->cpu_time_budget;
50    time_t budget_left = the_thread->real_priority -
51                           _Watchdog_Ticks_since_boot;
52
53    if ( deadline*budget_left > budget*deadline_left ) {
54      /* Put late unblocked task to background until the end of period. */
55      new_priority = the_thread->Start.initial_priority;
56      if ( the_thread->real_priority != new_priority )
57        the_thread->real_priority = new_priority;
58      if ( the_thread->current_priority != new_priority )
59        _Thread_Change_priority(the_thread, new_priority, true);
60    }
61  }
62
63  /*
64   *  If the thread that was unblocked is more important than the heir,
65   *  then we have a new heir.  This may or may not result in a
66   *  context switch.
67   *
68   *  Normal case:
69   *    If the current thread is preemptible, then we need to do
70   *    a context switch.
71   *  Pseudo-ISR case:
72   *    Even if the thread isn't preemptible, if the new heir is
73   *    a pseudo-ISR system task, we need to do a context switch.
74   */
75  if ( _Scheduler_Is_priority_higher_than( the_thread->current_priority,
76       _Thread_Heir->current_priority)) {
77    _Thread_Heir = the_thread;
78    if ( _Thread_Executing->is_preemptible ||
79         the_thread->current_priority == 0 )
80      _Thread_Dispatch_necessary = true;
81  }
82}
Note: See TracBrowser for help on using the repository browser.