From 05df0a846f436295a490cc9ac19e5a4061c3a575 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 17 May 1999 20:41:13 +0000 Subject: Thread Handler split into multiple files. Eventually, as RTEMS is split into one function per file, this will decrease the size of executables. --- cpukit/score/src/threadhandler.c | 119 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 cpukit/score/src/threadhandler.c (limited to 'cpukit/score/src/threadhandler.c') diff --git a/cpukit/score/src/threadhandler.c b/cpukit/score/src/threadhandler.c new file mode 100644 index 0000000000..bd4e4d319f --- /dev/null +++ b/cpukit/score/src/threadhandler.c @@ -0,0 +1,119 @@ +/* + * Thread Handler + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*PAGE + * + * _Thread_Handler + * + * This routine is the "primal" entry point for all threads. + * _Context_Initialize() dummies up the thread's initial context + * to cause the first Context_Switch() to jump to _Thread_Handler(). + * + * This routine is the default thread exitted error handler. It is + * returned to when a thread exits. The configured fatal error handler + * is invoked to process the exit. + * + * NOTE: + * + * On entry, it is assumed all interrupts are blocked and that this + * routine needs to set the initial isr level. This may or may not + * actually be needed by the context switch routine and as a result + * interrupts may already be at there proper level. Either way, + * setting the initial isr level properly here is safe. + * + * Currently this is only really needed for the posix port, + * ref: _Context_Switch in unix/cpu.c + * + * Input parameters: NONE + * + * Output parameters: NONE + */ + +void _Thread_Handler( void ) +{ + ISR_Level level; + Thread_Control *executing; + + executing = _Thread_Executing; + + /* + * have to put level into a register for those cpu's that use + * inline asm here + */ + + level = executing->Start.isr_level; + _ISR_Set_level(level); + + /* + * Take care that 'begin' extensions get to complete before + * 'switch' extensions can run. This means must keep dispatch + * disabled until all 'begin' extensions complete. + */ + + _User_extensions_Thread_begin( executing ); + + /* + * At this point, the dispatch disable level BETTER be 1. + */ + + _Thread_Enable_dispatch(); + + switch ( executing->Start.prototype ) { + case THREAD_START_NUMERIC: + (*(Thread_Entry_numeric) executing->Start.entry_point)( + executing->Start.numeric_argument + ); + break; + case THREAD_START_POINTER: + (*(Thread_Entry_pointer) executing->Start.entry_point)( + executing->Start.pointer_argument + ); + break; + case THREAD_START_BOTH_POINTER_FIRST: + (*(Thread_Entry_both_pointer_first) executing->Start.entry_point)( + executing->Start.pointer_argument, + executing->Start.numeric_argument + ); + break; + case THREAD_START_BOTH_NUMERIC_FIRST: + (*(Thread_Entry_both_numeric_first) executing->Start.entry_point)( + executing->Start.numeric_argument, + executing->Start.pointer_argument + ); + break; + } + + _User_extensions_Thread_exitted( executing ); + + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_THREAD_EXITTED + ); +} -- cgit v1.2.3