5
Last change
on this file since 99fc1d1d was
d37adfe5,
checked in by Sebastian Huber <sebastian.huber@…>, on 03/03/16 at 06:02:03
|
score: Fix CPU time used by executing threads
The CPU time used of a thread was previously maintained per-processor
mostly during _Thread_Dispatch(). However, on SMP configurations the
actual processor of a thread is difficult to figure out since thread
dispatching is a highly asynchronous process (e.g. via inter-processor
interrupts). Only the intended processor of a thread is known to the
scheduler easily. Do the CPU usage accounting during thread heir
updates in the context of the scheduler operations. Provide the
function _Thread_Get_CPU_time_used() to get the CPU usage of a thread
using proper locks to get a consistent value.
Close #2627.
|
-
Property mode set to
100644
|
File size:
934 bytes
|
Line | |
---|
1 | /* |
---|
2 | * Copyright (c) 2013-2014 embedded brains GmbH |
---|
3 | * |
---|
4 | * The license and distribution terms for this file may be |
---|
5 | * found in the file LICENSE in this distribution or at |
---|
6 | * http://www.rtems.org/license/LICENSE. |
---|
7 | */ |
---|
8 | |
---|
9 | #if HAVE_CONFIG_H |
---|
10 | #include "config.h" |
---|
11 | #endif |
---|
12 | |
---|
13 | #include <rtems/score/schedulersmpimpl.h> |
---|
14 | |
---|
15 | void _Scheduler_SMP_Start_idle( |
---|
16 | const Scheduler_Control *scheduler, |
---|
17 | Thread_Control *thread, |
---|
18 | Per_CPU_Control *cpu |
---|
19 | ) |
---|
20 | { |
---|
21 | Scheduler_Context *context = _Scheduler_Get_context( scheduler ); |
---|
22 | Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); |
---|
23 | Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_node( thread ); |
---|
24 | |
---|
25 | _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED ); |
---|
26 | node->state = SCHEDULER_SMP_NODE_SCHEDULED; |
---|
27 | |
---|
28 | _Thread_Set_CPU( thread, cpu ); |
---|
29 | _Chain_Append_unprotected( &self->Scheduled, &node->Base.Node ); |
---|
30 | _Chain_Prepend_unprotected( &self->Idle_threads, &thread->Object.Node ); |
---|
31 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.