summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2006-10-30 22:21:23 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2006-10-30 22:21:23 +0000
commit0c2ec7f52c496e436f09d44dcb880bf4ea16ba86 (patch)
treea9b300a256bb640e1abfdc6dbbb6eac0a49c6a96 /cpukit/score
parent2006-10-30 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-0c2ec7f52c496e436f09d44dcb880bf4ea16ba86.tar.bz2
2006-10-30 Joel Sherrill <joel@OARcorp.com>
PR 841/rtems * itron/inline/rtems/itron/semaphore.inl, itron/src/twai_sem.c, posix/include/rtems/posix/semaphore.h, posix/inline/rtems/posix/semaphore.inl, posix/src/semaphorewaitsupp.c, posix/src/semtimedwait.c, posix/src/semwait.c, rtems/src/semobtain.c, rtems/src/semtranslatereturncode.c, score/include/rtems/score/coresem.h, score/src/coresemseize.c: Make sem_timedwait more conformant to Open Group specification.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/include/rtems/score/coresem.h38
-rw-r--r--cpukit/score/src/coresemseize.c34
2 files changed, 52 insertions, 20 deletions
diff --git a/cpukit/score/include/rtems/score/coresem.h b/cpukit/score/include/rtems/score/coresem.h
index 7445151ecd..a146b1c1c2 100644
--- a/cpukit/score/include/rtems/score/coresem.h
+++ b/cpukit/score/include/rtems/score/coresem.h
@@ -82,7 +82,14 @@ typedef enum {
/** This status indicates that an attempt was made to unlock the semaphore
* and this would have made its count greater than that allowed.
*/
- CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
+ CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED,
+ /** This status indicates that the semaphore was not immediately
+ * available and the caller passed a bad timeout value to the API
+ * routine. In this case, the API required that the validity check
+ * for the timeout occur after the check that the semaphore was immediately
+ * available.
+ */
+ CORE_SEMAPHORE_BAD_TIMEOUT_VALUE
} CORE_semaphore_Status;
/**
@@ -116,6 +123,25 @@ typedef struct {
} CORE_semaphore_Control;
/**
+ * The following enumerated type is the set of blocking options
+ * available to seize operation.
+ */
+typedef enum {
+ /** This value indicates that the caller does not wish to block. */
+ CORE_SEMAPHORE_NO_WAIT,
+ /** This value indicates that the caller is willing to block forever. */
+ CORE_SEMAPHORE_BLOCK_FOREVER,
+ /** This value indicates that the caller is blocking with a timeout. */
+ CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT,
+ /** This value indicates that the caller wanted to block but passed in
+ * a bad timeout value to the API. Unfortunately, this is a weird case
+ * where the timeout bad error is required to be generated only if
+ * the semaphore is not available.
+ */
+ CORE_SEMAPHORE_BAD_TIMEOUT
+} Core_semaphore_Blocking_option;
+
+/**
* This routine initializes the semaphore based on the parameters passed.
*
* @param[in] the_semaphore is the semaphore to initialize
@@ -137,15 +163,15 @@ void _CORE_semaphore_Initialize(
* @param[in] the_semaphore is the semaphore to seize
* @param[in] id is the Id of the API level Semaphore object associated
* with this instance of a SuperCore Semaphore
- * @param[in] wait is TRUE if the calling thread is willing to wait
+ * @param[in] wait is the blocking mode
* @param[in] timeout is the number of ticks the calling thread is willing
* to wait if @a wait is TRUE.
*/
void _CORE_semaphore_Seize(
- CORE_semaphore_Control *the_semaphore,
- Objects_Id id,
- boolean wait,
- Watchdog_Interval timeout
+ CORE_semaphore_Control *the_semaphore,
+ Objects_Id id,
+ Core_semaphore_Blocking_option wait,
+ Watchdog_Interval timeout
);
/**
diff --git a/cpukit/score/src/coresemseize.c b/cpukit/score/src/coresemseize.c
index 49c835b80b..2648a620c2 100644
--- a/cpukit/score/src/coresemseize.c
+++ b/cpukit/score/src/coresemseize.c
@@ -51,10 +51,10 @@
*/
void _CORE_semaphore_Seize(
- CORE_semaphore_Control *the_semaphore,
- Objects_Id id,
- boolean wait,
- Watchdog_Interval timeout
+ CORE_semaphore_Control *the_semaphore,
+ Objects_Id id,
+ Core_semaphore_Blocking_option wait,
+ Watchdog_Interval timeout
)
{
Thread_Control *executing;
@@ -69,16 +69,22 @@ void _CORE_semaphore_Seize(
return;
}
- if ( !wait ) {
- _ISR_Enable( level );
- executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
- return;
+ switch ( wait ) {
+ case CORE_SEMAPHORE_NO_WAIT:
+ _ISR_Enable( level );
+ executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
+ return;
+ case CORE_SEMAPHORE_BAD_TIMEOUT:
+ executing->Wait.return_code = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
+ return;
+ case CORE_SEMAPHORE_BLOCK_FOREVER:
+ case CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT:
+ _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
+ executing->Wait.queue = &the_semaphore->Wait_queue;
+ executing->Wait.id = id;
+ _ISR_Enable( level );
+ _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
+ break;
}
- _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
- executing->Wait.queue = &the_semaphore->Wait_queue;
- executing->Wait.id = id;
- _ISR_Enable( level );
-
- _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
}