summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cpukit/posix/src/pthreadcreate.c3
-rw-r--r--cpukit/rtems/src/taskstart.c20
-rw-r--r--cpukit/score/Makefile.am1
-rw-r--r--cpukit/score/include/rtems/score/scheduler.h17
-rw-r--r--cpukit/score/include/rtems/score/schedulercbs.h3
-rw-r--r--cpukit/score/include/rtems/score/scheduleredf.h3
-rw-r--r--cpukit/score/include/rtems/score/schedulerpriority.h3
-rw-r--r--cpukit/score/include/rtems/score/schedulersimple.h3
-rw-r--r--cpukit/score/include/rtems/score/thread.h6
-rw-r--r--cpukit/score/inline/rtems/score/scheduler.inl16
-rw-r--r--cpukit/score/src/schedulerdefaultstartidle.c22
-rw-r--r--cpukit/score/src/threadcreateidle.c3
-rw-r--r--cpukit/score/src/threadstart.c10
13 files changed, 96 insertions, 14 deletions
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 9585772d17..53e4cdd46c 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -203,7 +203,8 @@ int pthread_create(
THREAD_START_POINTER,
start_routine,
arg,
- 0 /* unused */
+ 0, /* unused */
+ NULL
);
#if defined(RTEMS_DEBUG)
diff --git a/cpukit/rtems/src/taskstart.c b/cpukit/rtems/src/taskstart.c
index 3700139da3..e9ff378614 100644
--- a/cpukit/rtems/src/taskstart.c
+++ b/cpukit/rtems/src/taskstart.c
@@ -58,6 +58,7 @@ rtems_status_code rtems_task_start(
{
register Thread_Control *the_thread;
Objects_Locations location;
+ bool successfully_started;
if ( entry_point == NULL )
return RTEMS_INVALID_ADDRESS;
@@ -66,13 +67,22 @@ rtems_status_code rtems_task_start(
switch ( location ) {
case OBJECTS_LOCAL:
- if ( _Thread_Start(
- the_thread, THREAD_START_NUMERIC, entry_point, NULL, argument ) ) {
- _Objects_Put( &the_thread->Object );
+ successfully_started = _Thread_Start(
+ the_thread,
+ THREAD_START_NUMERIC,
+ entry_point,
+ NULL,
+ argument,
+ NULL
+ );
+
+ _Objects_Put( &the_thread->Object );
+
+ if ( successfully_started ) {
return RTEMS_SUCCESSFUL;
+ } else {
+ return RTEMS_INCORRECT_STATE;
}
- _Objects_Put( &the_thread->Object );
- return RTEMS_INCORRECT_STATE;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index a897e60709..50626fe79c 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -197,6 +197,7 @@ libscore_a_SOURCES += src/objectallocate.c src/objectclose.c \
## SCHEDULER_C_FILES
libscore_a_SOURCES += src/scheduler.c
+libscore_a_SOURCES += src/schedulerdefaultstartidle.c
## SCHEDULERPRIORITY_C_FILES
libscore_a_SOURCES += src/schedulerpriority.c \
diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h
index 5c35a36de1..9e08b23e4f 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -89,6 +89,12 @@ typedef struct {
/** perform scheduler update actions required at each clock tick */
void ( *tick )(void);
+ /**
+ * @brief Starts the idle thread for a particular processor.
+ *
+ * @see _Scheduler_Start_idle().
+ */
+ void ( *start_idle )( Thread_Control *thread, Per_CPU_Control *processor );
} Scheduler_Operations;
/**
@@ -139,6 +145,17 @@ extern Scheduler_Control _Scheduler;
*/
void _Scheduler_Handler_initialization( void );
+/**
+ * @brief Unblocks the thread.
+ *
+ * @param[in/out] thread An idle thread.
+ * @param[in] processor This parameter is unused.
+ */
+void _Scheduler_default_Start_idle(
+ Thread_Control *thread,
+ Per_CPU_Control *processor
+);
+
#ifndef __RTEMS_APPLICATION__
#include <rtems/score/scheduler.inl>
#endif
diff --git a/cpukit/score/include/rtems/score/schedulercbs.h b/cpukit/score/include/rtems/score/schedulercbs.h
index 53452e044a..41f8ab0b57 100644
--- a/cpukit/score/include/rtems/score/schedulercbs.h
+++ b/cpukit/score/include/rtems/score/schedulercbs.h
@@ -60,7 +60,8 @@ extern "C" {
_Scheduler_EDF_Extract, /* extract entry point */ \
_Scheduler_EDF_Priority_compare, /* compares two priorities */ \
_Scheduler_CBS_Release_job, /* new period of task */ \
- _Scheduler_priority_Tick /* tick entry point */ \
+ _Scheduler_priority_Tick, /* tick entry point */ \
+ _Scheduler_default_Start_idle /* start idle entry point */ \
}
/* Return values for CBS server. */
diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h
index 24f9a1ac32..e84b3f5909 100644
--- a/cpukit/score/include/rtems/score/scheduleredf.h
+++ b/cpukit/score/include/rtems/score/scheduleredf.h
@@ -53,7 +53,8 @@ extern "C" {
_Scheduler_EDF_Extract, /* extract entry point */ \
_Scheduler_EDF_Priority_compare, /* compares two priorities */ \
_Scheduler_EDF_Release_job, /* new period of task */ \
- _Scheduler_priority_Tick /* tick entry point */ \
+ _Scheduler_priority_Tick, /* tick entry point */ \
+ _Scheduler_default_Start_idle /* start idle entry point */ \
}
/**
diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h
index f97bb7f075..81c3582e76 100644
--- a/cpukit/score/include/rtems/score/schedulerpriority.h
+++ b/cpukit/score/include/rtems/score/schedulerpriority.h
@@ -52,7 +52,8 @@ extern "C" {
_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 */ \
+ _Scheduler_default_Start_idle /* start idle entry point */ \
}
/**
diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h
index df52a586be..6682074b7c 100644
--- a/cpukit/score/include/rtems/score/schedulersimple.h
+++ b/cpukit/score/include/rtems/score/schedulersimple.h
@@ -50,7 +50,8 @@ extern "C" {
_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 */ \
+ _Scheduler_default_Start_idle /* start idle entry point */ \
}
/**
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 3cddb5a3e9..60583a77c0 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -571,13 +571,17 @@ bool _Thread_Initialize(
* @param entry_point
* @param pointer_argument
* @param numeric_argument
+ * @param[in/out] processor The processor if used to start an idle thread
+ * during system initialization. Must be set to @c NULL to start a normal
+ * thread.
*/
bool _Thread_Start(
Thread_Control *the_thread,
Thread_Start_types the_prototype,
void *entry_point,
void *pointer_argument,
- Thread_Entry_numeric_type numeric_argument
+ Thread_Entry_numeric_type numeric_argument,
+ Per_CPU_Control *processor
);
/**
diff --git a/cpukit/score/inline/rtems/score/scheduler.inl b/cpukit/score/inline/rtems/score/scheduler.inl
index e3ced3900f..3201c23e99 100644
--- a/cpukit/score/inline/rtems/score/scheduler.inl
+++ b/cpukit/score/inline/rtems/score/scheduler.inl
@@ -208,6 +208,22 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Tick( void )
_Scheduler.Operations.tick();
}
+/**
+ * @brief Starts the idle thread for a particular processor.
+ *
+ * @param[in/out] thread The idle thread for the processor.
+ * @parma[in/out] processor The processor for the idle thread.
+ *
+ * @see _Thread_Create_idle().
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle(
+ Thread_Control *thread,
+ Per_CPU_Control *processor
+)
+{
+ ( *_Scheduler.Operations.start_idle )( thread, processor );
+}
+
/** @} */
#endif
diff --git a/cpukit/score/src/schedulerdefaultstartidle.c b/cpukit/score/src/schedulerdefaultstartidle.c
new file mode 100644
index 0000000000..043fe68b52
--- /dev/null
+++ b/cpukit/score/src/schedulerdefaultstartidle.c
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH
+ *
+ * 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.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/score/scheduler.h>
+
+void _Scheduler_default_Start_idle(
+ Thread_Control *thread,
+ Per_CPU_Control *processor
+)
+{
+ (void) processor;
+ _Scheduler_Unblock( thread );
+}
diff --git a/cpukit/score/src/threadcreateidle.c b/cpukit/score/src/threadcreateidle.c
index 7ad24cfdb3..d075510135 100644
--- a/cpukit/score/src/threadcreateidle.c
+++ b/cpukit/score/src/threadcreateidle.c
@@ -73,7 +73,8 @@ static void _Thread_Create_idle_for_cpu( Per_CPU_Control *per_cpu )
THREAD_START_NUMERIC,
rtems_configuration_get_idle_task(),
NULL,
- 0
+ 0,
+ per_cpu
);
}
diff --git a/cpukit/score/src/threadstart.c b/cpukit/score/src/threadstart.c
index d9ce62a091..4e24f39cfc 100644
--- a/cpukit/score/src/threadstart.c
+++ b/cpukit/score/src/threadstart.c
@@ -38,7 +38,8 @@ bool _Thread_Start(
Thread_Start_types the_prototype,
void *entry_point,
void *pointer_argument,
- Thread_Entry_numeric_type numeric_argument
+ Thread_Entry_numeric_type numeric_argument,
+ Per_CPU_Control *processor
)
{
if ( _States_Is_dormant( the_thread->current_state ) ) {
@@ -51,7 +52,12 @@ bool _Thread_Start(
_Thread_Load_environment( the_thread );
- _Thread_Ready( the_thread );
+ if ( processor == NULL ) {
+ _Thread_Ready( the_thread );
+ } else {
+ the_thread->current_state = STATES_READY;
+ _Scheduler_Start_idle( the_thread, processor );
+ }
_User_extensions_Thread_start( the_thread );