From 709796209c88e6749320b3096df57f369c2d62be Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 29 Aug 2018 09:43:44 +0200 Subject: score: Add thread pin/unpin support Add support to temporarily pin a thread to its current processor. This may be used to access per-processor data structures in critical sections with enabled thread dispatching, e.g. a pinned thread is allowed to block. Update #3508. --- cpukit/include/rtems/score/scheduler.h | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'cpukit/include/rtems/score/scheduler.h') diff --git a/cpukit/include/rtems/score/scheduler.h b/cpukit/include/rtems/score/scheduler.h index a6066c8e4a..fe6315daef 100644 --- a/cpukit/include/rtems/score/scheduler.h +++ b/cpukit/include/rtems/score/scheduler.h @@ -136,6 +136,36 @@ typedef struct { Thread_Scheduler_state next_state ); + /** + * @brief Pin thread operation. + * + * @param[in] scheduler The scheduler instance of the specified processor. + * @param[in] the_thread The thread to pin. + * @param[in] node The scheduler node of the thread. + * @param[in] cpu The processor to pin the thread. + */ + void ( *pin )( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + struct Per_CPU_Control *cpu + ); + + /** + * @brief Unpin thread operation. + * + * @param[in] scheduler The scheduler instance of the specified processor. + * @param[in] the_thread The thread to unpin. + * @param[in] node The scheduler node of the thread. + * @param[in] cpu The processor to unpin the thread. + */ + void ( *unpin )( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + struct Per_CPU_Control *cpu + ); + /** * @brief Add processor operation. * @@ -405,10 +435,28 @@ Priority_Control _Scheduler_default_Unmap_priority( Thread_Scheduler_state next_state ); + /** + * @brief Does nothing in a single processor system, otherwise a fatal error + * is issued. + * + * @param[in] scheduler Unused. + * @param[in] the_thread Unused. + * @param[in] node Unused. + * @param[in] cpu Unused. + */ + void _Scheduler_default_Pin_or_unpin( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + struct Per_CPU_Control *cpu + ); + #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ _Scheduler_default_Ask_for_help, \ _Scheduler_default_Reconsider_help_request, \ _Scheduler_default_Withdraw_node, \ + _Scheduler_default_Pin_or_unpin, \ + _Scheduler_default_Pin_or_unpin, \ NULL, \ NULL, #else -- cgit v1.2.3