summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-28 20:39:48 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-28 20:39:48 +0000
commitc838e2f437e92d76173d86402c74b73e847af88a (patch)
tree9f809fc793b19e2eeca2a856e96a2ac7e36a425b /cpukit/posix
parent2010-07-27 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff)
downloadrtems-c838e2f437e92d76173d86402c74b73e847af88a.tar.bz2
2010-07-28 Vinu Rajashekhar <vinutheraj@gmail.com>
* posix/src/condinit.c, posix/src/condwaitsupp.c, posix/src/psignalunblockthread.c: Clean up some signal interruption code.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/src/condinit.c4
-rw-r--r--cpukit/posix/src/condwaitsupp.c11
-rw-r--r--cpukit/posix/src/psignalunblockthread.c12
3 files changed, 14 insertions, 13 deletions
diff --git a/cpukit/posix/src/condinit.c b/cpukit/posix/src/condinit.c
index 5e64efa7cd..8bdbe2be00 100644
--- a/cpukit/posix/src/condinit.c
+++ b/cpukit/posix/src/condinit.c
@@ -44,7 +44,6 @@ int pthread_cond_init(
/*
* Be careful about attributes when global!!!
*/
-
if ( the_attr->process_shared == PTHREAD_PROCESS_SHARED )
return EINVAL;
@@ -64,11 +63,10 @@ int pthread_cond_init(
the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
-/* XXX some more initialization might need to go here */
_Thread_queue_Initialize(
&the_cond->Wait_queue,
THREAD_QUEUE_DISCIPLINE_FIFO,
- STATES_WAITING_FOR_CONDITION_VARIABLE,
+ STATES_WAITING_FOR_CONDITION_VARIABLE | STATES_INTERRUPTIBLE_BY_SIGNAL,
ETIMEDOUT
);
diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c
index f08c7d0649..745d224d3d 100644
--- a/cpukit/posix/src/condwaitsupp.c
+++ b/cpukit/posix/src/condwaitsupp.c
@@ -85,9 +85,16 @@ int _POSIX_Condition_variables_Wait_support(
* _Thread_queue_Enqueue.
*/
+ /*
+ * If the thread is interrupted, while in the thread queue, by
+ * a POSIX signal, then pthread_cond_wait returns spuriously,
+ * according to the POSIX standard. It means that pthread_cond_wait
+ * returns a success status, except for the fact that it was not
+ * woken up a pthread_cond_signal or a pthread_cond_broadcast.
+ */
status = _Thread_Executing->Wait.return_code;
- if ( status && status != ETIMEDOUT )
- return status;
+ if ( status == EINTR )
+ status = 0;
} else {
_Thread_Enable_dispatch();
diff --git a/cpukit/posix/src/psignalunblockthread.c b/cpukit/posix/src/psignalunblockthread.c
index 912ac34694..4b08a4eea3 100644
--- a/cpukit/posix/src/psignalunblockthread.c
+++ b/cpukit/posix/src/psignalunblockthread.c
@@ -101,21 +101,17 @@ bool _POSIX_signals_Unblock_thread(
if ( the_thread->current_state & STATES_INTERRUPTIBLE_BY_SIGNAL ) {
the_thread->Wait.return_code = EINTR;
/*
- * At this time, there is no RTEMS API object which lets a task
- * block on a thread queue and be interruptible by a POSIX signal.
- * If an object class with that requirement is ever added, enable
- * this code.
+ * In pthread_cond_wait, a thread will be blocking on a thread
+ * queue, but is also interruptible by a POSIX signal.
*/
- #if 0
if ( _States_Is_waiting_on_thread_queue(the_thread->current_state) )
_Thread_queue_Extract_with_proxy( the_thread );
- else
- #endif
- if ( _States_Is_delaying(the_thread->current_state) ){
+ else if ( _States_Is_delaying(the_thread->current_state) ){
if ( _Watchdog_Is_active( &the_thread->Timer ) )
(void) _Watchdog_Remove( &the_thread->Timer );
_Thread_Unblock( the_thread );
}
+
} else if ( the_thread->current_state == STATES_READY ) {
if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
_Context_Switch_necessary = true;