summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/prwlocktrywrlock.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-21 06:32:16 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-22 09:25:09 +0200
commit84a539885335c629100a6a12b57ead54bbbc0165 (patch)
treeff8d0acd9624e3888dc7fc6df9003a98a19b9b3d /cpukit/posix/src/prwlocktrywrlock.c
parentscore: Avoid Giant lock for barriers (diff)
downloadrtems-84a539885335c629100a6a12b57ead54bbbc0165.tar.bz2
score: Avoid Giant lock for CORE rwlock
Update #2555.
Diffstat (limited to 'cpukit/posix/src/prwlocktrywrlock.c')
-rw-r--r--cpukit/posix/src/prwlocktrywrlock.c60
1 files changed, 17 insertions, 43 deletions
diff --git a/cpukit/posix/src/prwlocktrywrlock.c b/cpukit/posix/src/prwlocktrywrlock.c
index 065199b88a..a44a54ffb5 100644
--- a/cpukit/posix/src/prwlocktrywrlock.c
+++ b/cpukit/posix/src/prwlocktrywrlock.c
@@ -18,57 +18,31 @@
#include "config.h"
#endif
-#include <pthread.h>
-#include <errno.h>
-
#include <rtems/posix/rwlockimpl.h>
-#include <rtems/score/thread.h>
-
-/*
- * pthread_rwlock_trywrlock
- *
- * This directive attempts to obtain a Write only lock on an rwlock instance.
- *
- * Input parameters:
- * rwlock - pointer to rwlock id
- *
- * Output parameters:
- * 0 - if successful
- * error code - if unsuccessful
- */
int pthread_rwlock_trywrlock(
pthread_rwlock_t *rwlock
)
{
- POSIX_RWLock_Control *the_rwlock;
- Objects_Locations location;
- Thread_Control *executing;
-
- the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
+ POSIX_RWLock_Control *the_rwlock;
+ ISR_lock_Context lock_context;
+ Thread_Control *executing;
- executing = _Thread_Executing;
- _CORE_RWLock_Seize_for_writing(
- &the_rwlock->RWLock,
- executing,
- false, /* we are not willing to wait */
- 0
- );
+ the_rwlock = _POSIX_RWLock_Get( rwlock, &lock_context );
- _Objects_Put( &the_rwlock->Object );
- return _POSIX_RWLock_Translate_core_RWLock_return_code(
- (CORE_RWLock_Status) executing->Wait.return_code
- );
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
+ if ( the_rwlock == NULL ) {
+ return EINVAL;
}
- return EINVAL;
+ executing = _Thread_Executing;
+ _CORE_RWLock_Seize_for_writing(
+ &the_rwlock->RWLock,
+ executing,
+ false, /* we are not willing to wait */
+ 0,
+ &lock_context
+ );
+ return _POSIX_RWLock_Translate_core_RWLock_return_code(
+ (CORE_RWLock_Status) executing->Wait.return_code
+ );
}