summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-02-09 14:30:42 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-02-09 14:30:42 +0000
commit107ce47b4b7be469696406948d2d2c1b01357b6b (patch)
tree91d1807bc741f2d6e7634f2a327239c51f4c5836 /cpukit/score
parent6dae1c2d0bec2337300e553a9fd0c29f4c13d143 (diff)
downloadrtems-107ce47b4b7be469696406948d2d2c1b01357b6b.tar.bz2
new isr synchronization algorithm using a single enumerated set of states.
Diffstat (limited to '')
-rw-r--r--cpukit/score/include/rtems/score/tqdata.h6
-rw-r--r--cpukit/score/inline/rtems/score/tqdata.inl1
-rw-r--r--cpukit/score/macros/rtems/score/tqdata.inl1
-rw-r--r--cpukit/score/src/threadq.c115
4 files changed, 76 insertions, 47 deletions
diff --git a/cpukit/score/include/rtems/score/tqdata.h b/cpukit/score/include/rtems/score/tqdata.h
index 872a29beb0..a4a5551dfd 100644
--- a/cpukit/score/include/rtems/score/tqdata.h
+++ b/cpukit/score/include/rtems/score/tqdata.h
@@ -41,10 +41,11 @@ typedef enum {
*/
typedef enum {
+ THREAD_QUEUE_SYNCHRONIZED,
THREAD_QUEUE_NOTHING_HAPPENED,
THREAD_QUEUE_TIMEOUT,
THREAD_QUEUE_SATISFIED
-} Thread_queue_states;
+} Thread_queue_States;
/*
* The following record defines the control block used
@@ -59,8 +60,7 @@ typedef struct {
Chain_Control Priority[TASK_QUEUE_DATA_NUMBER_OF_PRIORITY_HEADERS];
/* priority discipline list */
} Queues;
- boolean sync; /* alloc/dealloc critical section */
- Thread_queue_states sync_state; /* what happened while in sync */
+ Thread_queue_States sync_state; /* alloc/dealloc critical section */
Thread_queue_Disciplines discipline; /* queue discipline */
States_Control state; /* state of threads on Thread_q */
unsigned32 timeout_status;
diff --git a/cpukit/score/inline/rtems/score/tqdata.inl b/cpukit/score/inline/rtems/score/tqdata.inl
index 3cf9c51ef6..b16b3a1ca1 100644
--- a/cpukit/score/inline/rtems/score/tqdata.inl
+++ b/cpukit/score/inline/rtems/score/tqdata.inl
@@ -66,7 +66,6 @@ STATIC INLINE void _Thread_queue_Enter_critical_section (
Thread_queue_Control *the_thread_queue
)
{
- the_thread_queue->sync = TRUE;
the_thread_queue->sync_state = THREAD_QUEUE_NOTHING_HAPPENED;
}
diff --git a/cpukit/score/macros/rtems/score/tqdata.inl b/cpukit/score/macros/rtems/score/tqdata.inl
index 1df3cd5270..df1508104c 100644
--- a/cpukit/score/macros/rtems/score/tqdata.inl
+++ b/cpukit/score/macros/rtems/score/tqdata.inl
@@ -52,7 +52,6 @@
#define _Thread_queue_Enter_critical_section( _the_thread_queue ) \
do { \
- (_the_thread_queue)->sync = TRUE; \
(_the_thread_queue)->sync_state = THREAD_QUEUE_NOTHING_HAPPENED; \
} while ( 0 )
diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c
index dc52efa954..682a0362bc 100644
--- a/cpukit/score/src/threadq.c
+++ b/cpukit/score/src/threadq.c
@@ -55,6 +55,7 @@ void _Thread_queue_Initialize(
the_thread_queue->state = state;
the_thread_queue->discipline = the_discipline;
the_thread_queue->timeout_status = timeout_status;
+ the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
switch ( the_discipline ) {
case THREAD_QUEUE_DISCIPLINE_FIFO:
@@ -326,7 +327,8 @@ void _Thread_queue_Timeout(
case OBJECTS_LOCAL:
the_thread_queue = the_thread->Wait.queue;
- if ( the_thread_queue->sync == TRUE && _Thread_Is_executing(the_thread)) {
+ if ( the_thread_queue->sync_state != THREAD_QUEUE_SYNCHRONIZED &&
+ _Thread_Is_executing( the_thread ) ) {
if ( the_thread_queue->sync_state != THREAD_QUEUE_SATISFIED )
the_thread_queue->sync_state = THREAD_QUEUE_TIMEOUT;
} else {
@@ -362,13 +364,22 @@ void _Thread_queue_Enqueue_fifo (
Watchdog_Interval timeout
)
{
- ISR_Level level;
+ ISR_Level level;
+ Thread_queue_States sync_state;
_ISR_Disable( level );
- the_thread_queue->sync = FALSE;
+ sync_state = the_thread_queue->sync_state;
+ the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
+
+ switch ( sync_state ) {
+ case THREAD_QUEUE_SYNCHRONIZED:
+ /*
+ * This should never happen. It indicates that someone did not
+ * enter a thread queue critical section.
+ */
+ break;
- switch ( the_thread_queue->sync_state ) {
case THREAD_QUEUE_NOTHING_HAPPENED:
_Chain_Append_unprotected(
&the_thread_queue->Queues.Fifo,
@@ -449,15 +460,21 @@ Thread_Control *_Thread_queue_Dequeue_fifo(
_Thread_MP_Free_proxy( the_thread );
return the_thread;
- } else if ( the_thread_queue->sync &&
- the_thread_queue->sync_state != THREAD_QUEUE_SATISFIED ) {
- the_thread_queue->sync_state = THREAD_QUEUE_SATISFIED;
- _ISR_Enable( level );
- return _Thread_Executing;
- } else {
- _ISR_Enable( level );
- return NULL;
+ }
+
+ switch ( the_thread_queue->sync_state ) {
+ case THREAD_QUEUE_SYNCHRONIZED:
+ case THREAD_QUEUE_SATISFIED:
+ _ISR_Enable( level );
+ return NULL;
+
+ case THREAD_QUEUE_NOTHING_HAPPENED:
+ case THREAD_QUEUE_TIMEOUT:
+ the_thread_queue->sync_state = THREAD_QUEUE_SATISFIED;
+ _ISR_Enable( level );
+ return _Thread_Executing;
}
+ return NULL; /* this is only to prevent warnings */
}
/*PAGE
@@ -557,17 +574,18 @@ void _Thread_queue_Enqueue_priority(
Watchdog_Interval timeout
)
{
- 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;
+ 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;
+ Thread_queue_States sync_state;
_Chain_Initialize_empty( &the_thread->Wait.Block2n );
@@ -605,10 +623,10 @@ restart_forward_search:
(Thread_Control *)search_thread->Object.Node.next;
}
- the_thread_queue->sync = FALSE;
-
if ( the_thread_queue->sync_state != THREAD_QUEUE_NOTHING_HAPPENED )
- goto syncronize;
+ goto synchronize;
+
+ the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
if ( priority == search_priority )
goto equal_priority;
@@ -650,10 +668,10 @@ restart_reverse_search:
search_thread->Object.Node.previous;
}
- the_thread_queue->sync = FALSE;
-
if ( the_thread_queue->sync_state != THREAD_QUEUE_NOTHING_HAPPENED )
- goto syncronize;
+ goto synchronize;
+
+ the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
if ( priority == search_priority )
goto equal_priority;
@@ -681,9 +699,19 @@ equal_priority: /* add at end of priority group */
_ISR_Enable( level );
return;
-syncronize:
+synchronize:
- switch ( the_thread_queue->sync_state ) {
+ sync_state = the_thread_queue->sync_state;
+ the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
+
+ switch ( sync_state ) {
+ case THREAD_QUEUE_SYNCHRONIZED:
+ /*
+ * This should never happen. It indicates that someone did not
+ * enter a thread queue critical section.
+ */
+ break;
+
case THREAD_QUEUE_NOTHING_HAPPENED:
/*
* All of this was dealt with above. This should never happen.
@@ -738,9 +766,9 @@ Thread_Control *_Thread_queue_Dequeue_priority(
Thread_queue_Control *the_thread_queue
)
{
- unsigned32 index;
- ISR_Level level;
- Thread_Control *the_thread;
+ unsigned32 index;
+ ISR_Level level;
+ Thread_Control *the_thread = NULL; /* just to remove warnings */
Thread_Control *new_first_thread;
Chain_Node *new_first_node;
Chain_Node *new_second_node;
@@ -759,15 +787,18 @@ Thread_Control *_Thread_queue_Dequeue_priority(
}
}
- if ( the_thread_queue->sync &&
- the_thread_queue->sync_state != THREAD_QUEUE_SATISFIED ) {
- the_thread_queue->sync_state = THREAD_QUEUE_SATISFIED;
- _ISR_Enable( level );
- return _Thread_Executing;
- }
+ switch ( the_thread_queue->sync_state ) {
+ case THREAD_QUEUE_SYNCHRONIZED:
+ case THREAD_QUEUE_SATISFIED:
+ _ISR_Enable( level );
+ return NULL;
- _ISR_Enable( level );
- return NULL;
+ case THREAD_QUEUE_NOTHING_HAPPENED:
+ case THREAD_QUEUE_TIMEOUT:
+ the_thread_queue->sync_state = THREAD_QUEUE_SATISFIED;
+ _ISR_Enable( level );
+ return _Thread_Executing;
+ }
dequeue:
new_first_node = the_thread->Wait.Block2n.first;