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/threadtickletimeslice.c | 87 ++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 cpukit/score/src/threadtickletimeslice.c (limited to 'cpukit/score/src/threadtickletimeslice.c') diff --git a/cpukit/score/src/threadtickletimeslice.c b/cpukit/score/src/threadtickletimeslice.c new file mode 100644 index 0000000000..ea57350b2c --- /dev/null +++ b/cpukit/score/src/threadtickletimeslice.c @@ -0,0 +1,87 @@ +/* + * 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_Tickle_timeslice + * + * This scheduler routine determines if timeslicing is enabled + * for the currently executing thread and, if so, updates the + * timeslice count and checks for timeslice expiration. + * + * Input parameters: NONE + * + * Output parameters: NONE + */ + +void _Thread_Tickle_timeslice( void ) +{ + Thread_Control *executing; + + executing = _Thread_Executing; + + /* + * Increment the number of ticks this thread has been executing + */ + + executing->ticks_executed++; + + /* + * If the thread is not preemptible or is not ready, then + * just return. + */ + + if ( !executing->is_preemptible ) + return; + + if ( !_States_Is_ready( executing->current_state ) ) + return; + + /* + * The cpu budget algorithm determines what happens next. + */ + + switch ( executing->budget_algorithm ) { + case THREAD_CPU_BUDGET_ALGORITHM_NONE: + break; + + case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE: + case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE: + if ( --executing->cpu_time_budget == 0 ) { + _Thread_Reset_timeslice(); + executing->cpu_time_budget = _Thread_Ticks_per_timeslice; + } + break; + + case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT: + if ( --executing->cpu_time_budget == 0 ) + (*executing->budget_callout)( executing ); + break; + } +} -- cgit v1.2.3