summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/include/rtems/score/mppkt.h2
-rw-r--r--cpukit/score/include/rtems/score/object.h26
-rw-r--r--cpukit/score/include/rtems/score/objectmp.h21
-rw-r--r--cpukit/score/include/rtems/score/priority.h14
-rw-r--r--cpukit/score/include/rtems/score/thread.h123
-rw-r--r--cpukit/score/include/rtems/score/threadq.h37
-rw-r--r--cpukit/score/include/rtems/score/tqdata.h8
-rw-r--r--cpukit/score/include/rtems/score/userext.h4
-rw-r--r--cpukit/score/inline/rtems/score/object.inl13
-rw-r--r--cpukit/score/inline/rtems/score/priority.inl12
-rw-r--r--cpukit/score/inline/rtems/score/tqdata.inl4
-rw-r--r--cpukit/score/inline/rtems/score/userext.inl4
-rw-r--r--cpukit/score/macros/rtems/score/object.inl9
-rw-r--r--cpukit/score/macros/rtems/score/thread.inl2
-rw-r--r--cpukit/score/src/mpci.c6
-rw-r--r--cpukit/score/src/object.c22
-rw-r--r--cpukit/score/src/objectmp.c33
-rw-r--r--cpukit/score/src/thread.c316
-rw-r--r--cpukit/score/src/threadq.c120
19 files changed, 653 insertions, 123 deletions
diff --git a/cpukit/score/include/rtems/score/mppkt.h b/cpukit/score/include/rtems/score/mppkt.h
index 4e72d6930a..d63d587fca 100644
--- a/cpukit/score/include/rtems/score/mppkt.h
+++ b/cpukit/score/include/rtems/score/mppkt.h
@@ -64,7 +64,7 @@ typedef struct {
rtems_mp_packet_classes the_class;
Objects_Id id;
Objects_Id source_tid;
- rtems_task_priority source_priority;
+ Priority_Control source_priority;
rtems_status_code return_code;
unsigned32 length;
unsigned32 to_convert;
diff --git a/cpukit/score/include/rtems/score/object.h b/cpukit/score/include/rtems/score/object.h
index 5c84868dc1..b1d422d3d4 100644
--- a/cpukit/score/include/rtems/score/object.h
+++ b/cpukit/score/include/rtems/score/object.h
@@ -349,6 +349,19 @@ Objects_Control *_Objects_Get_next(
);
/*
+ * _Objects_Get_information
+ *
+ * DESCRIPTION:
+ *
+ * Returns the information control block for the class of objects
+ * corresponding to this id.
+ */
+
+Objects_Information *_Objects_Get_information(
+ Objects_Id id
+);
+
+/*
* _Objects_Build_id
*
* DESCRIPTION:
@@ -404,6 +417,19 @@ STATIC INLINE unsigned32 rtems_get_index(
);
/*
+ * _Objects_Is_class_valid
+ *
+ * DESCRIPTION:
+ *
+ * This function returns TRUE if the class is valid.
+ *
+ */
+
+STATIC INLINE boolean _Objects_Is_class_valid(
+ Objects_Classes the_class
+);
+
+/*
* _Objects_Is_local_node
*
* DESCRIPTION:
diff --git a/cpukit/score/include/rtems/score/objectmp.h b/cpukit/score/include/rtems/score/objectmp.h
index 6ec5ed1781..b15d5cbb43 100644
--- a/cpukit/score/include/rtems/score/objectmp.h
+++ b/cpukit/score/include/rtems/score/objectmp.h
@@ -81,18 +81,35 @@ STATIC INLINE boolean _Objects_MP_Is_null_global_object (
Objects_MP_Control *the_object
);
-/*
+/*PAGE
+ *
* _Objects_MP_Open
*
* DESCRIPTION:
*
+ * This routine place the specified global object in the
+ * specified information table.
+ */
+
+void _Objects_MP_Open (
+ Objects_Information *information,
+ Objects_MP_Control *the_global_object,
+ unsigned32 the_name, /* XXX -- wrong for variable */
+ Objects_Id the_id
+);
+
+/*
+ * _Objects_MP_Allocate_and_open
+ *
+ * DESCRIPTION:
+ *
* This routine allocates a global object control block
* and places it in the specified information table. If the
* allocation fails, then is_fatal_error determines the
* error processing actions taken.
*/
-boolean _Objects_MP_Open (
+boolean _Objects_MP_Allocate_and_open (
Objects_Information *information,
unsigned32 the_name, /* XXX -- wrong for variable length */
Objects_Id the_id,
diff --git a/cpukit/score/include/rtems/score/priority.h b/cpukit/score/include/rtems/score/priority.h
index 823611b080..44397e7a8a 100644
--- a/cpukit/score/include/rtems/score/priority.h
+++ b/cpukit/score/include/rtems/score/priority.h
@@ -29,7 +29,7 @@ extern "C" {
* NOTE: Priority 0 is reserved for internal threads only.
*/
-typedef unsigned32 rtems_task_priority;
+typedef unsigned32 Priority_Control;
#define RTEMS_MINIMUM_PRIORITY 1 /* highest thread priority */
#define RTEMS_MAXIMUM_PRIORITY 255 /* lowest thread priority */
@@ -92,7 +92,7 @@ STATIC INLINE void _Priority_Handler_initialization( void );
*/
STATIC INLINE boolean _Priority_Is_valid (
- rtems_task_priority the_priority
+ Priority_Control the_priority
);
/*
@@ -104,7 +104,7 @@ STATIC INLINE boolean _Priority_Is_valid (
*/
STATIC INLINE unsigned32 _Priority_Major (
- rtems_task_priority the_priority
+ Priority_Control the_priority
);
/*
@@ -116,7 +116,7 @@ STATIC INLINE unsigned32 _Priority_Major (
*/
STATIC INLINE unsigned32 _Priority_Minor (
- rtems_task_priority the_priority
+ Priority_Control the_priority
);
/*
@@ -155,7 +155,7 @@ STATIC INLINE void _Priority_Remove_from_bit_map (
* ready thread.
*/
-STATIC INLINE rtems_task_priority _Priority_Get_highest( void );
+STATIC INLINE Priority_Control _Priority_Get_highest( void );
/*
* _Priority_Initialize_information
@@ -169,7 +169,7 @@ STATIC INLINE rtems_task_priority _Priority_Get_highest( void );
STATIC INLINE void _Priority_Initialize_information(
Priority_Information *the_priority_map,
- rtems_task_priority new_priority
+ Priority_Control new_priority
);
/*
@@ -182,7 +182,7 @@ STATIC INLINE void _Priority_Initialize_information(
*/
STATIC INLINE boolean _Priority_Is_group_empty (
- rtems_task_priority the_priority
+ Priority_Control the_priority
);
#include <rtems/priority.inl>
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 9c5d0b040b..37a5898d01 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -86,22 +86,30 @@ typedef rtems_task ( *rtems_task_entry )(
rtems_task_argument
);
-typedef Thread ( *Thread_Entry )(
- Thread_Argument
- );
+typedef Thread ( *Thread_Entry )( );
/*
* The following structure contains the information which defines
* the starting state of a thread.
*/
+typedef enum {
+ THREAD_START_NUMERIC,
+ THREAD_START_POINTER,
+ THREAD_START_BOTH_POINTER_FIRST,
+ THREAD_START_BOTH_NUMERIC_FIRST
+} Thread_Start_types;
+
typedef struct {
Thread_Entry entry_point; /* starting thread address */
- unsigned32 initial_argument; /* initial argument */
- rtems_mode initial_modes; /* initial mode */
- rtems_task_priority initial_priority; /* initial priority */
- void *fp_context; /* initial FP context area address */
+ Thread_Start_types prototype; /* how task is invoked */
+ void *pointer_argument; /* pointer argument */
+ unsigned32 numeric_argument; /* numeric argument */
+ Modes_Control initial_modes; /* initial mode */
+ Priority_Control initial_priority; /* initial priority */
Stack_Control Initial_stack; /* stack information */
+ void *fp_context; /* initial FP context area address */
+ void *stack; /* initial FP context area address */
} Thread_Start_information;
/*
@@ -134,8 +142,8 @@ typedef struct {
typedef struct {
Objects_Control Object;
States_Control current_state;
- rtems_task_priority current_priority;
- rtems_task_priority real_priority;
+ Priority_Control current_priority;
+ Priority_Control real_priority;
unsigned32 resource_count;
Thread_Wait_information Wait;
Watchdog_Control Timer;
@@ -153,11 +161,21 @@ typedef struct {
* memory images for the shared part.
*/
+/* XXX structure in wrong file .. API .. not core */
+
+typedef struct {
+ boolean is_global;
+ unsigned32 Notepads[ RTEMS_NUMBER_NOTEPADS ];
+ rtems_event_set pending_events;
+ rtems_event_set events_out;
+ ASR_Information Signal;
+} RTEMS_API_Control;
+
typedef struct {
Objects_Control Object;
States_Control current_state;
- rtems_task_priority current_priority;
- rtems_task_priority real_priority;
+ Priority_Control current_priority;
+ Priority_Control real_priority;
unsigned32 resource_count;
Thread_Wait_information Wait;
Watchdog_Control Timer;
@@ -165,15 +183,11 @@ typedef struct {
/****************** end of common block ********************/
Chain_Control *ready;
Priority_Information Priority_map;
- rtems_event_set pending_events;
- rtems_event_set events_out;
Thread_Start_information Start;
- ASR_Information Signal;
- rtems_mode current_modes;
- rtems_attribute attribute_set;
+ Modes_Control current_modes;
Context_Control Registers;
void *fp_context;
- unsigned32 Notepads[ RTEMS_NUMBER_NOTEPADS ];
+ RTEMS_API_Control *RTEMS_API;
void *extension;
} Thread_Control;
@@ -305,6 +319,71 @@ STATIC INLINE void _Thread_Dispatch_initialization( void );
void _Thread_Dispatch( void );
/*
+ * _Thread_Initialize
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+boolean _Thread_Initialize(
+ Objects_Information *information,
+ Thread_Control *the_thread,
+ void *stack_area, /* NULL if to be allocated */
+ unsigned32 stack_size, /* insure it is >= min */
+ boolean is_fp, /* TRUE if thread uses FP */
+ Priority_Control priority,
+ Modes_Control mode,
+ Objects_Name name
+
+);
+
+/*
+ * _Thread_Start
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+boolean _Thread_Start(
+ Thread_Control *the_thread,
+ Thread_Start_types the_prototype,
+ void *entry_point,
+ void *pointer_argument,
+ unsigned32 numeric_argument
+);
+
+/*
+ * _Thread_Restart
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+/* XXX multiple task arg profiles */
+
+boolean _Thread_Restart(
+ Thread_Control *the_thread,
+ void *pointer_argument,
+ unsigned32 numeric_argument
+);
+
+/*
+ * _Thread_Close
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+void _Thread_Close(
+ Objects_Information *information,
+ Thread_Control *the_thread
+);
+
+/*
* _Thread_Ready
*
* DESCRIPTION:
@@ -493,7 +572,7 @@ void _Thread_Delay_ended(
void _Thread_Change_priority (
Thread_Control *the_thread,
- rtems_task_priority new_priority
+ Priority_Control new_priority
);
/*
@@ -507,7 +586,7 @@ void _Thread_Change_priority (
void _Thread_Set_priority(
Thread_Control *the_thread,
- rtems_task_priority new_priority
+ Priority_Control new_priority
);
/*
@@ -524,9 +603,9 @@ void _Thread_Set_priority(
*/
boolean _Thread_Change_mode(
- rtems_mode new_mode_set,
- rtems_mode mask,
- rtems_mode *old_mode_set
+ Modes_Control new_mode_set,
+ Modes_Control mask,
+ Modes_Control *old_mode_set
);
/*
diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h
index 291044ead1..27a36ab63e 100644
--- a/cpukit/score/include/rtems/score/threadq.h
+++ b/cpukit/score/include/rtems/score/threadq.h
@@ -37,6 +37,19 @@ typedef void ( *Thread_queue_Flush_callout )(
);
/*
+ * The following type defines the callout used when a local task
+ * is extracted from a remote thread queue (i.e. it's proxy must
+ * extracted from the remote queue).
+ */
+
+typedef void ( *Thread_queue_Extract_callout )(
+ Thread_Control *
+ );
+
+EXTERN Thread_queue_Extract_callout
+ _Thread_queue_Extract_table[ OBJECTS_CLASSES_LAST + 1 ];
+
+/*
* _Thread_queue_Dequeue
*
* DESCRIPTION:
@@ -62,7 +75,7 @@ Thread_Control *_Thread_queue_Dequeue(
void _Thread_queue_Enqueue(
Thread_queue_Control *the_thread_queue,
- rtems_interval timeout
+ rtems_interval timeout
);
/*
@@ -80,6 +93,20 @@ void _Thread_queue_Extract(
);
/*
+ * _Thread_queue_Extract_with_proxy
+ *
+ * DESCRIPTION:
+ *
+ * This routine extracts the_thread from the_thread_queue
+ * and insures that if there is a proxy for this task on
+ * another node, it is also dealt with.
+ */
+
+boolean _Thread_queue_Extract_with_proxy(
+ Thread_Control *the_thread
+);
+
+/*
* _Thread_queue_First
*
* DESCRIPTION:
@@ -118,9 +145,11 @@ void _Thread_queue_Flush(
*/
void _Thread_queue_Initialize(
- Thread_queue_Control *the_thread_queue,
- rtems_attribute attribute_set,
- States_Control state
+ Thread_queue_Control *the_thread_queue,
+ Objects_Classes the_class,
+ Thread_queue_Disciplines the_discipline,
+ States_Control state,
+ Thread_queue_Extract_callout proxy_extract_callout
);
/*
diff --git a/cpukit/score/include/rtems/score/tqdata.h b/cpukit/score/include/rtems/score/tqdata.h
index 37dd6853d7..f962f409d2 100644
--- a/cpukit/score/include/rtems/score/tqdata.h
+++ b/cpukit/score/include/rtems/score/tqdata.h
@@ -31,8 +31,8 @@ extern "C" {
*/
typedef enum {
- THREAD_QUEUE_DATA_FIFO_DISCIPLINE, /* RTEMS_FIFO queue discipline */
- THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE /* RTEMS_PRIORITY queue discipline */
+ THREAD_QUEUE_DISCIPLINE_FIFO, /* RTEMS_FIFO queue discipline */
+ THREAD_QUEUE_DISCIPLINE_PRIORITY /* RTEMS_PRIORITY queue discipline */
} Thread_queue_Disciplines;
/*
@@ -63,7 +63,7 @@ typedef struct {
*/
STATIC INLINE unsigned32 _Thread_queue_Header_number (
- rtems_task_priority the_priority
+ Priority_Control the_priority
);
/*
@@ -77,7 +77,7 @@ STATIC INLINE unsigned32 _Thread_queue_Header_number (
*/
STATIC INLINE boolean _Thread_queue_Is_reverse_search (
- rtems_task_priority the_priority
+ Priority_Control the_priority
);
#include <rtems/tqdata.inl>
diff --git a/cpukit/score/include/rtems/score/userext.h b/cpukit/score/include/rtems/score/userext.h
index 37131959d9..56fae9b7db 100644
--- a/cpukit/score/include/rtems/score/userext.h
+++ b/cpukit/score/include/rtems/score/userext.h
@@ -69,8 +69,8 @@ STATIC INLINE void _User_extensions_Handler_initialization (
*/
STATIC INLINE void _User_extensions_Add_set (
- User_extensions_Control *the_extension,
- rtems_extensions_table *extension_table
+ User_extensions_Control *the_extension,
+ rtems_extensions_table *extension_table
);
/*
diff --git a/cpukit/score/inline/rtems/score/object.inl b/cpukit/score/inline/rtems/score/object.inl
index 687ffd923b..b6ae73a351 100644
--- a/cpukit/score/inline/rtems/score/object.inl
+++ b/cpukit/score/inline/rtems/score/object.inl
@@ -76,6 +76,19 @@ STATIC INLINE unsigned32 rtems_get_index(
/*PAGE
*
+ * _Objects_Is_class_valid
+ *
+ */
+
+STATIC INLINE boolean _Objects_Is_class_valid(
+ Objects_Classes the_class
+)
+{
+ return the_class <= OBJECTS_CLASSES_LAST;
+}
+
+/*PAGE
+ *
* _Objects_Is_local_node
*
*/
diff --git a/cpukit/score/inline/rtems/score/priority.inl b/cpukit/score/inline/rtems/score/priority.inl
index 9e7c159f65..b2bc8535ff 100644
--- a/cpukit/score/inline/rtems/score/priority.inl
+++ b/cpukit/score/inline/rtems/score/priority.inl
@@ -41,7 +41,7 @@ STATIC INLINE void _Priority_Handler_initialization( void )
*/
STATIC INLINE boolean _Priority_Is_valid (
- rtems_task_priority the_priority
+ Priority_Control the_priority
)
{
return ( ( the_priority >= RTEMS_MINIMUM_PRIORITY ) &&
@@ -55,7 +55,7 @@ STATIC INLINE boolean _Priority_Is_valid (
*/
STATIC INLINE unsigned32 _Priority_Major (
- rtems_task_priority the_priority
+ Priority_Control the_priority
)
{
return ( the_priority / 16 );
@@ -68,7 +68,7 @@ STATIC INLINE unsigned32 _Priority_Major (
*/
STATIC INLINE unsigned32 _Priority_Minor (
- rtems_task_priority the_priority
+ Priority_Control the_priority
)
{
return ( the_priority % 16 );
@@ -109,7 +109,7 @@ STATIC INLINE void _Priority_Remove_from_bit_map (
*
*/
-STATIC INLINE rtems_task_priority _Priority_Get_highest( void )
+STATIC INLINE Priority_Control _Priority_Get_highest( void )
{
Priority_Bit_map_control minor;
Priority_Bit_map_control major;
@@ -129,7 +129,7 @@ STATIC INLINE rtems_task_priority _Priority_Get_highest( void )
STATIC INLINE void _Priority_Initialize_information(
Priority_Information *the_priority_map,
- rtems_task_priority new_priority
+ Priority_Control new_priority
)
{
Priority_Bit_map_control major;
@@ -158,7 +158,7 @@ STATIC INLINE void _Priority_Initialize_information(
*/
STATIC INLINE boolean _Priority_Is_group_empty (
- rtems_task_priority the_priority
+ Priority_Control the_priority
)
{
return the_priority == 0;
diff --git a/cpukit/score/inline/rtems/score/tqdata.inl b/cpukit/score/inline/rtems/score/tqdata.inl
index 7ec1e9e186..3168d058f5 100644
--- a/cpukit/score/inline/rtems/score/tqdata.inl
+++ b/cpukit/score/inline/rtems/score/tqdata.inl
@@ -24,7 +24,7 @@
*/
STATIC INLINE unsigned32 _Thread_queue_Header_number (
- rtems_task_priority the_priority
+ Priority_Control the_priority
)
{
return ( the_priority >> 6 );
@@ -37,7 +37,7 @@ STATIC INLINE unsigned32 _Thread_queue_Header_number (
*/
STATIC INLINE boolean _Thread_queue_Is_reverse_search (
- rtems_task_priority the_priority
+ Priority_Control the_priority
)
{
return ( the_priority & 0x20 );
diff --git a/cpukit/score/inline/rtems/score/userext.inl b/cpukit/score/inline/rtems/score/userext.inl
index 1558da968a..fa5a31c37b 100644
--- a/cpukit/score/inline/rtems/score/userext.inl
+++ b/cpukit/score/inline/rtems/score/userext.inl
@@ -41,8 +41,8 @@ STATIC INLINE void _User_extensions_Handler_initialization (
*/
STATIC INLINE void _User_extensions_Add_set (
- User_extensions_Control *the_extension,
- rtems_extensions_table *extension_table
+ User_extensions_Control *the_extension,
+ rtems_extensions_table *extension_table
)
{
the_extension->Callouts = *extension_table;
diff --git a/cpukit/score/macros/rtems/score/object.inl b/cpukit/score/macros/rtems/score/object.inl
index 27675b19bf..7a346af720 100644
--- a/cpukit/score/macros/rtems/score/object.inl
+++ b/cpukit/score/macros/rtems/score/object.inl
@@ -57,6 +57,15 @@
/*PAGE
*
+ * _Objects_Is_class_valid
+ *
+ */
+
+#define _Objects_Is_class_valid( _the_class ) \
+ ( (_the_class) <= OBJECTS_CLASSES_LAST )
+
+/*PAGE
+ *
* _Objects_Is_local_node
*
*/
diff --git a/cpukit/score/macros/rtems/score/thread.inl b/cpukit/score/macros/rtems/score/thread.inl
index 0e041de5ac..d7d37cb218 100644
--- a/cpukit/score/macros/rtems/score/thread.inl
+++ b/cpukit/score/macros/rtems/score/thread.inl
@@ -93,7 +93,7 @@
#define _Thread_Calculate_heir() \
{ \
- rtems_task_priority highest; \
+ Priority_Control highest; \
\
_Priority_Get_highest( highest ); \
\
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index e8d3803d76..26c27ae733 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -36,8 +36,10 @@ void _MPCI_Handler_initialization ( void )
{
_Thread_queue_Initialize(
&_MPCI_Remote_blocked_threads,
- RTEMS_FIFO,
- STATES_WAITING_FOR_RPC_REPLY
+ OBJECTS_NO_CLASS,
+ THREAD_QUEUE_DISCIPLINE_FIFO,
+ STATES_WAITING_FOR_RPC_REPLY,
+ NULL
);
}
diff --git a/cpukit/score/src/object.c b/cpukit/score/src/object.c
index b829258a48..b274579736 100644
--- a/cpukit/score/src/object.c
+++ b/cpukit/score/src/object.c
@@ -476,3 +476,25 @@ final:
*next_id_p = RTEMS_OBJECT_ID_FINAL;
return 0;
}
+
+/*PAGE
+ *
+ * _Objects_Get_information
+ *
+ * XXX
+ */
+
+Objects_Information *_Objects_Get_information(
+ Objects_Id id
+)
+{
+ Objects_Classes the_class;
+
+ the_class = rtems_get_class( id );
+
+ if ( !_Objects_Is_class_valid( the_class ) )
+ return NULL;
+
+ return _Objects_Information_table[ the_class ];
+}
+
diff --git a/cpukit/score/src/objectmp.c b/cpukit/score/src/objectmp.c
index a8b067020d..9752aadbc6 100644
--- a/cpukit/score/src/objectmp.c
+++ b/cpukit/score/src/objectmp.c
@@ -50,8 +50,31 @@ void _Objects_MP_Handler_initialization (
* _Objects_MP_Open
*
*/
+
+void _Objects_MP_Open (
+ Objects_Information *information,
+ Objects_MP_Control *the_global_object,
+ unsigned32 the_name, /* XXX -- wrong for variable */
+ Objects_Id the_id
+)
+{
+ the_global_object->Object.id = the_id;
+ the_global_object->name = the_name;
+
+ _Chain_Prepend(
+ &information->global_table[ rtems_get_node( the_id ) ],
+ &the_global_object->Object.Node
+ );
+
+}
-boolean _Objects_MP_Open (
+/*PAGE
+ *
+ * _Objects_MP_Allocate_and_open
+ *
+ */
+
+boolean _Objects_MP_Allocate_and_open (
Objects_Information *information,
unsigned32 the_name, /* XXX -- wrong for variable */
Objects_Id the_id,
@@ -70,13 +93,7 @@ boolean _Objects_MP_Open (
}
- the_global_object->Object.id = the_id;
- the_global_object->name = the_name;
-
- _Chain_Prepend(
- &information->global_table[ rtems_get_node( the_id ) ],
- &the_global_object->Object.Node
- );
+ _Objects_MP_Open( information, the_global_object, the_name, the_id );
return TRUE;
}
diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c
index c4dde3e6f8..dfc5324cb8 100644
--- a/cpukit/score/src/thread.c
+++ b/cpukit/score/src/thread.c
@@ -142,11 +142,11 @@ void _Thread_Enable_dispatch( void )
void _Thread_Dispatch( void )
{
- Thread_Control *executing;
- Thread_Control *heir;
- ISR_Level level;
+ Thread_Control *executing;
+ Thread_Control *heir;
+ ISR_Level level;
rtems_signal_set signal_set;
- rtems_mode previous_mode;
+ Modes_Control previous_mode;
executing = _Thread_Executing;
_ISR_Disable( level );
@@ -199,19 +199,19 @@ void _Thread_Dispatch( void )
_Thread_Dispatch_disable_level = 0;
- if ( _ASR_Are_signals_pending( &executing->Signal ) ) {
- signal_set = executing->Signal.signals_posted;
- executing->Signal.signals_posted = 0;
+ if ( _ASR_Are_signals_pending( &executing->RTEMS_API->Signal ) ) {
+ signal_set = executing->RTEMS_API->Signal.signals_posted;
+ executing->RTEMS_API->Signal.signals_posted = 0;
_ISR_Enable( level );
- executing->Signal.nest_level += 1;
- if (_Thread_Change_mode( executing->Signal.mode_set,
+ executing->RTEMS_API->Signal.nest_level += 1;
+ if (_Thread_Change_mode( executing->RTEMS_API->Signal.mode_set,
RTEMS_ALL_MODE_MASKS, &previous_mode ))
_Thread_Dispatch();
- (*executing->Signal.handler)( signal_set );
+ (*executing->RTEMS_API->Signal.handler)( signal_set );
- executing->Signal.nest_level -= 1;
+ executing->RTEMS_API->Signal.nest_level -= 1;
if (_Thread_Change_mode( previous_mode,
RTEMS_ALL_MODE_MASKS, &previous_mode ))
_Thread_Dispatch();
@@ -222,6 +222,257 @@ void _Thread_Dispatch( void )
/*PAGE
*
+ * _Thread_Initialize
+ *
+ * XXX
+ */
+
+boolean _Thread_Initialize(
+ Objects_Information *information,
+ Thread_Control *the_thread,
+ void *stack_area, /* NULL if to be allocated */
+ unsigned32 stack_size, /* insure it is >= min */
+ boolean is_fp, /* TRUE if thread uses FP */
+ Priority_Control priority,
+ Modes_Control mode,
+ Objects_Name name
+
+)
+{
+ unsigned32 actual_stack_size;
+ void *stack;
+ void *fp_area;
+
+ /*
+ * Allocate and Initialize the stack for this thread.
+ */
+
+ if ( !_Stack_Is_enough( stack_size ) )
+ actual_stack_size = RTEMS_MINIMUM_STACK_SIZE;
+ else
+ actual_stack_size = stack_size;
+
+ actual_stack_size = _Stack_Adjust_size( actual_stack_size );
+ stack = stack_area;
+
+ if ( !stack ) {
+ stack = _Workspace_Allocate( actual_stack_size );
+
+ if ( !stack )
+ return FALSE;
+
+ the_thread->Start.stack = stack;
+ } else
+ the_thread->Start.stack = NULL;
+
+ _Stack_Initialize(
+ &the_thread->Start.Initial_stack,
+ stack,
+ actual_stack_size
+ );
+
+ /*
+ * Allocate the floating point area for this thread
+ */
+
+ if ( is_fp ) {
+
+ fp_area = _Workspace_Allocate( CONTEXT_FP_SIZE );
+ if ( !fp_area ) {
+ (void) _Workspace_Free( stack );
+ return FALSE;
+ }
+ fp_area = _Context_Fp_start( fp_area, 0 );
+
+ } else
+ fp_area = NULL;
+
+ the_thread->fp_context = fp_area;
+ the_thread->Start.fp_context = fp_area;
+
+/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
+ /*
+ * Allocate and initialize the RTEMS API specific information
+ */
+
+ the_thread->RTEMS_API = _Workspace_Allocate( sizeof( RTEMS_API_Control ) );
+
+ if ( !the_thread->RTEMS_API ) {
+/* XXX when in task_create
+ _RTEMS_tasks_Free( the_thread );
+ _Objects_MP_Free_global_object( the_global_object );
+
+ _Thread_Enable_dispatch();
+ return( RTEMS_UNSATISFIED );
+*/
+ (void) _Workspace_Free( stack );
+ (void) _Workspace_Free( fp_area );
+ return FALSE;
+
+ }
+
+ the_thread->RTEMS_API->is_global = FALSE;
+ the_thread->RTEMS_API->pending_events = EVENT_SETS_NONE_PENDING;
+ _ASR_Initialize( &the_thread->RTEMS_API->Signal );
+
+ /* XXX should not be here .... */
+
+/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
+
+ /*
+ * General initialization
+ */
+
+ the_thread->current_state = STATES_DORMANT;
+ the_thread->current_modes = mode;
+ the_thread->resource_count = 0;
+ the_thread->real_priority = priority;
+ the_thread->Start.initial_priority = priority;
+ the_thread->Start.initial_modes = mode;
+
+ _Thread_Set_priority( the_thread, priority );
+
+ /*
+ * Open the object
+ */
+
+ _Objects_Open( information, &the_thread->Object, name );
+
+ /*
+ * Invoke create extensions
+ */
+
+ _User_extensions_Task_create( the_thread );
+ /* XXX if this fails ... */
+
+ return TRUE;
+}
+
+/*
+ * _Thread_Start
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+boolean _Thread_Start(
+ Thread_Control *the_thread,
+ Thread_Start_types the_prototype,
+ void *entry_point,
+ void *pointer_argument,
+ unsigned32 numeric_argument
+)
+{
+ if ( _States_Is_dormant( the_thread->current_state ) ) {
+
+ the_thread->Start.entry_point = entry_point;
+
+ the_thread->Start.prototype = the_prototype;
+ the_thread->Start.pointer_argument = pointer_argument;
+ the_thread->Start.numeric_argument = numeric_argument;
+
+ _Thread_Load_environment( the_thread );
+
+ _Thread_Ready( the_thread );
+
+ _User_extensions_Task_start( the_thread );
+
+ return TRUE;
+ }
+
+ return FALSE;
+
+}
+
+/*
+ * _Thread_Restart
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+boolean _Thread_Restart(
+ Thread_Control *the_thread,
+ void *pointer_argument,
+ unsigned32 numeric_argument
+)
+{
+ if ( !_States_Is_dormant( the_thread->current_state ) ) {
+
+ _Thread_Set_transient( the_thread );
+ the_thread->resource_count = 0;
+ the_thread->current_modes = the_thread->Start.initial_modes;
+
+ the_thread->Start.pointer_argument = pointer_argument;
+ the_thread->Start.numeric_argument = numeric_argument;
+
+ if ( !_Thread_queue_Extract_with_proxy( the_thread ) ) {
+
+ if ( _Watchdog_Is_active( &the_thread->Timer ) )
+ (void) _Watchdog_Remove( &the_thread->Timer );
+ }
+
+ if ( the_thread->current_priority != the_thread->Start.initial_priority ) {
+ the_thread->real_priority = the_thread->Start.initial_priority;
+ _Thread_Set_priority( the_thread, the_thread->Start.initial_priority );
+ }
+
+ _Thread_Load_environment( the_thread );
+
+ _Thread_Ready( the_thread );
+
+ _User_extensions_Task_restart( the_thread );
+
+ if ( _Thread_Is_executing ( the_thread ) )
+ _Thread_Restart_self();
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ * _Thread_Close
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+void _Thread_Close(
+ Objects_Information *information,
+ Thread_Control *the_thread
+)
+{
+ _Objects_Close( information, &the_thread->Object );
+
+ _Thread_Set_state( the_thread, STATES_TRANSIENT );
+
+ if ( !_Thread_queue_Extract_with_proxy( the_thread ) ) {
+
+ if ( _Watchdog_Is_active( &the_thread->Timer ) )
+ (void) _Watchdog_Remove( &the_thread->Timer );
+ }
+
+ _User_extensions_Task_delete( the_thread );
+
+#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
+ if ( _Thread_Is_allocated_fp( the_thread ) )
+ _Thread_Deallocate_fp();
+#endif
+ the_thread->fp_context = NULL;
+
+ (void) _Workspace_Free( the_thread->Start.fp_context );
+
+ if ( the_thread->Start.stack )
+ (void) _Workspace_Free( the_thread->Start.stack );
+}
+
+/*PAGE
+ *
* _Thread_Ready
*
* This kernel routine readies the requested thread, the thread chain
@@ -595,7 +846,26 @@ void _Thread_Handler( void )
_Thread_Enable_dispatch();
- (*executing->Start.entry_point)( executing->Start.initial_argument );
+ switch ( executing->Start.prototype ) {
+ case THREAD_START_NUMERIC:
+ (*executing->Start.entry_point)( executing->Start.numeric_argument );
+ break;
+ case THREAD_START_POINTER:
+ (*executing->Start.entry_point)( executing->Start.pointer_argument );
+ break;
+ case THREAD_START_BOTH_POINTER_FIRST:
+ (*executing->Start.entry_point)(
+ executing->Start.pointer_argument,
+ executing->Start.numeric_argument
+ );
+ break;
+ case THREAD_START_BOTH_NUMERIC_FIRST:
+ (*executing->Start.entry_point)(
+ executing->Start.numeric_argument,
+ executing->Start.pointer_argument
+ );
+ break;
+ }
_User_extensions_Task_exitted( executing );
@@ -654,8 +924,8 @@ void _Thread_Delay_ended(
*/
void _Thread_Change_priority(
- Thread_Control *the_thread,
- rtems_task_priority new_priority
+ Thread_Control *the_thread,
+ Priority_Control new_priority
)
{
ISR_Level level;
@@ -704,8 +974,8 @@ void _Thread_Change_priority(
*/
void _Thread_Set_priority(
- Thread_Control *the_thread,
- rtems_task_priority new_priority
+ Thread_Control *the_thread,
+ Priority_Control new_priority
)
{
the_thread->current_priority = new_priority;
@@ -735,13 +1005,13 @@ void _Thread_Set_priority(
*/
boolean _Thread_Change_mode(
- unsigned32 new_mode_set,
- unsigned32 mask,
- unsigned32 *old_mode_set
+ Modes_Control new_mode_set,
+ Modes_Control mask,
+ Modes_Control *old_mode_set
)
{
- rtems_mode changed;
- rtems_mode threads_new_mode_set;
+ Modes_Control changed;
+ Modes_Control threads_new_mode_set;
Thread_Control *executing;
boolean need_dispatch;
@@ -754,7 +1024,7 @@ boolean _Thread_Change_mode(
_Modes_Set_interrupt_level( threads_new_mode_set );
if ( _Modes_Mask_changed( changed, RTEMS_ASR_MASK ) )
- _ASR_Swap_signals( &executing->Signal );
+ _ASR_Swap_signals( &executing->RTEMS_API->Signal );
executing->current_modes = threads_new_mode_set;
need_dispatch = TRUE;
@@ -765,7 +1035,7 @@ boolean _Thread_Change_mode(
_Context_Switch_necessary = TRUE;
- else if ( !_ASR_Are_signals_pending( &executing->Signal ) )
+ else if ( !_ASR_Are_signals_pending( &executing->RTEMS_API->Signal ) )
need_dispatch = FALSE;
diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c
index 60ffb5db38..7b4647bb7f 100644
--- a/cpukit/score/src/threadq.c
+++ b/cpukit/score/src/threadq.c
@@ -30,33 +30,39 @@
*
* Input parameters:
* the_thread_queue - pointer to a threadq header
- * attribute_set - used to determine queueing discipline
+ * the_class - class of the object to which this belongs
+ * discipline - queueing discipline
* state - state of waiting threads
*
* Output parameters: NONE
*/
void _Thread_queue_Initialize(
- Thread_queue_Control *the_thread_queue,
- rtems_attribute attribute_set,
- States_Control state
+ Thread_queue_Control *the_thread_queue,
+ Objects_Classes the_class,
+ Thread_queue_Disciplines the_discipline,
+ States_Control state,
+ Thread_queue_Extract_callout proxy_extract_callout
)
{
unsigned32 index;
- if ( _Attributes_Is_priority( attribute_set ) ) {
- the_thread_queue->discipline = THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE;
- for( index=0 ;
- index < TASK_QUEUE_DATA_NUMBER_OF_PRIORITY_HEADERS ;
- index++)
- _Chain_Initialize_empty( &the_thread_queue->Queues.Priority[index] );
- }
- else {
- the_thread_queue->discipline = THREAD_QUEUE_DATA_FIFO_DISCIPLINE;
- _Chain_Initialize_empty( &the_thread_queue->Queues.Fifo );
- }
+ _Thread_queue_Extract_table[ the_class ] = proxy_extract_callout;
+
+ the_thread_queue->state = state;
+ the_thread_queue->discipline = the_discipline;
- the_thread_queue->state = state;
+ switch ( the_discipline ) {
+ case THREAD_QUEUE_DISCIPLINE_FIFO:
+ _Chain_Initialize_empty( &the_thread_queue->Queues.Fifo );
+ break;
+ case THREAD_QUEUE_DISCIPLINE_PRIORITY:
+ for( index=0 ;
+ index < TASK_QUEUE_DATA_NUMBER_OF_PRIORITY_HEADERS ;
+ index++)
+ _Chain_Initialize_empty( &the_thread_queue->Queues.Priority[index] );
+ break;
+ }
}
@@ -107,10 +113,10 @@ void _Thread_queue_Enqueue(
}
switch( the_thread_queue->discipline ) {
- case THREAD_QUEUE_DATA_FIFO_DISCIPLINE:
+ case THREAD_QUEUE_DISCIPLINE_FIFO:
_Thread_queue_Enqueue_fifo( the_thread_queue, the_thread, timeout );
break;
- case THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE:
+ case THREAD_QUEUE_DISCIPLINE_PRIORITY:
_Thread_queue_Enqueue_priority(
the_thread_queue, the_thread, timeout );
break;
@@ -144,10 +150,10 @@ Thread_Control *_Thread_queue_Dequeue(
ISR_Level level;
switch ( the_thread_queue->discipline ) {
- case THREAD_QUEUE_DATA_FIFO_DISCIPLINE:
+ case THREAD_QUEUE_DISCIPLINE_FIFO:
the_thread = _Thread_queue_Dequeue_fifo( the_thread_queue );
break;
- case THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE:
+ case THREAD_QUEUE_DISCIPLINE_PRIORITY:
the_thread = _Thread_queue_Dequeue_priority( the_thread_queue );
break;
default: /* this is only to prevent warnings */
@@ -171,6 +177,45 @@ Thread_Control *_Thread_queue_Dequeue(
/*PAGE
*
+ * _Thread_queue_Extract_with_proxy
+ *
+ * This routine extracts the_thread from the_thread_queue
+ * and insures that if there is a proxy for this task on
+ * another node, it is also dealt with.
+ *
+ * XXX
+ */
+
+boolean _Thread_queue_Extract_with_proxy(
+ Thread_Control *the_thread
+)
+{
+ States_Control state;
+ Objects_Classes the_class;
+ Thread_queue_Extract_callout proxy_extract_callout;
+
+ state = the_thread->current_state;
+
+ if ( _States_Is_waiting_on_thread_queue( state ) ) {
+ if ( _States_Is_waiting_for_rpc_reply( state ) &&
+ _States_Is_locally_blocked( state ) ) {
+
+ the_class = rtems_get_class( the_thread->Wait.id );
+
+ proxy_extract_callout = _Thread_queue_Extract_table[ the_class ];
+
+ if ( proxy_extract_callout )
+ (*proxy_extract_callout)( the_thread );
+ }
+ _Thread_queue_Extract( the_thread->Wait.queue, the_thread );
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*PAGE
+ *
* _Thread_queue_Extract
*
* This routine removes a specific thread from the specified threadq,
@@ -191,10 +236,10 @@ void _Thread_queue_Extract(
)
{
switch ( the_thread_queue->discipline ) {
- case THREAD_QUEUE_DATA_FIFO_DISCIPLINE:
+ case THREAD_QUEUE_DISCIPLINE_FIFO:
_Thread_queue_Extract_fifo( the_thread_queue, the_thread );
break;
- case THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE:
+ case THREAD_QUEUE_DISCIPLINE_PRIORITY:
_Thread_queue_Extract_priority( the_thread_queue, the_thread );
break;
}
@@ -248,10 +293,10 @@ Thread_Control *_Thread_queue_First(
Thread_Control *the_thread;
switch ( the_thread_queue->discipline ) {
- case THREAD_QUEUE_DATA_FIFO_DISCIPLINE:
+ case THREAD_QUEUE_DISCIPLINE_FIFO:
the_thread = _Thread_queue_First_fifo( the_thread_queue );
break;
- case THREAD_QUEUE_DATA_PRIORITY_DISCIPLINE:
+ case THREAD_QUEUE_DISCIPLINE_PRIORITY:
the_thread = _Thread_queue_First_priority( the_thread_queue );
break;
default: /* this is only to prevent warnings */
@@ -437,16 +482,17 @@ void _Thread_queue_Extract_fifo(
if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
_ISR_Enable( level );
- _Thread_Unblock( the_thread );
} else {
_Watchdog_Deactivate( &the_thread->Timer );
_ISR_Enable( level );
(void) _Watchdog_Remove( &the_thread->Timer );
- _Thread_Unblock( the_thread );
}
+ _Thread_Unblock( the_thread );
+
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
_Thread_MP_Free_proxy( the_thread );
+
}
/*PAGE
@@ -498,17 +544,17 @@ void _Thread_queue_Enqueue_priority(
rtems_interval timeout
)
{
- rtems_task_priority search_priority;
- Thread_Control *search_thread;
- ISR_Level level;
- Chain_Control *header;
- unsigned32 header_index;
- Chain_Node *the_node;
- Chain_Node *next_node;
- Chain_Node *previous_node;
- Chain_Node *search_node;
- rtems_task_priority priority;
- States_Control block_state;
+ Priority_Control search_priority;
+ Thread_Control *search_thread;
+ ISR_Level level;
+ Chain_Control *header;
+ unsigned32 header_index;
+ Chain_Node *the_node;
+ Chain_Node *next_node;
+ Chain_Node *previous_node;
+ Chain_Node *search_node;
+ Priority_Control priority;
+ States_Control block_state;
_Chain_Initialize_empty( &the_thread->Wait.Block2n );