summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pthreadequal.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-04 11:10:32 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-06 08:17:05 +0200
commit64051ec80b55c3945ace509fa275c21ab8c89ab1 (patch)
tree6e239a88e5489b8db583f15e09e57e09bd6dd11a /cpukit/posix/src/pthreadequal.c
parentrtems: Avoid Giant lock for signals (diff)
downloadrtems-64051ec80b55c3945ace509fa275c21ab8c89ab1.tar.bz2
posix: Avoid Giant lock in pthread_equal()
Update #2555.
Diffstat (limited to 'cpukit/posix/src/pthreadequal.c')
-rw-r--r--cpukit/posix/src/pthreadequal.c60
1 files changed, 9 insertions, 51 deletions
diff --git a/cpukit/posix/src/pthreadequal.c b/cpukit/posix/src/pthreadequal.c
index 12ce9f28fb..4ee5040c14 100644
--- a/cpukit/posix/src/pthreadequal.c
+++ b/cpukit/posix/src/pthreadequal.c
@@ -40,58 +40,16 @@ int pthread_equal(
#ifndef RTEMS_DEBUG
return _Objects_Are_ids_equal( t1, t2 );
#else
- int status;
- Objects_Locations location;
- Thread_Control *thread_1;
- Thread_Control *thread_2;
+ ISR_lock_Context lock_context_1;
+ ISR_lock_Context lock_context_2;
+ Thread_Control *thread_1;
+ Thread_Control *thread_2;
- /*
- * By default this is not a match.
- */
-
- status = 0;
-
- /*
- * Validate the first id and return 0 if it is not valid
- */
-
- thread_1 = _Thread_Get( t1, &location );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
-
- /*
- * Validate the second id and return 0 if it is not valid
- */
-
- thread_2 = _Thread_Get( t2, &location );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
- status = _Objects_Are_ids_equal( t1, t2 );
- _Objects_Put_without_thread_dispatch( &thread_2->Object );
- _Objects_Put( &thread_1->Object );
- break;
-
- case OBJECTS_ERROR:
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- /* t1 must have been valid so exit the critical section */
- _Objects_Put( &thread_1->Object );
- /* return status == 0 */
- break;
- }
- break;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- /* return status == 0 */
- break;
- }
+ thread_1 = _Thread_Get_interrupt_disable( t1, &lock_context_1 );
+ thread_2 = _Thread_Get_interrupt_disable( t2, &lock_context_2 );
+ _ISR_lock_ISR_enable( &lock_context_2 );
+ _ISR_lock_ISR_enable( &lock_context_1 );
- return status;
+ return thread_1 != NULL && thread_1 == thread_2;
#endif
}