summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/schedulercbsallocate.c20
-rw-r--r--cpukit/score/src/schedulerdefaultallocatefree.c4
-rw-r--r--cpukit/score/src/scheduleredfallocate.c18
-rw-r--r--cpukit/score/src/scheduleredffree.c36
-rw-r--r--cpukit/score/src/schedulerpriorityaffinitysmp.c8
-rw-r--r--cpukit/score/src/schedulerpriorityallocate.c38
-rw-r--r--cpukit/score/src/schedulerpriorityfree.c35
-rw-r--r--cpukit/score/src/thread.c3
-rw-r--r--cpukit/score/src/threadinitialize.c65
-rw-r--r--cpukit/score/src/threadrestart.c2
10 files changed, 43 insertions, 186 deletions
diff --git a/cpukit/score/src/schedulercbsallocate.c b/cpukit/score/src/schedulercbsallocate.c
index 1190b84254..a6f89c35a9 100644
--- a/cpukit/score/src/schedulercbsallocate.c
+++ b/cpukit/score/src/schedulercbsallocate.c
@@ -25,24 +25,18 @@
#include <rtems/score/schedulercbs.h>
#include <rtems/score/wkspace.h>
-void *_Scheduler_CBS_Allocate(
+bool _Scheduler_CBS_Allocate(
const Scheduler_Control *scheduler,
- Thread_Control *the_thread
+ Thread_Control *the_thread
)
{
- void *sched;
- Scheduler_CBS_Per_thread *schinfo;
+ Scheduler_CBS_Per_thread *schinfo = the_thread->scheduler_info;
(void) scheduler;
- sched = _Workspace_Allocate(sizeof(Scheduler_CBS_Per_thread));
- if ( sched ) {
- the_thread->scheduler_info = sched;
- schinfo = (Scheduler_CBS_Per_thread *)(the_thread->scheduler_info);
- schinfo->edf_per_thread.thread = the_thread;
- schinfo->edf_per_thread.queue_state = SCHEDULER_EDF_QUEUE_STATE_NEVER_HAS_BEEN;
- schinfo->cbs_server = NULL;
- }
+ schinfo->edf_per_thread.thread = the_thread;
+ schinfo->edf_per_thread.queue_state = SCHEDULER_EDF_QUEUE_STATE_NEVER_HAS_BEEN;
+ schinfo->cbs_server = NULL;
- return sched;
+ return true;
}
diff --git a/cpukit/score/src/schedulerdefaultallocatefree.c b/cpukit/score/src/schedulerdefaultallocatefree.c
index 4efed5bad8..c865385dfb 100644
--- a/cpukit/score/src/schedulerdefaultallocatefree.c
+++ b/cpukit/score/src/schedulerdefaultallocatefree.c
@@ -21,7 +21,7 @@
#include <rtems/score/scheduler.h>
-void *_Scheduler_default_Allocate(
+bool _Scheduler_default_Allocate(
const Scheduler_Control *scheduler,
Thread_Control *the_thread
)
@@ -29,7 +29,7 @@ void *_Scheduler_default_Allocate(
( void ) scheduler;
( void ) the_thread;
- return ( void * )-1; /* maybe pick an appropriate poison value */
+ return true;
}
void _Scheduler_default_Free(
diff --git a/cpukit/score/src/scheduleredfallocate.c b/cpukit/score/src/scheduleredfallocate.c
index 68ae12450c..3dc9dd5070 100644
--- a/cpukit/score/src/scheduleredfallocate.c
+++ b/cpukit/score/src/scheduleredfallocate.c
@@ -24,24 +24,18 @@
#include <rtems/score/scheduleredf.h>
#include <rtems/score/wkspace.h>
-void *_Scheduler_EDF_Allocate(
+bool _Scheduler_EDF_Allocate(
const Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
- void *sched;
- Scheduler_EDF_Per_thread *schinfo;
+ Scheduler_EDF_Per_thread *schinfo = the_thread->scheduler_info;
(void) scheduler;
- sched = _Workspace_Allocate( sizeof(Scheduler_EDF_Per_thread) );
+ schinfo = (Scheduler_EDF_Per_thread *)(the_thread->scheduler_info);
+ schinfo->thread = the_thread;
+ schinfo->queue_state = SCHEDULER_EDF_QUEUE_STATE_NEVER_HAS_BEEN;
- if ( sched ) {
- the_thread->scheduler_info = sched;
- schinfo = (Scheduler_EDF_Per_thread *)(the_thread->scheduler_info);
- schinfo->thread = the_thread;
- schinfo->queue_state = SCHEDULER_EDF_QUEUE_STATE_NEVER_HAS_BEEN;
- }
-
- return sched;
+ return true;
}
diff --git a/cpukit/score/src/scheduleredffree.c b/cpukit/score/src/scheduleredffree.c
deleted file mode 100644
index 3529ac9c41..0000000000
--- a/cpukit/score/src/scheduleredffree.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * @file
- *
- * @brief Frees EDF Thread Information
- *
- * @ingroup ScoreScheduler
- */
-
-/*
- * 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.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/system.h>
-#include <rtems/config.h>
-#include <rtems/score/scheduler.h>
-#include <rtems/score/scheduleredf.h>
-#include <rtems/score/wkspace.h>
-
-void _Scheduler_EDF_Free(
- const Scheduler_Control *scheduler,
- Thread_Control *the_thread
-)
-{
- (void) scheduler;
-
- _Workspace_Free( the_thread->scheduler_info );
-}
diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c
index 2ab12b4824..0ea4336321 100644
--- a/cpukit/score/src/schedulerpriorityaffinitysmp.c
+++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c
@@ -31,20 +31,18 @@ _Scheduler_priority_affinity_Get_scheduler_info( Thread_Control *thread )
return ( Scheduler_priority_affinity_SMP_Per_thread * ) thread->scheduler_info;
}
-void * _Scheduler_priority_affinity_SMP_Allocate(
+bool _Scheduler_priority_affinity_SMP_Allocate(
const Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
Scheduler_priority_affinity_SMP_Per_thread *info =
- _Workspace_Allocate( sizeof( *info ) );
+ the_thread->scheduler_info;
info->Affinity = *_CPU_set_Default();
info->Affinity.set = &info->Affinity.preallocated;
-
- the_thread->scheduler_info = info;
- return info;
+ return true;
}
bool _Scheduler_priority_affinity_SMP_Get_affinity(
diff --git a/cpukit/score/src/schedulerpriorityallocate.c b/cpukit/score/src/schedulerpriorityallocate.c
deleted file mode 100644
index 32feabb97b..0000000000
--- a/cpukit/score/src/schedulerpriorityallocate.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * @file
- *
- * @brief Allocate Scheduler Priority
- * @ingroup ScoreScheduler
- */
-
-/*
- * Copyright (C) 2010 Gedare Bloom.
- * 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.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/score/schedulerpriority.h>
-#include <rtems/score/thread.h>
-#include <rtems/score/wkspace.h>
-
-void *_Scheduler_priority_Allocate (
- const Scheduler_Control *scheduler,
- Thread_Control *the_thread
-)
-{
- Scheduler_priority_Per_thread *sched_info_of_thread =
- _Workspace_Allocate( sizeof( *sched_info_of_thread ) );
-
- (void) scheduler;
-
- the_thread->scheduler_info = sched_info_of_thread;
-
- return sched_info_of_thread;
-}
diff --git a/cpukit/score/src/schedulerpriorityfree.c b/cpukit/score/src/schedulerpriorityfree.c
deleted file mode 100644
index b2daa26493..0000000000
--- a/cpukit/score/src/schedulerpriorityfree.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * @file
- *
- * @brief Free Scheduler Priority
- * @ingroup ScoreScheduler
- */
-
-/*
- * Copyright (C) 2010 Gedare Bloom.
- * 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.org/license/LICENSE.
- */
-
-#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>
-#include <rtems/score/wkspace.h>
-
-void _Scheduler_priority_Free (
- const Scheduler_Control *scheduler,
- Thread_Control *the_thread
-)
-{
- (void) scheduler;
-
- _Workspace_Free( the_thread->scheduler_info );
-}
diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c
index a77fe5fa8c..226e63af1a 100644
--- a/cpukit/score/src/thread.c
+++ b/cpukit/score/src/thread.c
@@ -64,8 +64,7 @@ void _Thread_Handler_initialization(void)
OBJECTS_INTERNAL_API,
OBJECTS_INTERNAL_THREADS,
_Thread_Get_maximum_internal_threads(),
- sizeof( Thread_Control ),
- /* size of this object's control block */
+ _Thread_Control_size, /* size of this object's control block */
false, /* true if names for this object are strings */
8 /* maximum length of each object's name */
#if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 6864df58e9..153c1d0b13 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -42,15 +42,15 @@ bool _Thread_Initialize(
Objects_Name name
)
{
- size_t actual_stack_size = 0;
- void *stack = NULL;
+ size_t actual_stack_size = 0;
+ void *stack = NULL;
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
- void *fp_area;
+ void *fp_area = NULL;
#endif
- void *sched = NULL;
- void *extensions_area;
- bool extension_status;
- int i;
+ bool extension_status;
+ size_t i;
+ bool scheduler_allocated = false;
+ const Scheduler_Control *scheduler;
/*
* Do not use _TLS_Size here since this will lead GCC to assume that this
@@ -64,6 +64,13 @@ bool _Thread_Initialize(
}
#endif
+ for ( i = 0 ; i < _Thread_Control_add_on_count ; ++i ) {
+ const Thread_Control_add_on *add_on = &_Thread_Control_add_ons[ i ];
+
+ *(void **) ( (char *) the_thread + add_on->destination_offset ) =
+ (char *) the_thread + add_on->source_offset;
+ }
+
/*
* Initialize the Ada self pointer
*/
@@ -71,20 +78,8 @@ bool _Thread_Initialize(
the_thread->rtems_ada_self = NULL;
#endif
- /*
- * Zero out all the allocated memory fields
- */
- for ( i=0 ; i <= THREAD_API_LAST ; i++ )
- the_thread->API_Extensions[i] = NULL;
-
- extensions_area = NULL;
- the_thread->libc_reent = NULL;
the_thread->Start.tls_area = NULL;
- #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
- fp_area = NULL;
- #endif
-
/*
* Allocate and Initialize the stack for this thread.
*/
@@ -153,18 +148,6 @@ bool _Thread_Initialize(
#endif
/*
- * Allocate the extensions area for this thread
- */
- if ( rtems_configuration_get_maximum_extensions() ) {
- extensions_area = _Workspace_Allocate(
- (rtems_configuration_get_maximum_extensions() + 1) * sizeof( void * )
- );
- if ( !extensions_area )
- goto failed;
- }
- the_thread->extensions = (void **) extensions_area;
-
- /*
* Clear the extensions area so extension users can determine
* if they are linked to the thread. An extension user may
* create the extension long after tasks have been created
@@ -215,9 +198,13 @@ bool _Thread_Initialize(
the_thread->resource_count = 0;
the_thread->real_priority = priority;
the_thread->Start.initial_priority = priority;
- sched =_Scheduler_Allocate( _Scheduler_Get( the_thread ), the_thread );
- if ( !sched )
+
+ scheduler = _Scheduler_Get( _Thread_Get_executing() );
+ scheduler_allocated = _Scheduler_Allocate( scheduler, the_thread );
+ if ( !scheduler_allocated ) {
goto failed;
+ }
+
_Thread_Set_priority( the_thread, priority );
/*
@@ -260,21 +247,17 @@ bool _Thread_Initialize(
return true;
failed:
- _Workspace_Free( the_thread->Start.tls_area );
-
- _Workspace_Free( the_thread->libc_reent );
- for ( i=0 ; i <= THREAD_API_LAST ; i++ )
- _Workspace_Free( the_thread->API_Extensions[i] );
+ if ( scheduler_allocated ) {
+ _Scheduler_Free( scheduler, the_thread );
+ }
- _Workspace_Free( extensions_area );
+ _Workspace_Free( the_thread->Start.tls_area );
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
_Workspace_Free( fp_area );
#endif
- _Workspace_Free( sched );
-
_Thread_Stack_Free( the_thread );
return false;
}
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 47c27929dd..422ee33a6d 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -91,8 +91,6 @@ static void _Thread_Free( Thread_Control *the_thread )
*/
_Thread_Stack_Free( the_thread );
- _Workspace_Free( the_thread->extensions );
-
_Workspace_Free( the_thread->Start.tls_area );
_Objects_Free(