1 | /* |
---|
2 | * Copyright (C) 2011 Petr Benes. |
---|
3 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <rtems/system.h> |
---|
17 | #include <rtems/config.h> |
---|
18 | #include <rtems/score/scheduler.h> |
---|
19 | #include <rtems/score/schedulercbs.h> |
---|
20 | |
---|
21 | void _Scheduler_CBS_Release_job( |
---|
22 | Thread_Control *the_thread, |
---|
23 | uint32_t deadline |
---|
24 | ) |
---|
25 | { |
---|
26 | Priority_Control new_priority; |
---|
27 | Scheduler_CBS_Per_thread *sched_info = |
---|
28 | (Scheduler_CBS_Per_thread *) the_thread->scheduler_info; |
---|
29 | Scheduler_CBS_Server *serv_info = |
---|
30 | (Scheduler_CBS_Server *) sched_info->cbs_server; |
---|
31 | |
---|
32 | if (deadline) { |
---|
33 | /* Initializing or shifting deadline. */ |
---|
34 | if (serv_info) |
---|
35 | new_priority = (_Watchdog_Ticks_since_boot + serv_info->parameters.deadline) |
---|
36 | & ~SCHEDULER_EDF_PRIO_MSB; |
---|
37 | else |
---|
38 | new_priority = (_Watchdog_Ticks_since_boot + deadline) |
---|
39 | & ~SCHEDULER_EDF_PRIO_MSB; |
---|
40 | } |
---|
41 | else { |
---|
42 | /* Switch back to background priority. */ |
---|
43 | new_priority = the_thread->Start.initial_priority; |
---|
44 | } |
---|
45 | |
---|
46 | /* Budget replenishment for the next job. */ |
---|
47 | if (serv_info) |
---|
48 | the_thread->cpu_time_budget = serv_info->parameters.budget; |
---|
49 | |
---|
50 | the_thread->real_priority = new_priority; |
---|
51 | _Thread_Change_priority(the_thread, new_priority, true); |
---|
52 | } |
---|