2011-09-01 Petr Benes <benesp16@fel.cvut.cz>

PR 1895/cpukit
	* rtems/src/ratemoncancel.c, rtems/src/ratemondelete.c,
	rtems/src/ratemonperiod.c, sapi/include/confdefs.h,
	score/Makefile.am, score/include/rtems/score/scheduler.h,
	score/include/rtems/score/schedulerpriority.h,
	score/include/rtems/score/schedulersimple.h,
	score/include/rtems/score/schedulersimplesmp.h,
	score/inline/rtems/score/scheduler.inl,
	score/inline/rtems/score/schedulerpriority.inl,
	score/src/coremutexseize.c: Add priority_compare and release_job
	hooks interfaces to scheduler interface.
	* score/src/schedulerpriorityprioritycompare.c,
	score/src/schedulerpriorityreleasejob.c: New files.
This commit is contained in:
Joel Sherrill
2011-09-01 18:13:54 +00:00
parent 900d9e66f8
commit ac9d2ecc46
15 changed files with 219 additions and 39 deletions

View File

@@ -1,3 +1,19 @@
2011-09-01 Petr Benes <benesp16@fel.cvut.cz>
PR 1895/cpukit
* rtems/src/ratemoncancel.c, rtems/src/ratemondelete.c,
rtems/src/ratemonperiod.c, sapi/include/confdefs.h,
score/Makefile.am, score/include/rtems/score/scheduler.h,
score/include/rtems/score/schedulerpriority.h,
score/include/rtems/score/schedulersimple.h,
score/include/rtems/score/schedulersimplesmp.h,
score/inline/rtems/score/scheduler.inl,
score/inline/rtems/score/schedulerpriority.inl,
score/src/coremutexseize.c: Add priority_compare and release_job
hooks interfaces to scheduler interface.
* score/src/schedulerpriorityprioritycompare.c,
score/src/schedulerpriorityreleasejob.c: New files.
2011-08-29 Joel Sherrill <joel.sherrilL@OARcorp.com> 2011-08-29 Joel Sherrill <joel.sherrilL@OARcorp.com>
* rtems/include/rtems/rtems/tasks.h: Formatting. * rtems/include/rtems/rtems/tasks.h: Formatting.

View File

@@ -53,6 +53,7 @@ rtems_status_code rtems_rate_monotonic_cancel(
} }
(void) _Watchdog_Remove( &the_period->Timer ); (void) _Watchdog_Remove( &the_period->Timer );
the_period->state = RATE_MONOTONIC_INACTIVE; the_period->state = RATE_MONOTONIC_INACTIVE;
_Scheduler_Release_job(the_period->owner, 0);
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;

View File

