source: rtems/cpukit/score/src/schedulercbsgetexecutiontime.c @ 3d73642

5
Last change on this file since 3d73642 was 80cf60e, checked in by Sebastian Huber <sebastian.huber@…>, on 04/15/20 at 07:48:32

Canonicalize config.h include

Use the following variant which was already used by most source files:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Get Thread Execution Info
5 *
6 * @ingroup RTEMSScoreScheduler
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.org/license/LICENSE.
16 */
17
18#ifdef HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/score/schedulercbs.h>
23#include <rtems/score/threadimpl.h>
24
25int _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  Scheduler_CBS_Server *server;
32  ISR_lock_Context      lock_context;
33  Thread_Control       *the_thread;
34
35  if ( server_id >= _Scheduler_CBS_Maximum_servers ) {
36    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
37  }
38
39  server = &_Scheduler_CBS_Server_list[ server_id ];
40
41  if ( !server->initialized ) {
42    return SCHEDULER_CBS_ERROR_NOSERVER;
43  }
44
45  if ( server->task_id == -1 ) {
46    *exec_time = 0;
47    return SCHEDULER_CBS_OK;
48  }
49
50  the_thread = _Thread_Get( server->task_id, &lock_context );
51
52  if ( the_thread != NULL ) {
53    *exec_time = server->parameters.budget - the_thread->cpu_time_budget;
54    _ISR_lock_ISR_enable( &lock_context );
55  } else {
56    *exec_time = server->parameters.budget;
57  }
58
59  return SCHEDULER_CBS_OK;
60}
Note: See TracBrowser for help on using the repository browser.