diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-08-04 15:06:45 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-08-04 15:06:45 +0000 |
commit | f5ab0885ee728a459d6c830e2b8f5a7a3de37b15 (patch) | |
tree | a584a2cf7b6a9f648ce8fe79586234eb21afedef /testsuites/psxtmtests/psxtmrwlock01 | |
parent | 21889eadb58b800f0cc0efbf89d49c43e467aa3c (diff) |
2011-08-04 Ricardo Aguirre <el.mastin@ymail.com>
* psxtmrwlock01/init.c, psxtmrwlock01/psxtmrwlock01.doc: Update.
Diffstat (limited to 'testsuites/psxtmtests/psxtmrwlock01')
-rw-r--r-- | testsuites/psxtmtests/psxtmrwlock01/init.c | 89 | ||||
-rw-r--r-- | testsuites/psxtmtests/psxtmrwlock01/psxtmrwlock01.doc | 7 |
2 files changed, 60 insertions, 36 deletions
diff --git a/testsuites/psxtmtests/psxtmrwlock01/init.c b/testsuites/psxtmtests/psxtmrwlock01/init.c index ef1c22ba72..21982ab0cc 100644 --- a/testsuites/psxtmtests/psxtmrwlock01/init.c +++ b/testsuites/psxtmtests/psxtmrwlock01/init.c @@ -12,7 +12,6 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif - #include <errno.h> #include <timesys.h> #include <rtems/timerdrv.h> @@ -40,6 +39,7 @@ void benchmark_pthread_rwlock_init(void) 0, 0 ); + } void benchmark_pthread_rwlock_rdlock(void) @@ -59,9 +59,10 @@ void benchmark_pthread_rwlock_rdlock(void) 0, 0 ); + } -void benchmark_pthread_rwlock_unlock(bool do_print) +void benchmark_pthread_rwlock_unlock(int print) { long end_time; int status; @@ -69,12 +70,8 @@ void benchmark_pthread_rwlock_unlock(bool do_print) benchmark_timer_initialize(); status = pthread_rwlock_unlock(&rwlock); end_time = benchmark_timer_read(); - if ( status == EPERM ) - puts( "The current thread does not own the read-write lock"); - else - rtems_test_assert( status == 0 ); - - if ( do_print ) { + rtems_test_assert( status == 0 ); + if ( print == 1 ){ put_time( "pthread_rwlock_unlock - available", end_time, @@ -93,15 +90,24 @@ void benchmark_pthread_rwlock_tryrdlock(void) benchmark_timer_initialize(); status = pthread_rwlock_tryrdlock(&rwlock); end_time = benchmark_timer_read(); - rtems_test_assert( status == 0 ); - - put_time( - "pthread_rwlock_tryrdlock - available", - end_time, - 1, /* Only executed once */ - 0, - 0 - ); + rtems_test_assert( status == 0 || status == EBUSY ); + if (status == EBUSY) { + put_time( + "pthread_rwlock_tryrdlock - not available", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); + } else if (status == 0) { + put_time( + "pthread_rwlock_tryrdlock - available", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); + } } void benchmark_pthread_rwlock_timedrdlock(void) @@ -121,6 +127,7 @@ void benchmark_pthread_rwlock_timedrdlock(void) 0, 0 ); + } void benchmark_pthread_rwlock_wrlock(void) @@ -140,6 +147,7 @@ void benchmark_pthread_rwlock_wrlock(void) 0, 0 ); + } void benchmark_pthread_rwlock_trywrlock(void) @@ -150,15 +158,25 @@ void benchmark_pthread_rwlock_trywrlock(void) benchmark_timer_initialize(); status = pthread_rwlock_trywrlock(&rwlock); end_time = benchmark_timer_read(); - rtems_test_assert( status == 0 ); - put_time( - "pthread_rwlock_trywrlock - available", - end_time, - 1, /* Only executed once */ - 0, - 0 - ); + rtems_test_assert( status == 0 || status == EBUSY ); + if ( status == EBUSY ) { + put_time( + "pthread_rwlock_trywrlock - not available ", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); + } else if ( status == 0 ) { + put_time( + "pthread_rwlock_trywrlock - available", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); + } } void benchmark_pthread_rwlock_timedwrlock(void) @@ -211,31 +229,36 @@ void *POSIX_Init( /* applying a read lock */ benchmark_pthread_rwlock_rdlock(); /* unlocking rwlock */ - benchmark_pthread_rwlock_unlock( true ); - /* trying to apply a read lock when it is available */ + benchmark_pthread_rwlock_unlock(0); + /* trying to apply a read lock when it is available*/ benchmark_pthread_rwlock_tryrdlock(); /* unlocking rwlock */ - benchmark_pthread_rwlock_unlock( false ); + benchmark_pthread_rwlock_unlock(0); /* applying a timed read lock */ benchmark_pthread_rwlock_timedrdlock(); /* unlocking rwlock */ - benchmark_pthread_rwlock_unlock( false ); + benchmark_pthread_rwlock_unlock(0); /* applying a write lock */ benchmark_pthread_rwlock_wrlock(); + /* trying to get read lock, when is not available*/ + benchmark_pthread_rwlock_tryrdlock(); /* unlocking rwlock */ - benchmark_pthread_rwlock_unlock( false ); - /* trying to apply a write lock, when it is available */ + benchmark_pthread_rwlock_unlock(0); + /* trying to apply a write lock, when it is available*/ + benchmark_pthread_rwlock_trywrlock(); + /* trying to get write lock, when it is not available*/ benchmark_pthread_rwlock_trywrlock(); /* unlocking rwlock */ - benchmark_pthread_rwlock_unlock( false ); + benchmark_pthread_rwlock_unlock(0); /* applying a timed write lock */ benchmark_pthread_rwlock_timedwrlock(); /* unlocking rwlock */ - benchmark_pthread_rwlock_unlock( false ); + benchmark_pthread_rwlock_unlock(1); /* destroying rwlock */ benchmark_pthread_rwlock_destroy(); puts( "*** END OF POSIX TIME PSXTMRWLOCK 01 ***" ); + rtems_test_exit(0); } diff --git a/testsuites/psxtmtests/psxtmrwlock01/psxtmrwlock01.doc b/testsuites/psxtmtests/psxtmrwlock01/psxtmrwlock01.doc index 7ccf6efbeb..147a36ac10 100644 --- a/testsuites/psxtmtests/psxtmrwlock01/psxtmrwlock01.doc +++ b/testsuites/psxtmtests/psxtmrwlock01/psxtmrwlock01.doc @@ -15,9 +15,10 @@ This test benchmarks the following operations: + pthread_rwlock_rdlock - available + pthread_rwlock_unlock + pthread_rwlock_tryrdlock - available ++ pthread_rwlock_tryrdlock - not available + pthread_rwlock_timedrdlock - available -+ pthread_rwlock_wrlock - available -+ pthread_rwlock_trywrlock - available ++ pthread_rwlock_wrlock - available ++ pthread_rwlock_trywrlock - available ++ pthread_rwlock_trywrlock - not available + pthread_rwlock_timedwrlock - available + pthread_rwlock_destroy - |