@@ -51,6 +51,7 @@ rtems_status_code rtems_rate_monotonic_delete(
(void) _Watchdog_Remove( &the_period->Timer ); (void) _Watchdog_Remove( &the_period->Timer );
the_period->state = RATE_MONOTONIC_INACTIVE; the_period->state = RATE_MONOTONIC_INACTIVE;
_Rate_monotonic_Free( the_period ); _Rate_monotonic_Free( the_period );
_Scheduler_Release_job(the_period->owner, 0);
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;

View File

@@ -143,6 +143,8 @@ void _Rate_monotonic_Initiate_statistics(
_Timespec_Add_to( &the_period->cpu_usage_period_initiated, &ran ); _Timespec_Add_to( &the_period->cpu_usage_period_initiated, &ran );
} }
#endif #endif
_Scheduler_Release_job(the_period->owner, the_period->next_length);
} }
void _Rate_monotonic_Update_statistics( void _Rate_monotonic_Update_statistics(
@@ -282,6 +284,8 @@ rtems_status_code rtems_rate_monotonic_period(
if ( the_period->state == RATE_MONOTONIC_INACTIVE ) { if ( the_period->state == RATE_MONOTONIC_INACTIVE ) {
_ISR_Enable( level ); _ISR_Enable( level );
the_period->next_length = length;
/* /*
* Baseline statistics information for the beginning of a period. * Baseline statistics information for the beginning of a period.
*/ */
@@ -295,8 +299,6 @@ rtems_status_code rtems_rate_monotonic_period(
NULL NULL
); );
the_period->next_length = length;
_Watchdog_Insert_ticks( &the_period->Timer, length ); _Watchdog_Insert_ticks( &the_period->Timer, length );
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;
@@ -353,6 +355,7 @@ rtems_status_code rtems_rate_monotonic_period(
the_period->next_length = length; the_period->next_length = length;
_Watchdog_Insert_ticks( &the_period->Timer, length ); _Watchdog_Insert_ticks( &the_period->Timer, length );
_Scheduler_Release_job(the_period->owner, the_period->next_length);
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
return RTEMS_TIMEOUT; return RTEMS_TIMEOUT;
} }

View File

@@ -661,6 +661,9 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
#if defined(CONFIGURE_SCHEDULER_USER) #if defined(CONFIGURE_SCHEDULER_USER)
#define CONFIGURE_SCHEDULER_ENTRY_POINTS \ #define CONFIGURE_SCHEDULER_ENTRY_POINTS \
CONFIGURE_SCHEDULER_USER_ENTRY_POINTS CONFIGURE_SCHEDULER_USER_ENTRY_POINTS
#define CONFIGURE_SCHEDULER_MEMORY_FOR_SCHEDULER \
CONFIGURE_SCHEDULER_USER_MEMORY_FOR_SCHEDULER
#endif #endif
/* /*

View File

@@ -203,6 +203,8 @@ libscore_a_SOURCES += src/schedulerpriority.c \
src/schedulerpriorityenqueuefirst.c \ src/schedulerpriorityenqueuefirst.c \
src/schedulerpriorityextract.c \ src/schedulerpriorityextract.c \
src/schedulerpriorityfree.c \ src/schedulerpriorityfree.c \
src/schedulerpriorityprioritycompare.c \
src/schedulerpriorityreleasejob.c \
src/schedulerpriorityschedule.c \ src/schedulerpriorityschedule.c \
src/schedulerpriorityunblock.c \ src/schedulerpriorityunblock.c \
src/schedulerpriorityupdate.c \ src/schedulerpriorityupdate.c \

View File

@@ -77,8 +77,18 @@ typedef struct {
/** extract a thread from the ready set */ /** extract a thread from the ready set */
void ( *extract )(Thread_Control *); void ( *extract )(Thread_Control *);
/**
* Compares two priorities (returns >0 for higher priority, 0 for equal
* and <0 for lower priority).
*/
int ( *priority_compare )(Priority_Control, Priority_Control);
/** This routine is called upon release of a new job. */
void ( *release_job ) (Thread_Control *, uint32_t);
/** perform scheduler update actions required at each clock tick */ /** perform scheduler update actions required at each clock tick */
void ( *tick )(void); void ( *tick )(void);
} Scheduler_Operations; } Scheduler_Operations;
/** /**
@@ -106,6 +116,20 @@ typedef struct {
*/ */
extern Scheduler_Control _Scheduler; extern Scheduler_Control _Scheduler;
/**
* Macro testing whether @a p1 has lower priority than @a p2
* in the intuitive sense of priority.
*/
#define _Scheduler_Is_priority_lower_than( _p1, _p2 ) \
(_Scheduler_Priority_compare(_p1,_p2) < 0)
/**
* Macro testing whether @a p1 has higher priority than @a p2
* in the intuitive sense of priority.
*/
#define _Scheduler_Is_priority_higher_than( _p1, _p2 ) \
(_Scheduler_Priority_compare(_p1,_p2) > 0)
/** /**
* This routine initializes the scheduler to the policy chosen by the user * This routine initializes the scheduler to the policy chosen by the user
* through confdefs, or to the priority scheduler with ready chains by * through confdefs, or to the priority scheduler with ready chains by

View File

@@ -49,6 +49,8 @@ extern "C" {
_Scheduler_priority_Enqueue, /* enqueue entry point */ \ _Scheduler_priority_Enqueue, /* enqueue entry point */ \
_Scheduler_priority_Enqueue_first, /* enqueue_first entry point */ \ _Scheduler_priority_Enqueue_first, /* enqueue_first entry point */ \
_Scheduler_priority_Extract, /* extract entry point */ \ _Scheduler_priority_Extract, /* extract entry point */ \
_Scheduler_priority_Priority_compare, /* compares two priorities */ \
_Scheduler_priority_Release_job, /* new period of task */ \
_Scheduler_priority_Tick /* tick entry point */ \ _Scheduler_priority_Tick /* tick entry point */ \
} }
@@ -171,6 +173,30 @@ void _Scheduler_priority_Extract(
Thread_Control *the_thread Thread_Control *the_thread
); );
/**
* @brief Scheduler priority Priority compare
*
* This routine compares two priorities.
*/
int _Scheduler_priority_Priority_compare(
Priority_Control p1,
Priority_Control p2
);
/**
* @brief Scheduler priority Release job
*
* This routine is called when a new job of task is released.
*
* @param[in] the_thread is the owner of the job.
* @param[in] deadline of the new job from now. If equal to 0,
* the job was cancelled or deleted.
*/
void _Scheduler_priority_Release_job (
Thread_Control *the_thread,
uint32_t deadline
);
/** /**
* @brief Deterministic Priority Scheduler Tick Method * @brief Deterministic Priority Scheduler Tick Method
* *

View File

@@ -46,6 +46,8 @@ extern "C" {
_Scheduler_simple_Enqueue, /* enqueue entry point */ \ _Scheduler_simple_Enqueue, /* enqueue entry point */ \
_Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \ _Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \
_Scheduler_simple_Extract, /* extract entry point */ \ _Scheduler_simple_Extract, /* extract entry point */ \
_Scheduler_priority_Priority_compare, /* compares two priorities */ \
_Scheduler_priority_Release_job, /* new period of task */ \
_Scheduler_priority_Tick /* tick entry point */ \ _Scheduler_priority_Tick /* tick entry point */ \
} }

