forked from Imagelibrary/rtems
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:
@@ -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>
|
||||
|
||||
* rtems/include/rtems/rtems/tasks.h: Formatting.
|
||||
|
||||
@@ -53,6 +53,7 @@ rtems_status_code rtems_rate_monotonic_cancel(
|
||||
}
|
||||
(void) _Watchdog_Remove( &the_period->Timer );
|
||||
the_period->state = RATE_MONOTONIC_INACTIVE;
|
||||
_Scheduler_Release_job(the_period->owner, 0);
|
||||
_Thread_Enable_dispatch();
|
||||
return RTEMS_SUCCESSFUL;
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ rtems_status_code rtems_rate_monotonic_delete(
|
||||
(void) _Watchdog_Remove( &the_period->Timer );
|
||||
the_period->state = RATE_MONOTONIC_INACTIVE;
|
||||
_Rate_monotonic_Free( the_period );
|
||||
_Scheduler_Release_job(the_period->owner, 0);
|
||||
_Thread_Enable_dispatch();
|
||||
return RTEMS_SUCCESSFUL;
|
||||
|
||||
|
||||
@@ -143,6 +143,8 @@ void _Rate_monotonic_Initiate_statistics(
|
||||
_Timespec_Add_to( &the_period->cpu_usage_period_initiated, &ran );
|
||||
}
|
||||
#endif
|
||||
|
||||
_Scheduler_Release_job(the_period->owner, the_period->next_length);
|
||||
}
|
||||
|
||||
void _Rate_monotonic_Update_statistics(
|
||||
@@ -282,6 +284,8 @@ rtems_status_code rtems_rate_monotonic_period(
|
||||
if ( the_period->state == RATE_MONOTONIC_INACTIVE ) {
|
||||
_ISR_Enable( level );
|
||||
|
||||
the_period->next_length = length;
|
||||
|
||||
/*
|
||||
* Baseline statistics information for the beginning of a period.
|
||||
*/
|
||||
@@ -295,8 +299,6 @@ rtems_status_code rtems_rate_monotonic_period(
|
||||
NULL
|
||||
);
|
||||
|
||||
the_period->next_length = length;
|
||||
|
||||
_Watchdog_Insert_ticks( &the_period->Timer, length );
|
||||
_Thread_Enable_dispatch();
|
||||
return RTEMS_SUCCESSFUL;
|
||||
@@ -353,6 +355,7 @@ rtems_status_code rtems_rate_monotonic_period(
|
||||
the_period->next_length = length;
|
||||
|
||||
_Watchdog_Insert_ticks( &the_period->Timer, length );
|
||||
_Scheduler_Release_job(the_period->owner, the_period->next_length);
|
||||
_Thread_Enable_dispatch();
|
||||
return RTEMS_TIMEOUT;
|
||||
}
|
||||
|
||||
@@ -661,6 +661,9 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
|
||||
#if defined(CONFIGURE_SCHEDULER_USER)
|
||||
#define CONFIGURE_SCHEDULER_ENTRY_POINTS \
|
||||
CONFIGURE_SCHEDULER_USER_ENTRY_POINTS
|
||||
|
||||
#define CONFIGURE_SCHEDULER_MEMORY_FOR_SCHEDULER \
|
||||
CONFIGURE_SCHEDULER_USER_MEMORY_FOR_SCHEDULER
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -203,6 +203,8 @@ libscore_a_SOURCES += src/schedulerpriority.c \
|
||||
src/schedulerpriorityenqueuefirst.c \
|
||||
src/schedulerpriorityextract.c \
|
||||
src/schedulerpriorityfree.c \
|
||||
src/schedulerpriorityprioritycompare.c \
|
||||
src/schedulerpriorityreleasejob.c \
|
||||
src/schedulerpriorityschedule.c \
|
||||
src/schedulerpriorityunblock.c \
|
||||
src/schedulerpriorityupdate.c \
|
||||
|
||||
@@ -77,8 +77,18 @@ typedef struct {
|
||||
/** extract a thread from the ready set */
|
||||
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 */
|
||||
void ( *tick )(void);
|
||||
|
||||
} Scheduler_Operations;
|
||||
|
||||
/**
|
||||
@@ -106,6 +116,20 @@ typedef struct {
|
||||
*/
|
||||
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
|
||||
* through confdefs, or to the priority scheduler with ready chains by
|
||||
|
||||
@@ -49,6 +49,8 @@ extern "C" {
|
||||
_Scheduler_priority_Enqueue, /* enqueue entry point */ \
|
||||
_Scheduler_priority_Enqueue_first, /* enqueue_first 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 */ \
|
||||
}
|
||||
|
||||
@@ -171,6 +173,30 @@ void _Scheduler_priority_Extract(
|
||||
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
|
||||
*
|
||||
|
||||
@@ -46,6 +46,8 @@ extern "C" {
|
||||
_Scheduler_simple_Enqueue, /* enqueue entry point */ \
|
||||
_Scheduler_simple_Enqueue_first, /* enqueue_first 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 */ \
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ extern "C" {
|
||||
|
||||
#include <rtems/score/scheduler.h>
|
||||
#include <rtems/score/schedulersimple.h>
|
||||
#include <rtems/score/schedulerpriority.h>
|
||||
|
||||
/**
|
||||
* Entry points for Scheduler Simple SMP
|
||||
@@ -57,6 +58,8 @@ extern "C" {
|
||||
_Scheduler_simple_Enqueue, /* enqueue entry point */ \
|
||||
_Scheduler_simple_Enqueue_first, /* enqueue_first 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 */ \
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,32 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Extract(
|
||||
_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
|
||||
*
|
||||
* This method is invoked at each clock tick to allow the scheduler
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -60,7 +60,9 @@ void _CORE_mutex_Seize_interrupt_blocking(
|
||||
|
||||
executing = _Thread_Executing;
|
||||
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(
|
||||
the_mutex->holder,
|
||||
executing->current_priority,
|
||||
|
||||
27
cpukit/score/src/schedulerpriorityprioritycompare.c
Normal file
27
cpukit/score/src/schedulerpriorityprioritycompare.c
Normal 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 );
|
||||
}
|
||||
27
cpukit/score/src/schedulerpriorityreleasejob.c
Normal file
27
cpukit/score/src/schedulerpriorityreleasejob.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user