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 | |
---|
10 | #if HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <rtems/system.h> |
---|
15 | #include <rtems/config.h> |
---|
16 | #include <rtems/score/scheduler.h> |
---|
17 | #include <rtems/score/schedulercbs.h> |
---|
18 | |
---|
19 | void _Scheduler_CBS_Release_job( |
---|
20 | Thread_Control *the_thread, |
---|
21 | uint32_t deadline |
---|
22 | ) |
---|
23 | { |
---|
24 | Priority_Control new_priority; |
---|
25 | Scheduler_CBS_Per_thread *sched_info = |
---|
26 | (Scheduler_CBS_Per_thread *) the_thread->scheduler_info; |
---|
27 | Scheduler_CBS_Server *serv_info = |
---|
28 | (Scheduler_CBS_Server *) sched_info->cbs_server; |
---|
29 | |
---|
30 | if (deadline) { |
---|
31 | /* Initializing or shifting deadline. */ |
---|
32 | if (serv_info) |
---|
33 | new_priority = (_Watchdog_Ticks_since_boot + serv_info->parameters.deadline) |
---|
34 | & ~SCHEDULER_EDF_PRIO_MSB; |
---|
35 | else |
---|
36 | new_priority = (_Watchdog_Ticks_since_boot + deadline) |
---|
37 | & ~SCHEDULER_EDF_PRIO_MSB; |
---|
38 | } |
---|
39 | else { |
---|
40 | /* Switch back to background priority. */ |
---|
41 | new_priority = the_thread->Start.initial_priority; |
---|
42 | } |
---|
43 | |
---|
44 | /* Budget replenishment for the next job. */ |
---|
45 | if (serv_info) |
---|
46 | the_thread->cpu_time_budget = serv_info->parameters.budget; |
---|
47 | |
---|
48 | the_thread->real_priority = new_priority; |
---|
49 | _Thread_Change_priority(the_thread, new_priority, true); |
---|
50 | } |
---|