[1b475860] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @brief Get Thread Execution Info |
---|
| 5 | * |
---|
| 6 | * @ingroup ScoreScheduler |
---|
| 7 | */ |
---|
| 8 | |
---|
[82db8e56] | 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/score/schedulercbs.h> |
---|
[5618c37a] | 23 | #include <rtems/score/threadimpl.h> |
---|
[82db8e56] | 24 | |
---|
| 25 | int _Scheduler_CBS_Get_execution_time ( |
---|
| 26 | Scheduler_CBS_Server_id server_id, |
---|
| 27 | time_t *exec_time, |
---|
| 28 | time_t *abs_time |
---|
| 29 | ) |
---|
| 30 | { |
---|
| 31 | Objects_Locations location; |
---|
| 32 | Thread_Control *the_thread; |
---|
| 33 | |
---|
[04bf7cb] | 34 | if ( server_id >= _Scheduler_CBS_Maximum_servers ) |
---|
[82db8e56] | 35 | return SCHEDULER_CBS_ERROR_INVALID_PARAMETER; |
---|
| 36 | if ( !_Scheduler_CBS_Server_list[server_id] ) |
---|
| 37 | return SCHEDULER_CBS_ERROR_NOSERVER; |
---|
[a7d04d6] | 38 | if ( _Scheduler_CBS_Server_list[server_id]->task_id == -1 ) { |
---|
[82db8e56] | 39 | *exec_time = 0; |
---|
| 40 | return SCHEDULER_CBS_OK; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | the_thread = _Thread_Get( |
---|
| 44 | _Scheduler_CBS_Server_list[server_id]->task_id, |
---|
| 45 | &location |
---|
| 46 | ); |
---|
| 47 | /* The routine _Thread_Get may disable dispatch and not enable again. */ |
---|
| 48 | if ( the_thread ) { |
---|
| 49 | *exec_time = _Scheduler_CBS_Server_list[server_id]->parameters.budget - |
---|
| 50 | the_thread->cpu_time_budget; |
---|
[2d2352b] | 51 | _Objects_Put( &the_thread->Object ); |
---|
[82db8e56] | 52 | } |
---|
| 53 | else { |
---|
| 54 | *exec_time = _Scheduler_CBS_Server_list[server_id]->parameters.budget; |
---|
| 55 | } |
---|
| 56 | return SCHEDULER_CBS_OK; |
---|
| 57 | } |
---|