View File

@@ -40,6 +40,7 @@ extern "C" {
#include <rtems/score/scheduler.h> #include <rtems/score/scheduler.h>
#include <rtems/score/schedulersimple.h> #include <rtems/score/schedulersimple.h>
#include <rtems/score/schedulerpriority.h>
/** /**
* Entry points for Scheduler Simple SMP * Entry points for Scheduler Simple SMP
@@ -57,6 +58,8 @@ extern "C" {
_Scheduler_simple_Enqueue, /* enqueue entry point */ \ _Scheduler_simple_Enqueue, /* enqueue entry point */ \
_Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \ _Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \
_Scheduler_simple_Extract, /* extract entry point */ \ _Scheduler_simple_Extract, /* extract entry point */ \
_Scheduler_priority_Priority_compare, /* compares two priorities */ \
_Scheduler_priority_Release_job, /* new period of task */ \
_Scheduler_simple_smp_Tick /* tick entry point */ \ _Scheduler_simple_smp_Tick /* tick entry point */ \
} }

View File

@@ -159,6 +159,32 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Extract(
_Scheduler.Operations.extract( the_thread ); _Scheduler.Operations.extract( the_thread );
} }
/**
* @brief Scheduler Priority compare
*
* This routine compares two priorities.
*/
RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare(
Priority_Control p1,
Priority_Control p2
)
{
return _Scheduler.Operations.priority_compare(p1, p2);
}
/**
* @brief Scheduler Release job
*
* This routine is called when a new period of task is issued.
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Release_job(
Thread_Control *the_thread,
uint32_t length
)
{
_Scheduler.Operations.release_job(the_thread, length);
}
/** @brief Scheduler Method Invoked at Each Clock Tick /** @brief Scheduler Method Invoked at Each Clock Tick
* *
* This method is invoked at each clock tick to allow the scheduler * This method is invoked at each clock tick to allow the scheduler

View File

@@ -185,6 +185,23 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(void)
); );
} }
/**
* @brief Scheduler priority Priority compare body
*
* This routine implements priority comparison for priority-based
* scheduling.
*
* @return >0 for higher priority, 0 for equal and <0 for lower priority.
*/
RTEMS_INLINE_ROUTINE int _Scheduler_priority_Priority_compare_body(
Priority_Control p1,
Priority_Control p2
)
{
/* High priority in priority scheduler is represented by low numbers. */
return ( p2 - p1 );
}
/**@}*/ /**@}*/
#endif #endif

View File

@@ -60,7 +60,9 @@ void _CORE_mutex_Seize_interrupt_blocking(
executing = _Thread_Executing; executing = _Thread_Executing;
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) { if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) {
if ( the_mutex->holder->current_priority > executing->current_priority ) { if ( _Scheduler_Is_priority_higher_than(
executing->current_priority,
the_mutex->holder->current_priority)) {
_Thread_Change_priority( _Thread_Change_priority(
the_mutex->holder, the_mutex->holder,
executing->current_priority, executing->current_priority,

View File

@@ -0,0 +1,27 @@
/*
* COPYRIGHT (c) 2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/config.h>
#include <rtems/score/chain.h>
#include <rtems/score/schedulerpriority.h>
int _Scheduler_priority_Priority_compare(
Priority_Control p1,
Priority_Control p2
)
{
return _Scheduler_priority_Priority_compare_body( p1, p2 );
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2011 Petr Benes.
* Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/config.h>
#include <rtems/score/scheduler.h>
#include <rtems/score/schedulerpriority.h>
void _Scheduler_priority_Release_job(
Thread_Control *the_thread,
uint32_t deadline
)
{
return;
}