RTEMS
schedulersmp.c
1 /*
2  * Copyright (c) 2014, 2017 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 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif
12 
14 
15 void _Scheduler_Request_ask_for_help( Thread_Control *the_thread )
16 {
17  ISR_lock_Context scheduler_lock_context;
18 
19  _Thread_Scheduler_acquire_critical( the_thread, &scheduler_lock_context );
20 
21  if ( _Chain_Is_node_off_chain( &the_thread->Scheduler.Help_node ) ) {
22  Per_CPU_Control *cpu;
23  ISR_lock_Context per_cpu_lock_context;
24 
25  cpu = _Thread_Get_CPU( the_thread );
26  _Per_CPU_Acquire( cpu, &per_cpu_lock_context );
27 
30  &the_thread->Scheduler.Help_node
31  );
32 
33  _Per_CPU_Release( cpu, &per_cpu_lock_context );
34 
35  _Thread_Dispatch_request( _Per_CPU_Get(), cpu );
36  }
37 
38  _Thread_Scheduler_release_critical( the_thread, &scheduler_lock_context );
39 }
static __inline__ bool _Chain_Is_node_off_chain(const Chain_Node *node)
Checks if the node is off chain.
Definition: chainimpl.h:142
Thread_Scheduler_control Scheduler
Scheduler related control.
Definition: thread.h:764
Chain_Control Threads_in_need_for_help
Chain of threads in need for help.
Definition: percpu.h:497
static __inline__ void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
Definition: chainimpl.h:680
Per CPU Core Structure.
Definition: percpu.h:347
static __inline__ void _Thread_Dispatch_request(Per_CPU_Control *cpu_self, Per_CPU_Control *cpu_target)
Requests a thread dispatch on the target processor.
Chain_Node Help_node
Node for the Per_CPU_Control::Threads_in_need_for_help chain.
Definition: thread.h:302
SMP Scheduler Implementation.
static __inline__ void _Thread_Scheduler_acquire_critical(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Acquires the lock context in a critical section.
Definition: threadimpl.h:1483
static __inline__ void _Thread_Scheduler_release_critical(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Releases the lock context in a critical section.
Definition: threadimpl.h:1497
static __inline__ Per_CPU_Control * _Thread_Get_CPU(const Thread_Control *thread)
Gets the cpu of the thread's scheduler.
Definition: threadimpl.h:867
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65