source: rtems/cpukit/score/src/schedulercbsgetexecutiontime.c @ 4fc370e

4.115
Last change on this file since 4fc370e was 4fc370e, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/13 at 10:08:23

score: Move thread dispatch content to new file

Move thread dispatch declarations and inline functions to new header
<rtems/score/threaddispatch.h> to make it independent of the
Thread_Control structure. This avoids a cyclic dependency in case
thread dispatch functions are used for the object implementation.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief Get Thread Execution Info
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/config.h>
24#include <rtems/score/scheduler.h>
25#include <rtems/score/schedulercbs.h>
26#include <rtems/score/threaddispatch.h>
27
28int _Scheduler_CBS_Get_execution_time (
29  Scheduler_CBS_Server_id   server_id,
30  time_t                   *exec_time,
31  time_t                   *abs_time
32)
33{
34  Objects_Locations location;
35  Thread_Control *the_thread;
36
37  if ( server_id >= _Scheduler_CBS_Maximum_servers )
38    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
39  if ( !_Scheduler_CBS_Server_list[server_id] )
40    return SCHEDULER_CBS_ERROR_NOSERVER;
41  if ( _Scheduler_CBS_Server_list[server_id]->task_id == -1 ) {
42    *exec_time = 0;
43    return SCHEDULER_CBS_OK;
44  }
45
46  the_thread = _Thread_Get(
47                 _Scheduler_CBS_Server_list[server_id]->task_id,
48                 &location
49               );
50  /* The routine _Thread_Get may disable dispatch and not enable again. */
51  if ( the_thread ) {
52    _Thread_Enable_dispatch();
53    *exec_time = _Scheduler_CBS_Server_list[server_id]->parameters.budget -
54      the_thread->cpu_time_budget;
55  }
56  else {
57    *exec_time = _Scheduler_CBS_Server_list[server_id]->parameters.budget;
58  }
59  return SCHEDULER_CBS_OK;
60}
Note: See TracBrowser for help on using the repository browser.