summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-02 15:58:09 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-02 15:58:09 +0000
commit8f0529f65addd0664199d09080c1462b566c9773 (patch)
tree41e8be29f62bdf570a749aeed2fbcf7c3472c9b6 /cpukit/score
parentAdded support for message priority as required by POSIX. (diff)
downloadrtems-8f0529f65addd0664199d09080c1462b566c9773.tar.bz2
Added maximum count detection logic.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/include/rtems/score/coresem.h4
-rw-r--r--cpukit/score/src/coresem.c16
2 files changed, 16 insertions, 4 deletions
diff --git a/cpukit/score/include/rtems/score/coresem.h b/cpukit/score/include/rtems/score/coresem.h
index 2ef1371e8d..1384ca361d 100644
--- a/cpukit/score/include/rtems/score/coresem.h
+++ b/cpukit/score/include/rtems/score/coresem.h
@@ -55,7 +55,8 @@ typedef enum {
CORE_SEMAPHORE_STATUS_SUCCESSFUL,
CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT,
CORE_SEMAPHORE_WAS_DELETED,
- CORE_SEMAPHORE_TIMEOUT
+ CORE_SEMAPHORE_TIMEOUT,
+ CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
} CORE_semaphore_Status;
/*
@@ -64,6 +65,7 @@ typedef enum {
*/
typedef struct {
+ unsigned32 maximum_count;
CORE_semaphore_Disciplines discipline;
} CORE_semaphore_Attributes;
diff --git a/cpukit/score/src/coresem.c b/cpukit/score/src/coresem.c
index b0b471bad6..fde8505c64 100644
--- a/cpukit/score/src/coresem.c
+++ b/cpukit/score/src/coresem.c
@@ -91,16 +91,26 @@ CORE_semaphore_Status _CORE_semaphore_Surrender(
)
{
Thread_Control *the_thread;
+ ISR_Level level;
+ CORE_semaphore_Status status;
+
+ status = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
if ( (the_thread = _Thread_queue_Dequeue(&the_semaphore->Wait_queue)) ) {
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
(*api_semaphore_mp_support) ( the_thread, id );
- } else
- the_semaphore->count += 1;
+ } else {
+ _ISR_Disable( level );
+ if ( the_semaphore->count <= the_semaphore->Attributes.maximum_count )
+ the_semaphore->count += 1;
+ else
+ status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;
+ _ISR_Enable( level );
+ }
- return( CORE_SEMAPHORE_STATUS_SUCCESSFUL );
+ return status;
}
/*PAGE