testsuites/psxtmtests: reformat with clang-format

Updates #3860.

Updates #5358.
This commit is contained in:
Gedare Bloom
2026-02-02 14:35:59 -06:00
committed by Kinsey Moore
parent 077fbf519b
commit 87e4f79bd1
54 changed files with 1216 additions and 1583 deletions
+15 -17
View File
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -42,14 +42,14 @@
const char rtems_test_name[] = "PSXTMBARRIER 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
static void benchmark_pthread_barrier_init(void);
void *POSIX_Init( void *argument );
static void benchmark_pthread_barrier_init( void );
pthread_barrier_t barrier;
pthread_barrier_t barrier;
static void benchmark_pthread_barrier_init(void)
static void benchmark_pthread_barrier_init( void )
{
benchmark_timer_t end_time;
benchmark_timer_t end_time;
int status;
pthread_barrierattr_t attr;
@@ -60,41 +60,39 @@ static void benchmark_pthread_barrier_init(void)
rtems_test_assert( status == 0 );
benchmark_timer_initialize();
status = pthread_barrier_init( &barrier,&attr, 1 );
status = pthread_barrier_init( &barrier, &attr, 1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_barrier_init: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_barrier_destroy(void)
static void benchmark_pthread_barrier_destroy( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_barrier_destroy( &barrier );
status = pthread_barrier_destroy( &barrier );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_barrier_destroy: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -107,7 +105,7 @@ void *POSIX_Init(
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -115,7 +113,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+20 -26
View File
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -45,15 +45,13 @@
const char rtems_test_name[] = "PSXTMBARRIER 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_barrier_t barrier;
pthread_barrier_t barrier;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -65,7 +63,7 @@ void *Low(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
end_time = benchmark_timer_read();
@@ -83,9 +81,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -95,29 +91,27 @@ void *Middle(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
(void) pthread_barrier_wait( &barrier );
(void) pthread_barrier_wait( &barrier );
/* should never return */
rtems_test_assert( FALSE );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
pthread_barrierattr_t attr;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -137,7 +131,7 @@ void *POSIX_Init(
* Set threshold on count higher than number of threads so all will
* block.
*/
status = pthread_barrier_init( &barrier,&attr, OPERATION_COUNT + 2 );
status = pthread_barrier_init( &barrier, &attr, OPERATION_COUNT + 2 );
rtems_test_assert( status == 0 );
/*
@@ -150,8 +144,8 @@ void *POSIX_Init(
* all the other tasks.
*/
benchmark_timer_initialize();
/* blocking barrier call */
status = pthread_barrier_wait( &barrier );
/* blocking barrier call */
status = pthread_barrier_wait( &barrier );
rtems_test_assert( status == 0 );
return NULL;
}
@@ -161,10 +155,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+12 -22
View File
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -44,15 +44,13 @@
const char rtems_test_name[] = "PSXTMBARRIER 03";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Blocker(void *argument);
void *POSIX_Init( void *argument );
void *Blocker( void *argument );
#define N 2
pthread_barrier_t barrier;
#define N 2
pthread_barrier_t barrier;
void *Blocker(
void *argument
)
void *Blocker( void *argument )
{
(void) argument;
@@ -61,14 +59,12 @@ void *Blocker(
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
pthread_t threadId;
int status;
pthread_t threadId;
benchmark_timer_t end_time;
TEST_BEGIN();
@@ -89,7 +85,7 @@ void *POSIX_Init(
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other thread run */
/* let other thread run */
/*
* Because this is the Nth thread at the barrier, this is an
@@ -104,13 +100,7 @@ void *POSIX_Init(
*/
rtems_test_assert( status == PTHREAD_BARRIER_SERIAL_THREAD );
put_time(
"pthread_barrier_wait: releasing no preempt",
end_time,
1,
0,
0
);
put_time( "pthread_barrier_wait: releasing no preempt", end_time, 1, 0, 0 );
TEST_END();
rtems_test_exit( 0 );
@@ -123,7 +113,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+15 -27
View File
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -44,15 +44,13 @@
const char rtems_test_name[] = "PSXTMBARRIER 04";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Blocker(void *argument);
void *POSIX_Init( void *argument );
void *Blocker( void *argument );
#define N 2
pthread_barrier_t barrier;
#define N 2
pthread_barrier_t barrier;
void *Blocker(
void *argument
)
void *Blocker( void *argument )
{
(void) argument;
@@ -61,30 +59,20 @@ void *Blocker(
/* block on barrier wait, switch back to first thread */
(void) pthread_barrier_wait( &barrier );
/* preempt first thread and stop time */
end_time = benchmark_timer_read();
put_time(
"pthread_barrier_wait: releasing preempt",
end_time,
1,
0,
0
);
put_time( "pthread_barrier_wait: releasing preempt", end_time, 1, 0, 0 );
TEST_END();
rtems_test_exit( 0 );
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
pthread_t threadId;
int policy;
int status;
pthread_t threadId;
int policy;
struct sched_param param;
TEST_BEGIN();
@@ -97,10 +85,10 @@ void *POSIX_Init(
/* yield to second thread so it can start up and block */
sched_yield();
pthread_getschedparam(threadId, &policy, &param);
param.sched_priority = sched_get_priority_max(policy) - 1;
pthread_getschedparam( threadId, &policy, &param );
param.sched_priority = sched_get_priority_max( policy ) - 1;
/* preempt doesn't occur here due to second thread being blocked */
pthread_setschedparam(threadId, policy, &param);
pthread_setschedparam( threadId, policy, &param );
/* as soon as this thread waits on barrier, release occurs, 2nd thread
* preempts this one due to having a higher priority
@@ -117,7 +105,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+13 -19
View File
@@ -25,7 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -42,11 +42,11 @@
const char rtems_test_name[] = "PSXTMBARRIERATTR01";
/* forward declarations to avoid warnings */
static void *POSIX_Init(void *argument);
static void *POSIX_Init( void *argument );
static pthread_barrierattr_t attr;
static void benchmark_create_barrierattr(void)
static void benchmark_create_barrierattr( void )
{
benchmark_timer_t end_time;
int status;
@@ -59,14 +59,13 @@ static void benchmark_create_barrierattr(void)
put_time(
"pthread_barrierattr_init: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_barrierattr_setpshared(void)
static void benchmark_barrierattr_setpshared( void )
{
benchmark_timer_t end_time;
int status;
@@ -79,14 +78,13 @@ static void benchmark_barrierattr_setpshared(void)
put_time(
"pthread_barrierattr_setpshared: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_barrierattr_getpshared(void)
static void benchmark_barrierattr_getpshared( void )
{
benchmark_timer_t end_time;
int status;
@@ -101,14 +99,13 @@ static void benchmark_barrierattr_getpshared(void)
put_time(
"pthread_barrierattr_getpshared: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_destroy_barrierattr(void)
static void benchmark_destroy_barrierattr( void )
{
benchmark_timer_t end_time;
int status;
@@ -121,16 +118,13 @@ static void benchmark_destroy_barrierattr(void)
put_time(
"pthread_barrierattr_destroy: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void *POSIX_Init(
void *argument
)
static void *POSIX_Init( void *argument )
{
(void) argument;
@@ -142,7 +136,7 @@ static void *POSIX_Init(
benchmark_destroy_barrierattr();
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -150,7 +144,7 @@ static void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+11 -14
View File
@@ -25,7 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -42,29 +42,29 @@
const char rtems_test_name[] = "PSXTMCLEANUP01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
int status = 1;
static void routine(void *arg)
static void routine( void *arg )
{
(void) arg;
}
static void benchmark_pthread_cleanup_push_pull(void)
static void benchmark_pthread_cleanup_push_pull( void )
{
benchmark_timer_t end_time;
int execute = 1;
int execute = 1;
status = 0;
benchmark_timer_initialize();
pthread_cleanup_push(routine, NULL);
pthread_cleanup_push( routine, NULL );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_cleanup_push : only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
@@ -76,16 +76,13 @@ static void benchmark_pthread_cleanup_push_pull(void)
put_time(
"pthread_cleanup_pop : only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -94,7 +91,7 @@ void *POSIX_Init(
benchmark_pthread_cleanup_push_pull();
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -102,7 +99,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
@@ -39,16 +39,14 @@
const char rtems_test_name[] = "PSXTMCLOCKNANOSLEEP 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
benchmark_timer_t end_time;
struct timespec sleepTime;
struct timespec sleepTime;
sleepTime.tv_sec = 0;
sleepTime.tv_nsec = 0;
@@ -56,14 +54,14 @@ void *POSIX_Init(
TEST_BEGIN();
benchmark_timer_initialize();
clock_nanosleep( CLOCK_REALTIME, 0, &sleepTime, (struct timespec *) NULL );
clock_nanosleep( CLOCK_REALTIME, 0, &sleepTime, (struct timespec *) NULL );
end_time = benchmark_timer_read();
put_time( "nanosleep: yield", end_time, 1, 0, 0 );
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -71,7 +69,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
@@ -41,13 +41,11 @@
const char rtems_test_name[] = "PSXTMCLOCKNANOSLEEP 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -55,13 +53,7 @@ void *Low(
end_time = benchmark_timer_read();
put_time(
"clock_nanosleep: blocking",
end_time,
OPERATION_COUNT,
0,
0
);
put_time( "clock_nanosleep: blocking", end_time, OPERATION_COUNT, 0, 0 );
TEST_END();
@@ -69,9 +61,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -80,20 +70,18 @@ void *Middle(
sleepTime.tv_sec = 0;
sleepTime.tv_nsec = 1;
clock_nanosleep(CLOCK_REALTIME, 0, &sleepTime, (struct timespec *) NULL);
clock_nanosleep( CLOCK_REALTIME, 0, &sleepTime, (struct timespec *) NULL );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
struct timespec sleepTime;
struct timespec remainder;
@@ -104,7 +92,7 @@ void *POSIX_Init(
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -115,7 +103,7 @@ void *POSIX_Init(
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
/* calling clock_nanosleep*/
clock_nanosleep(CLOCK_REALTIME, 0, &sleepTime, &remainder);
clock_nanosleep( CLOCK_REALTIME, 0, &sleepTime, &remainder );
return NULL;
}
@@ -125,10 +113,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
@@ -41,13 +41,11 @@
const char rtems_test_name[] = "PSXTMCLOCKNANOSLEEP 03";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -55,13 +53,7 @@ void *Low(
end_time = benchmark_timer_read();
put_time(
"clock_nanosleep: blocking",
end_time,
OPERATION_COUNT,
0,
0
);
put_time( "clock_nanosleep: blocking", end_time, OPERATION_COUNT, 0, 0 );
TEST_END();
@@ -69,9 +61,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -90,15 +80,13 @@ void *Middle(
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
struct timespec sleepTime;
struct timespec remainder;
@@ -109,7 +97,7 @@ void *POSIX_Init(
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -120,7 +108,7 @@ void *POSIX_Init(
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
/* calling clock_nanosleep*/
clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &sleepTime, &remainder);
clock_nanosleep( CLOCK_REALTIME, TIMER_ABSTIME, &sleepTime, &remainder );
return NULL;
}
@@ -130,10 +118,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+12 -26
View File
@@ -40,53 +40,39 @@
const char rtems_test_name[] = "PSXTMCOND 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void benchmark_create_cond_var(void);
void benchmark_destroy_cond_var(void);
void *POSIX_Init( void *argument );
void benchmark_create_cond_var( void );
void benchmark_destroy_cond_var( void );
pthread_cond_t mycondvar;
void benchmark_create_cond_var(void)
void benchmark_create_cond_var( void )
{
uint32_t end_time;
int status;
benchmark_timer_initialize();
status = pthread_cond_init(&mycondvar, NULL);
status = pthread_cond_init( &mycondvar, NULL );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_cond_init: only case",
end_time,
1,
0,
0
);
put_time( "pthread_cond_init: only case", end_time, 1, 0, 0 );
}
void benchmark_destroy_cond_var(void)
void benchmark_destroy_cond_var( void )
{
uint32_t end_time;
int status;
benchmark_timer_initialize();
status = pthread_cond_destroy(&mycondvar);
status = pthread_cond_destroy( &mycondvar );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_cond_destroy: only case",
end_time,
1,
0,
0
);
put_time( "pthread_cond_destroy: only case", end_time, 1, 0, 0 );
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -96,7 +82,7 @@ void *POSIX_Init(
benchmark_destroy_cond_var();
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -106,7 +92,7 @@ void *POSIX_Init(
/* configure an instance of the condition variable created and destroyed */
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+9 -12
View File
@@ -38,19 +38,19 @@
const char rtems_test_name[] = "PSXTMCOND 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void benchmark_signal(void);
void *POSIX_Init( void *argument );
void benchmark_signal( void );
pthread_cond_t CondID;
void benchmark_signal(void)
void benchmark_signal( void )
{
uint32_t end_time;
int status;
benchmark_timer_initialize();
status = pthread_cond_signal(&CondID);
status = pthread_cond_signal( &CondID );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
@@ -58,27 +58,24 @@ void benchmark_signal(void)
put_time(
"pthread_cond_signal: no threads waiting",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
TEST_BEGIN();
pthread_cond_init(&CondID, NULL);
pthread_cond_init( &CondID, NULL );
benchmark_signal();
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -86,7 +83,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+26 -30
View File
@@ -40,53 +40,49 @@
const char rtems_test_name[] = "PSXTMCOND 03";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Blocker(void *argument);
void *POSIX_Init( void *argument );
void *Blocker( void *argument );
pthread_mutex_t MutexID;
pthread_cond_t CondID;
pthread_cond_t CondID;
void *Blocker(
void *argument
)
void *Blocker( void *argument )
{
(void) argument;
int status;
status = pthread_mutex_lock(&MutexID);
status = pthread_mutex_lock( &MutexID );
rtems_test_assert( status == 0 );
/* Unlock mutex, block, wait for CondID to be signaled */
pthread_cond_wait(&CondID,&MutexID);
/* should never return */
pthread_cond_wait( &CondID, &MutexID );
/* should never return */
rtems_test_assert( FALSE );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
pthread_t threadId;
uint32_t end_time;
int status;
pthread_t threadId;
uint32_t end_time;
struct sched_param param;
int policy;
int policy;
TEST_BEGIN();
status = pthread_create( &threadId, NULL, Blocker, NULL );
rtems_test_assert( status == 0 );
status = pthread_mutex_init(&MutexID, NULL);
status = pthread_mutex_init( &MutexID, NULL );
rtems_test_assert( status == 0 );
status = pthread_cond_init(&CondID, NULL); /* Create condition variable */
status = pthread_cond_init( &CondID, NULL ); /* Create condition variable */
rtems_test_assert( status == 0 );
/*
@@ -94,17 +90,17 @@ void *POSIX_Init(
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other thread run */
/* let other thread run */
/* To be extra sure we don't get preempted on the signal */
status = pthread_getschedparam(pthread_self(), &policy, &param);
rtems_test_assert( status == 0);
param.sched_priority = sched_get_priority_max(policy) - 1;
status = pthread_setschedparam(pthread_self(), policy, &param);
rtems_test_assert( status == 0);
status = pthread_getschedparam( pthread_self(), &policy, &param );
rtems_test_assert( status == 0 );
param.sched_priority = sched_get_priority_max( policy ) - 1;
status = pthread_setschedparam( pthread_self(), policy, &param );
rtems_test_assert( status == 0 );
benchmark_timer_initialize();
status = pthread_cond_signal(&CondID);
status = pthread_cond_signal( &CondID );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
@@ -127,10 +123,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+24 -34
View File
@@ -40,64 +40,54 @@
const char rtems_test_name[] = "PSXTMCOND 04";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Blocker(void *argument);
void *POSIX_Init( void *argument );
void *Blocker( void *argument );
pthread_mutex_t MutexID;
pthread_cond_t CondID;
pthread_cond_t CondID;
void *Blocker(
void *argument
)
void *Blocker( void *argument )
{
(void) argument;
uint32_t end_time;
struct sched_param param;
int policy;
int status;
uint32_t end_time;
struct sched_param param;
int policy;
int status;
status = pthread_mutex_lock(&MutexID);
status = pthread_mutex_lock( &MutexID );
rtems_test_assert( status == 0 );
status = pthread_getschedparam(pthread_self(), &policy, &param);
status = pthread_getschedparam( pthread_self(), &policy, &param );
rtems_test_assert( status == 0 );
param.sched_priority = sched_get_priority_max(policy) - 1;
status = pthread_setschedparam(pthread_self(), policy, &param);
param.sched_priority = sched_get_priority_max( policy ) - 1;
status = pthread_setschedparam( pthread_self(), policy, &param );
/* Thread blocks, unlocks mutex, waits for CondID to be signaled */
pthread_cond_wait(&CondID,&MutexID);
pthread_cond_wait( &CondID, &MutexID );
/* Once signaled, this thread preempts POSIX_Init thread */
end_time = benchmark_timer_read();
put_time(
"pthread_cond_signal: thread waiting preempt",
end_time,
1,
0,
0
);
put_time( "pthread_cond_signal: thread waiting preempt", end_time, 1, 0, 0 );
TEST_END();
rtems_test_exit( 0 );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
pthread_t threadId;
int status;
pthread_t threadId;
TEST_BEGIN();
status = pthread_create( &threadId, NULL, Blocker, NULL );
rtems_test_assert( status == 0 );
status = pthread_mutex_init(&MutexID, NULL);
status = pthread_mutex_init( &MutexID, NULL );
rtems_test_assert( status == 0 );
status = pthread_cond_init(&CondID, NULL); /* Create condition variable */
status = pthread_cond_init( &CondID, NULL ); /* Create condition variable */
rtems_test_assert( status == 0 );
/*
@@ -109,8 +99,8 @@ void *POSIX_Init(
/* Other thread is blocked and waiting on condition to be signaled */
benchmark_timer_initialize();
status = pthread_cond_signal(&CondID);
rtems_test_assert ( status == 0 );
status = pthread_cond_signal( &CondID );
rtems_test_assert( status == 0 );
return NULL;
}
@@ -119,10 +109,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+9 -12
View File
@@ -38,45 +38,42 @@
const char rtems_test_name[] = "PSXTMCOND 05";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void benchmark_broadcast(void);
void *POSIX_Init( void *argument );
void benchmark_broadcast( void );
pthread_cond_t CondID;
void benchmark_broadcast(void)
void benchmark_broadcast( void )
{
uint32_t end_time;
int status;
benchmark_timer_initialize();
status = pthread_cond_broadcast(&CondID);
status = pthread_cond_broadcast( &CondID );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_cond_broadcast: no threads waiting",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
TEST_BEGIN();
pthread_cond_init(&CondID, NULL);
pthread_cond_init( &CondID, NULL );
benchmark_broadcast();
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -84,7 +81,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+26 -30
View File
@@ -42,54 +42,50 @@
const char rtems_test_name[] = "PSXTMCOND 06";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Blocker(void *argument);
void *POSIX_Init( void *argument );
void *Blocker( void *argument );
pthread_mutex_t MutexID;
pthread_cond_t CondID;
pthread_cond_t CondID;
void *Blocker(
void *argument
)
void *Blocker( void *argument )
{
(void) argument;
int status;
status = pthread_mutex_lock(&MutexID);
status = pthread_mutex_lock( &MutexID );
rtems_test_assert( status == 0 );
/* Unlock mutex, block, wait for CondID to be signaled */
pthread_cond_wait(&CondID,&MutexID);
pthread_cond_wait( &CondID, &MutexID );
/* should never return */
/* should never return */
rtems_test_assert( FALSE );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
uint32_t end_time;
int status;
int i;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
int policy;
uint32_t end_time;
int status;
int i;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
int policy;
TEST_BEGIN();
/* Setup variables */
status = pthread_create( &threadId, NULL, Blocker, NULL );
rtems_test_assert( status == 0 );
status = pthread_mutex_init(&MutexID, NULL);
status = pthread_mutex_init( &MutexID, NULL );
rtems_test_assert( status == 0 );
status = pthread_cond_init(&CondID, NULL);
status = pthread_cond_init( &CondID, NULL );
rtems_test_assert( status == 0 );
/* Setup so threads are created with a high enough priority to preempt
@@ -101,27 +97,27 @@ void *POSIX_Init(
rtems_test_assert( status == 0 );
status = pthread_attr_setschedpolicy( &attr, SCHED_FIFO );
rtems_test_assert( status == 0 );
param.sched_priority = sched_get_priority_max(SCHED_FIFO) / 2;
param.sched_priority = sched_get_priority_max( SCHED_FIFO ) / 2;
status = pthread_attr_setschedparam( &attr, &param );
rtems_test_assert( status == 0 );
for ( i=0 ; i < N ; i++) {
for ( i = 0; i < N; i++ ) {
/* Threads will preempt as they are created, start up, and block */
status = pthread_create(&threadId, &attr, Blocker, NULL);
status = pthread_create( &threadId, &attr, Blocker, NULL );
rtems_test_assert( status == 0 );
}
/* Now that all the threads have been created, adjust our priority
* so we don't get preempted on broadcast.
*/
status = pthread_getschedparam(pthread_self(), &policy, &param);
status = pthread_getschedparam( pthread_self(), &policy, &param );
rtems_test_assert( status == 0 );
param.sched_priority = sched_get_priority_max(policy) - 1;
status = pthread_setschedparam(pthread_self(), policy, &param);
param.sched_priority = sched_get_priority_max( policy ) - 1;
status = pthread_setschedparam( pthread_self(), policy, &param );
rtems_test_assert( status == 0 );
benchmark_timer_initialize();
status = pthread_cond_broadcast(&CondID);
status = pthread_cond_broadcast( &CondID );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
@@ -144,10 +140,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 + N
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 + N
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+23 -28
View File
@@ -42,26 +42,24 @@
const char rtems_test_name[] = "PSXTMCOND 07";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Blocker(void *argument);
void *POSIX_Init( void *argument );
void *Blocker( void *argument );
pthread_mutex_t MutexID;
pthread_cond_t CondID;
pthread_cond_t CondID;
void *Blocker(
void *argument
)
void *Blocker( void *argument )
{
(void) argument;
int status;
benchmark_timer_t end_time;
int status;
benchmark_timer_t end_time;
status = pthread_mutex_lock(&MutexID);
status = pthread_mutex_lock( &MutexID );
rtems_test_assert( status == 0 );
/* Unlock mutex, block, wait for CondID to be signaled */
pthread_cond_wait(&CondID,&MutexID);
pthread_cond_wait( &CondID, &MutexID );
end_time = benchmark_timer_read();
put_time(
@@ -75,20 +73,17 @@ void *Blocker(
TEST_END();
rtems_test_exit( 0 );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
int i;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
int status;
int i;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
TEST_BEGIN();
@@ -96,13 +91,13 @@ void *POSIX_Init(
status = pthread_create( &threadId, NULL, Blocker, NULL );
rtems_test_assert( status == 0 );
status = pthread_mutex_init(&MutexID, NULL);
status = pthread_mutex_init( &MutexID, NULL );
rtems_test_assert( status == 0 );
status = pthread_cond_init(&CondID, NULL);
status = pthread_cond_init( &CondID, NULL );
rtems_test_assert( status == 0 );
/* Setup so threads are created with a high enough priority to preempt
/* Setup so threads are created with a high enough priority to preempt
* as they get created.
*/
status = pthread_attr_init( &attr );
@@ -114,13 +109,13 @@ void *POSIX_Init(
status = pthread_attr_setschedpolicy( &attr, SCHED_FIFO );
rtems_test_assert( status == 0 );
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
param.sched_priority = sched_get_priority_max( SCHED_FIFO );
status = pthread_attr_setschedparam( &attr, &param );
rtems_test_assert( status == 0 );
for ( i=0 ; i < N ; i++ ) {
for ( i = 0; i < N; i++ ) {
/* Threads will preempt as they are created, start up, and block */
status = pthread_create(&threadId, &attr, Blocker, NULL);
status = pthread_create( &threadId, &attr, Blocker, NULL );
rtems_test_assert( status == 0 );
}
@@ -128,7 +123,7 @@ void *POSIX_Init(
* in other thread
*/
benchmark_timer_initialize();
status = pthread_cond_broadcast(&CondID);
status = pthread_cond_broadcast( &CondID );
/* Should never reach this point */
rtems_test_assert( FALSE );
@@ -140,10 +135,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 + N
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 + N
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
@@ -26,25 +26,25 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
#if defined(USE_WAIT)
#if defined( USE_WAIT )
#define TEST_NUMBER "08"
#define TEST_CASE "pthread_cond_wait: blocking"
#elif defined(USE_TIMEDWAIT_WITH_VALUE)
#define TEST_CASE "pthread_cond_wait: blocking"
#elif defined( USE_TIMEDWAIT_WITH_VALUE )
#define TEST_NUMBER "09"
#define TEST_CASE "pthread_cond_timedwait: blocking"
#elif defined(USE_TIMEDWAIT_WAIT_VALUE_IN_PAST)
#define TEST_CASE "pthread_cond_timedwait: blocking"
#elif defined( USE_TIMEDWAIT_WAIT_VALUE_IN_PAST )
#define TEST_NUMBER "10"
#define TEST_CASE "pthread_cond_timedwait: time in past error"
#elif defined(USE_CLOCKWAIT_WITH_VALUE)
#define TEST_CASE "pthread_cond_timedwait: time in past error"
#elif defined( USE_CLOCKWAIT_WITH_VALUE )
#define TEST_NUMBER "11"
#define TEST_CASE "pthread_cond_clockwait: blocking"
#elif defined(USE_CLOCKWAIT_WAIT_VALUE_IN_PAST)
#define TEST_CASE "pthread_cond_clockwait: blocking"
#elif defined( USE_CLOCKWAIT_WAIT_VALUE_IN_PAST )
#define TEST_NUMBER "12"
#define TEST_CASE "pthread_cond_clockwait: time in past error"
#define TEST_CASE "pthread_cond_clockwait: time in past error"
#else
#error "How am I being compiled?"
#endif
@@ -68,18 +68,16 @@
const char rtems_test_name[] = "PSXTMCOND " TEST_NUMBER;
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_cond_t CondID;
pthread_mutex_t MutexID;
struct timespec sleepTime;
clockid_t clock_id;
clockid_t clock_id;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -87,13 +85,7 @@ void *Low(
end_time = benchmark_timer_read();
put_time(
TEST_CASE,
end_time,
OPERATION_COUNT,
0,
0
);
put_time( TEST_CASE, end_time, OPERATION_COUNT, 0, 0 );
TEST_END();
@@ -101,107 +93,102 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
int rc;
int rc;
rc = pthread_mutex_lock(&MutexID);
rc = pthread_mutex_lock( &MutexID );
rtems_test_assert( rc == 0 );
/* block and switch to another task here */
#if defined(USE_WAIT)
rc = pthread_cond_wait( &CondID, &MutexID );
rtems_test_assert( rc == 0 );
#if defined( USE_WAIT )
rc = pthread_cond_wait( &CondID, &MutexID );
rtems_test_assert( rc == 0 );
#elif defined(USE_TIMEDWAIT_WITH_VALUE)
/* adjust sleepTime to get something obviously in the future */
++sleepTime.tv_sec;
#elif defined( USE_TIMEDWAIT_WITH_VALUE )
/* adjust sleepTime to get something obviously in the future */
++sleepTime.tv_sec;
rc = pthread_cond_timedwait( &CondID, &MutexID, &sleepTime );
rtems_test_assert( rc == 0 );
#elif defined( USE_TIMEDWAIT_WAIT_VALUE_IN_PAST )
{
/* override sleepTime with something obviously in the past */
sleepTime.tv_sec = 0;
sleepTime.tv_nsec = 5;
/* this does all the work of timedwait but immediately returns */
rc = pthread_cond_timedwait( &CondID, &MutexID, &sleepTime );
rtems_test_assert( rc == 0 );
rtems_test_assert( rc == ETIMEDOUT );
benchmark_timer_read();
}
#elif defined( USE_CLOCKWAIT_WITH_VALUE )
/* adjust sleepTime to get something obviously in the future */
++sleepTime.tv_sec;
#elif defined(USE_TIMEDWAIT_WAIT_VALUE_IN_PAST)
{
/* override sleepTime with something obviously in the past */
sleepTime.tv_sec = 0;
sleepTime.tv_nsec = 5;
rc = pthread_cond_clockwait( &CondID, &MutexID, clock_id, &sleepTime );
rtems_test_assert( rc == 0 );
/* this does all the work of timedwait but immediately returns */
rc = pthread_cond_timedwait( &CondID, &MutexID, &sleepTime );
rtems_test_assert(rc == ETIMEDOUT);
benchmark_timer_read();
}
#elif defined(USE_CLOCKWAIT_WITH_VALUE)
/* adjust sleepTime to get something obviously in the future */
++sleepTime.tv_sec;
#elif defined( USE_CLOCKWAIT_WAIT_VALUE_IN_PAST )
{
/* override sleepTime with something obviously in the past */
sleepTime.tv_sec = 0;
sleepTime.tv_nsec = 5;
rc = pthread_cond_clockwait( &CondID, &MutexID, clock_id, &sleepTime );
rtems_test_assert( rc == 0 );
#elif defined(USE_CLOCKWAIT_WAIT_VALUE_IN_PAST)
{
/* override sleepTime with something obviously in the past */
sleepTime.tv_sec = 0;
sleepTime.tv_nsec = 5;
rc = pthread_cond_clockwait( &CondID, &MutexID, clock_id, &sleepTime );
rtems_test_assert(rc == ETIMEDOUT);
benchmark_timer_read();
}
rtems_test_assert( rc == ETIMEDOUT );
benchmark_timer_read();
}
#endif
pthread_mutex_unlock(&MutexID);
#if defined(USE_TIMEDWAIT_WAIT_VALUE_IN_PAST)
/*
pthread_mutex_unlock( &MutexID );
#if defined( USE_TIMEDWAIT_WAIT_VALUE_IN_PAST )
/*
* In this case, unlock does not switch to another thread. so we need
* to explicitly yield. If we do not yield, then we will measure the
* time required to do an implicit pthread_exit() which is undesirable
* from a measurement viewpoint.
*/
sched_yield();
sched_yield();
#endif
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int rc;
struct timeval tp;
int i;
int status;
pthread_t threadId;
int rc;
struct timeval tp;
TEST_BEGIN();
rc = gettimeofday(&tp, NULL);
rc = gettimeofday( &tp, NULL );
rtems_test_assert( rc == 0 );
/* Convert from timeval to timespec */
sleepTime.tv_sec = tp.tv_sec;
sleepTime.tv_sec = tp.tv_sec;
sleepTime.tv_nsec = tp.tv_usec * 1000;
clock_id = CLOCK_MONOTONIC;
rc = pthread_cond_init(&CondID, NULL);
rc = pthread_cond_init( &CondID, NULL );
rtems_test_assert( rc == 0 );
rc = pthread_mutex_init(&MutexID, NULL);
rc = pthread_mutex_init( &MutexID, NULL );
rtems_test_assert( rc == 0 );
rc = pthread_mutex_lock(&MutexID);
rc = pthread_mutex_lock( &MutexID );
rtems_test_assert( rc == 0 );
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -212,7 +199,7 @@ void *POSIX_Init(
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
rc = pthread_mutex_unlock(&MutexID);
rc = pthread_mutex_unlock( &MutexID );
rtems_test_assert( rc == 0 );
/* Should never return. */
@@ -224,11 +211,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+13 -15
View File
@@ -39,51 +39,49 @@
const char rtems_test_name[] = "PSXTMKEY 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
pthread_key_t Key;
static void benchmark_pthread_key_create(void)
static void benchmark_pthread_key_create( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_key_create(&Key, NULL);
status = pthread_key_create( &Key, NULL );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_key_create: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_key_delete(void)
static void benchmark_pthread_key_delete( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_key_delete(Key);
status = pthread_key_delete( Key );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_key_delete: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(void *argument)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -97,7 +95,7 @@ void *POSIX_Init(void *argument)
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -105,8 +103,8 @@ void *POSIX_Init(void *argument)
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+14 -17
View File
@@ -37,9 +37,9 @@
const char rtems_test_name[] = "PSXTMKEY 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void benchmark_pthread_setspecific(void *value_p);
void benchmark_pthread_getspecific( void *expected );
void *POSIX_Init( void *argument );
void benchmark_pthread_setspecific( void *value_p );
void benchmark_pthread_getspecific( void *expected );
pthread_key_t Key;
int Value1;
@@ -47,49 +47,46 @@ int Value1;
void benchmark_pthread_setspecific( void *value_p )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_setspecific( Key, value_p );
status = pthread_setspecific( Key, value_p );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_setspecific: only case: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void benchmark_pthread_getspecific( void *expected )
{
benchmark_timer_t end_time;
void *value_p;
void *value_p;
benchmark_timer_initialize();
value_p = pthread_getspecific( Key );
value_p = pthread_getspecific( Key );
end_time = benchmark_timer_read();
rtems_test_assert( value_p == expected );
put_time(
"pthread_getspecific: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
int status;
TEST_BEGIN();
@@ -106,7 +103,7 @@ void *POSIX_Init(
rtems_test_assert( status == 0 );
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -114,8 +111,8 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+99 -89
View File
@@ -36,284 +36,294 @@
#include "test_support.h"
#include <tmacros.h>
#include <mqueue.h>
#include <signal.h> /* signal facilities */
#include <signal.h> /* signal facilities */
const char rtems_test_name[] = "PSXTMMQ 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
#define MQ_MAXMSG 1
#define MQ_MSGSIZE sizeof(int)
#define MQ_MAXMSG 1
#define MQ_MSGSIZE sizeof( int )
mqd_t queue;
mqd_t queue2;
const char *q_name;
static void benchmark_mq_open(int printable)
static void benchmark_mq_open( int printable )
{
benchmark_timer_t end_time;
struct mq_attr attr;
struct mq_attr attr;
attr.mq_maxmsg = MQ_MAXMSG;
attr.mq_maxmsg = MQ_MAXMSG;
attr.mq_msgsize = MQ_MSGSIZE;
q_name= "queue";
q_name = "queue";
benchmark_timer_initialize();
queue = mq_open( q_name, O_CREAT | O_RDWR , 0x777, &attr );
queue = mq_open( q_name, O_CREAT | O_RDWR, 0x777, &attr );
end_time = benchmark_timer_read();
rtems_test_assert( (int) queue != (-1) );
rtems_test_assert( (int) queue != ( -1 ) );
if (printable == 1)
if ( printable == 1 ) {
put_time(
"mq_open: first open",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
}
static void benchmark_mq_open_second(int printable)
static void benchmark_mq_open_second( int printable )
{
benchmark_timer_t end_time;
struct mq_attr attr;
struct mq_attr attr;
attr.mq_maxmsg = MQ_MAXMSG;
attr.mq_maxmsg = MQ_MAXMSG;
attr.mq_msgsize = MQ_MSGSIZE;
benchmark_timer_initialize();
queue2 =mq_open( q_name, O_RDONLY | O_CREAT , 0x777, &attr);
queue2 = mq_open( q_name, O_RDONLY | O_CREAT, 0x777, &attr );
end_time = benchmark_timer_read();
rtems_test_assert( (int) queue2 != (-1) );
rtems_test_assert( (int) queue2 != ( -1 ) );
if (printable == 1)
if ( printable == 1 ) {
put_time(
"mq_open: second open",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
}
static void benchmark_mq_close(int printable)
static void benchmark_mq_close( int printable )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = mq_close(queue);
status = mq_close( queue );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
if (printable == 1)
if ( printable == 1 ) {
put_time(
"mq_close: close of first",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
}
static void benchmark_mq_close_second(int printable)
static void benchmark_mq_close_second( int printable )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = mq_close(queue2);
status = mq_close( queue2 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
if (printable == 1)
if ( printable == 1 ) {
put_time(
"mq_close: close of second",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
}
static void benchmark_mq_unlink(void)
static void benchmark_mq_unlink( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = mq_unlink(q_name);
status = mq_unlink( q_name );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"mq_unlink: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_mq_notify(void)
static void benchmark_mq_notify( void )
{
#if defined(RTEMS_POSIX_API)
#if defined( RTEMS_POSIX_API )
benchmark_timer_t end_time;
int status;
struct sigevent event;
int status;
struct sigevent event;
event.sigev_notify = SIGEV_SIGNAL;
event.sigev_signo = SIGUSR1;
event.sigev_signo = SIGUSR1;
benchmark_timer_initialize();
status = mq_notify( queue2, &event );
status = mq_notify( queue2, &event );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"mq_notify: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
#endif
}
static void benchmark_mq_send(void)
static void benchmark_mq_send( void )
{
benchmark_timer_t end_time;
int status;
int status;
status = 9;
benchmark_timer_initialize();
status = mq_send( queue, (const char *)&status, MQ_MSGSIZE, 1 );
status = mq_send( queue, (const char *) &status, MQ_MSGSIZE, 1 );
end_time = benchmark_timer_read();
rtems_test_assert( status != (-1) );
rtems_test_assert( status != ( -1 ) );
put_time(
"mq_send: no threads waiting",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_mq_receive(void)
static void benchmark_mq_receive( void )
{
benchmark_timer_t end_time;
int status;
unsigned int priority;
int message[MQ_MAXMSG];
priority = 1; /*priority low*/
int status;
unsigned int priority;
int message[ MQ_MAXMSG ];
priority = 1; /*priority low*/
benchmark_timer_initialize();
status = mq_receive( queue2, ( char *)message, MQ_MSGSIZE, &priority );
status = mq_receive( queue2, (char *) message, MQ_MSGSIZE, &priority );
end_time = benchmark_timer_read();
rtems_test_assert( status != (-1) );
rtems_test_assert( status != ( -1 ) );
put_time(
"mq_receive: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_mq_timedsend(void)
static void benchmark_mq_timedsend( void )
{
benchmark_timer_t end_time;
int status;
struct timespec timeout;
int status;
struct timespec timeout;
status = 5;
timeout.tv_sec = 0;
timeout.tv_sec = 0;
timeout.tv_nsec = 1;
benchmark_timer_initialize();
status = mq_timedsend(
queue, (const char *)&status, MQ_MSGSIZE, 1, &timeout);
status = mq_timedsend(
queue,
(const char *) &status,
MQ_MSGSIZE,
1,
&timeout
);
end_time = benchmark_timer_read();
rtems_test_assert( status != (-1) );
rtems_test_assert( status != ( -1 ) );
put_time(
"mq_timedsend: no threads waiting",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_mq_timedreceive(void)
static void benchmark_mq_timedreceive( void )
{
benchmark_timer_t end_time;
int status;
unsigned int priority;
struct timespec timeout;
int message[MQ_MAXMSG];
int status;
unsigned int priority;
struct timespec timeout;
int message[ MQ_MAXMSG ];
priority = 1; /*priority low*/
timeout.tv_sec = 0;
priority = 1; /*priority low*/
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
benchmark_timer_initialize();
status = mq_timedreceive(
queue2, ( char *)message, MQ_MSGSIZE, &priority, &timeout);
status = mq_timedreceive(
queue2,
(char *) message,
MQ_MSGSIZE,
&priority,
&timeout
);
end_time = benchmark_timer_read();
rtems_test_assert( status != (-1) );
rtems_test_assert( status != ( -1 ) );
put_time(
"mq_timedreceive: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
TEST_BEGIN();
/* create the first message queue READWRITE */
benchmark_mq_open(1);
benchmark_mq_open( 1 );
/* send message using first queue */
benchmark_mq_send();
/* open a second message queue READ ONLY */
benchmark_mq_open_second(1);
benchmark_mq_open_second( 1 );
/* receiving message using the seconde queue */
benchmark_mq_receive();
/* closing the second message queue */
benchmark_mq_close_second(0);
benchmark_mq_close_second( 0 );
/* unlinking the first queue */
benchmark_mq_unlink();
/* closing the first queue */
benchmark_mq_close(0);
benchmark_mq_close( 0 );
/* now repeat basically the same, but for the timed-send/receive */
/* open the first queue */
benchmark_mq_open(0);
benchmark_mq_open( 0 );
/* send message using the first queue */
benchmark_mq_timedsend();
/* open a second message queue READ ONLY */
benchmark_mq_open_second(0);
benchmark_mq_open_second( 0 );
/* receiving message using the seconde queue */
benchmark_mq_timedreceive();
/* calling notify */
benchmark_mq_notify();
/* closing the second message queue */
benchmark_mq_close_second(1);
benchmark_mq_close_second( 1 );
/* closing the first queue */
benchmark_mq_close(1);
benchmark_mq_close( 1 );
TEST_END();
rtems_test_exit(0);
TEST_END();
rtems_test_exit( 0 );
}
/* configuration information */
@@ -321,9 +331,9 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 2
#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 2
#define CONFIGURE_INIT
+22 -29
View File
@@ -30,35 +30,33 @@
const char rtems_test_name[] = "PSXTMMQRCVBLOCK 01";
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
#define MQ_MAXMSG 1
#define MQ_MSGSIZE sizeof(int)
#define MQ_MAXMSG 1
#define MQ_MSGSIZE sizeof( int )
mqd_t queue;
int message[MQ_MAXMSG];
mqd_t queue;
int message[ MQ_MAXMSG ];
const char *q_name;
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
int oflag= O_CREAT |O_RDWR;
pthread_t threadId;
int i;
int status;
int oflag = O_CREAT | O_RDWR;
pthread_t threadId;
struct mq_attr attr;
attr.mq_maxmsg = MQ_MAXMSG;
attr.mq_maxmsg = MQ_MAXMSG;
attr.mq_msgsize = MQ_MSGSIZE;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -66,36 +64,31 @@ void *POSIX_Init(
status = pthread_create( &threadId, NULL, Low, NULL );
rtems_test_assert( !status );
queue = mq_open( "queue" , oflag , 0x777, &attr );
queue = mq_open( "queue", oflag, 0x777, &attr );
/* let other threads run */
sched_yield();
/* now run the benchmark */
benchmark_timer_initialize();
status = mq_receive( queue, (char *)message , MQ_MSGSIZE, 0 );
status = mq_receive( queue, (char *) message, MQ_MSGSIZE, 0 );
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
sched_yield();
/* let other threads run */
/* let other threads run */
(void) mq_receive( queue, (char *)message , MQ_MSGSIZE, 0 );
(void) mq_receive( queue, (char *) message, MQ_MSGSIZE, 0 );
return NULL;
}
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -124,10 +117,10 @@ void *Low(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+36 -32
View File
@@ -42,40 +42,38 @@
const char rtems_test_name[] = "PSXTMMQRCVBLOCK 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
#define MQ_MAXMSG 1
#define MQ_MSGSIZE sizeof(int)
#define MQ_MAXMSG 1
#define MQ_MSGSIZE sizeof( int )
static mqd_t queue;
int message[MQ_MAXMSG];
const char *q_name;
unsigned int priority;
static mqd_t queue;
int message[ MQ_MAXMSG ];
const char *q_name;
unsigned int priority;
struct timespec timeout;
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
int oflag = O_CREAT |O_RDWR;
pthread_t threadId;
struct mq_attr attr;
int i;
int status;
int oflag = O_CREAT | O_RDWR;
pthread_t threadId;
struct mq_attr attr;
priority = 0;
timeout.tv_sec = 0;
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
attr.mq_maxmsg = MQ_MAXMSG;
attr.mq_maxmsg = MQ_MAXMSG;
attr.mq_msgsize = MQ_MSGSIZE;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -91,29 +89,35 @@ void *POSIX_Init(
/* now run the benchmark */
benchmark_timer_initialize();
status = mq_timedreceive(
queue, (char *)message, MQ_MSGSIZE, &priority, &timeout);
queue,
(char *) message,
MQ_MSGSIZE,
&priority,
&timeout
);
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
sched_yield();
/* let other threads run */
/* let other threads run */
(void) mq_timedreceive(
queue, (char *)message, MQ_MSGSIZE, &priority, &timeout);
(void) mq_timedreceive(
queue,
(char *) message,
MQ_MSGSIZE,
&priority,
&timeout
);
return NULL;
}
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -142,10 +146,10 @@ void *Low(
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+12 -26
View File
@@ -39,51 +39,37 @@
const char rtems_test_name[] = "PSXTMMUTEX 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
pthread_mutex_t MutexId;
static void test_mutex_create(void)
static void test_mutex_create( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_mutex_init( &MutexId, NULL );
status = pthread_mutex_init( &MutexId, NULL );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_mutex_init: only case",
end_time,
1,
0,
0
);
put_time( "pthread_mutex_init: only case", end_time, 1, 0, 0 );
}
static void test_mutex_destroy(void)
static void test_mutex_destroy( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_mutex_destroy( &MutexId );
status = pthread_mutex_destroy( &MutexId );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_mutex_destroy: only case",
end_time,
1,
0,
0
);
put_time( "pthread_mutex_destroy: only case", end_time, 1, 0, 0 );
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -94,7 +80,7 @@ void *POSIX_Init(
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -102,7 +88,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+16 -22
View File
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -44,15 +44,13 @@
const char rtems_test_name[] = "PSXTMMUTEX 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_mutex_t MutexId;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -64,7 +62,7 @@ void *Low(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
end_time = benchmark_timer_read();
@@ -82,9 +80,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -96,7 +92,7 @@ void *Middle(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
status = pthread_mutex_lock( &MutexId );
rtems_test_assert( !status );
@@ -104,19 +100,17 @@ void *Middle(
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -136,7 +130,7 @@ void *POSIX_Init(
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
@@ -151,10 +145,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+39 -72
View File
@@ -39,82 +39,64 @@
const char rtems_test_name[] = "PSXTMMUTEX 03";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void benchmark_mutex_lock_available(void);
void benchmark_mutex_unlock_no_threads_waiting(void);
void benchmark_mutex_trylock_available(void);
void benchmark_mutex_trylock_not_available(void);
void benchmark_mutex_timedlock_available(void);
void benchmark_mutex_clocklock_available_clockmonotonic(void);
void benchmark_mutex_clocklock_available_clockrealtime(void);
void *POSIX_Init( void *argument );
void benchmark_mutex_lock_available( void );
void benchmark_mutex_unlock_no_threads_waiting( void );
void benchmark_mutex_trylock_available( void );
void benchmark_mutex_trylock_not_available( void );
void benchmark_mutex_timedlock_available( void );
void benchmark_mutex_clocklock_available_clockmonotonic( void );
void benchmark_mutex_clocklock_available_clockrealtime( void );
pthread_mutex_t MutexId;
void benchmark_mutex_lock_available(void)
void benchmark_mutex_lock_available( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_mutex_lock( &MutexId );
status = pthread_mutex_lock( &MutexId );
end_time = benchmark_timer_read();
rtems_test_assert( !status );
put_time(
"pthread_mutex_lock: available",
end_time,
1,
0,
0
);
put_time( "pthread_mutex_lock: available", end_time, 1, 0, 0 );
}
void benchmark_mutex_unlock_no_threads_waiting(void)
void benchmark_mutex_unlock_no_threads_waiting( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_mutex_unlock( &MutexId );
status = pthread_mutex_unlock( &MutexId );
end_time = benchmark_timer_read();
rtems_test_assert( !status );
put_time(
"pthread_mutex_unlock: no threads waiting",
end_time,
1,
0,
0
);
put_time( "pthread_mutex_unlock: no threads waiting", end_time, 1, 0, 0 );
}
void benchmark_mutex_trylock_available(void)
void benchmark_mutex_trylock_available( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_mutex_trylock( &MutexId );
status = pthread_mutex_trylock( &MutexId );
end_time = benchmark_timer_read();
rtems_test_assert( !status );
put_time(
"pthread_mutex_trylock: available",
end_time,
1,
0,
0
);
put_time( "pthread_mutex_trylock: available", end_time, 1, 0, 0 );
}
void benchmark_mutex_trylock_not_available(void)
void benchmark_mutex_trylock_not_available( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_mutex_trylock( &MutexId );
/*
status = pthread_mutex_trylock( &MutexId );
/*
* it has to return a negative value
* because it try to lock a not available mutex
* so the assert call is make with status instead !status
@@ -122,41 +104,29 @@ void benchmark_mutex_trylock_not_available(void)
end_time = benchmark_timer_read();
rtems_test_assert( status );
put_time(
"pthread_mutex_trylock: not available",
end_time,
1,
0,
0
);
put_time( "pthread_mutex_trylock: not available", end_time, 1, 0, 0 );
}
void benchmark_mutex_timedlock_available(void)
void benchmark_mutex_timedlock_available( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_mutex_timedlock( &MutexId, 0 );
status = pthread_mutex_timedlock( &MutexId, 0 );
end_time = benchmark_timer_read();
rtems_test_assert( !status );
put_time(
"pthread_mutex_timedlock: available",
end_time,
1,
0,
0
);
put_time( "pthread_mutex_timedlock: available", end_time, 1, 0, 0 );
}
void benchmark_mutex_clocklock_available_clockmonotonic(void)
void benchmark_mutex_clocklock_available_clockmonotonic( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_mutex_clocklock( &MutexId, CLOCK_MONOTONIC, 0 );
status = pthread_mutex_clocklock( &MutexId, CLOCK_MONOTONIC, 0 );
end_time = benchmark_timer_read();
rtems_test_assert( !status );
@@ -169,13 +139,13 @@ void benchmark_mutex_clocklock_available_clockmonotonic(void)
);
}
void benchmark_mutex_clocklock_available_clockrealtime(void)
void benchmark_mutex_clocklock_available_clockrealtime( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_mutex_clocklock( &MutexId, CLOCK_REALTIME, 0 );
status = pthread_mutex_clocklock( &MutexId, CLOCK_REALTIME, 0 );
end_time = benchmark_timer_read();
rtems_test_assert( !status );
@@ -188,13 +158,11 @@ void benchmark_mutex_clocklock_available_clockrealtime(void)
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
int status;
TEST_BEGIN();
@@ -220,7 +188,6 @@ void *POSIX_Init(
benchmark_mutex_clocklock_available_clockrealtime();
benchmark_mutex_unlock_no_threads_waiting();
/*
* Destroy the mutex used in the tests
*/
@@ -229,7 +196,7 @@ void *POSIX_Init(
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -237,7 +204,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+18 -24
View File
@@ -41,16 +41,14 @@
const char rtems_test_name[] = "PSXTMMUTEX 04";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_mutex_t MutexId;
void *Low(
void *argument
)
{
void *Low( void *argument )
{
(void) argument;
benchmark_timer_t end_time;
@@ -61,7 +59,7 @@ void *Low(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
end_time = benchmark_timer_read();
@@ -79,9 +77,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -93,31 +89,29 @@ void *Middle(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
status = pthread_mutex_lock( &MutexId);
rtems_test_assert( !status ); /*this is important*/
status = pthread_mutex_lock( &MutexId );
rtems_test_assert( !status ); /*this is important*/
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
status = pthread_create( &threadId, NULL, Low, NULL );
rtems_test_assert( !status );
@@ -133,7 +127,7 @@ void *POSIX_Init(
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
@@ -148,7 +142,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+11 -15
View File
@@ -40,14 +40,12 @@
const char rtems_test_name[] = "PSXTMMUTEX 05";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Blocker(void *argument);
void *POSIX_Init( void *argument );
void *Blocker( void *argument );
pthread_mutex_t MutexId;
void *Blocker(
void *argument
)
void *Blocker( void *argument )
{
(void) argument;
@@ -58,21 +56,19 @@ void *Blocker(
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
pthread_t threadId;
int status;
pthread_t threadId;
benchmark_timer_t end_time;
TEST_BEGIN();
status = pthread_create( &threadId, NULL, Blocker, NULL );
rtems_test_assert( status == 0 );
/*
* Deliberately create the mutex after the threads. This way if the
* threads do run before we intend, they will get an error.
@@ -91,10 +87,10 @@ void *POSIX_Init(
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other thread run */
/* let other thread run */
benchmark_timer_initialize();
status = pthread_mutex_unlock( &MutexId );
status = pthread_mutex_unlock( &MutexId );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
@@ -117,10 +113,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+23 -30
View File
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -44,22 +44,20 @@
const char rtems_test_name[] = "PSXTMMUTEX 06";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_mutex_t MutexId;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
int status;
int status;
benchmark_timer_t end_time;
status = pthread_mutex_lock( &MutexId );
status = pthread_mutex_lock( &MutexId );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
@@ -77,9 +75,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -88,27 +84,25 @@ void *Middle(
status = pthread_mutex_lock( &MutexId );
rtems_test_assert( status == 0 );
/* thread switch occurs */
/* thread switch occurs */
status = pthread_mutex_unlock( &MutexId );
rtems_test_assert( status == 0 );
/* thread switch occurs */
/* thread switch occurs */
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
int i;
int status;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
TEST_BEGIN();
@@ -145,8 +139,7 @@ void *POSIX_Init(
* And create rest of threads as more important than we are. They
* will preempt us as they are created and block.
*/
for ( i=0 ; i < OPERATION_COUNT ; i++ ) {
for ( i = 0; i < OPERATION_COUNT; i++ ) {
param.sched_priority = 3 + i;
status = pthread_attr_setschedparam( &attr, &param );
rtems_test_assert( status == 0 );
@@ -154,7 +147,7 @@ void *POSIX_Init(
status = pthread_create(
&threadId,
&attr,
(i == OPERATION_COUNT - 1) ? Low : Middle,
( i == OPERATION_COUNT - 1 ) ? Low : Middle,
NULL
);
rtems_test_assert( status == 0 );
@@ -165,10 +158,10 @@ void *POSIX_Init(
*/
benchmark_timer_initialize();
status = pthread_mutex_unlock( &MutexId );
rtems_test_assert( status == 0 );
status = pthread_mutex_unlock( &MutexId );
rtems_test_assert( status == 0 );
/* thread switch occurs */
/* thread switch occurs */
return NULL;
}
@@ -177,10 +170,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+17 -20
View File
@@ -39,59 +39,57 @@
const char rtems_test_name[] = "PSXTMMUTEX 07";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void test_mutex_setprioceiling(void);
void test_mutex_getprioceiling(void);
void *POSIX_Init( void *argument );
void test_mutex_setprioceiling( void );
void test_mutex_getprioceiling( void );
pthread_mutex_t MutexId;
void test_mutex_setprioceiling(void)
void test_mutex_setprioceiling( void )
{
benchmark_timer_t end_time;
int status;
int old_ceiling;
int status;
int old_ceiling;
benchmark_timer_initialize();
status = pthread_mutex_setprioceiling( &MutexId, 5, &old_ceiling );
status = pthread_mutex_setprioceiling( &MutexId, 5, &old_ceiling );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_mutex_setprioceiling: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void test_mutex_getprioceiling(void)
void test_mutex_getprioceiling( void )
{
benchmark_timer_t end_time;
int status;
int current_ceiling;
int status;
int current_ceiling;
benchmark_timer_initialize();
status = pthread_mutex_getprioceiling( &MutexId, &current_ceiling );
status = pthread_mutex_getprioceiling( &MutexId, &current_ceiling );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_mutex_getprioceiling: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
int status;
TEST_BEGIN();
/* create mutex*/
@@ -108,16 +106,15 @@ void *POSIX_Init(
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+27 -40
View File
@@ -39,11 +39,11 @@
const char rtems_test_name[] = "PSXTMMUTEXATTR01";
/* forward declarations to avoid warnings */
static void *POSIX_Init(void *argument);
static void *POSIX_Init( void *argument );
static pthread_mutexattr_t attr;
static void benchmark_create_pthread_mutexattr(void)
static void benchmark_create_pthread_mutexattr( void )
{
benchmark_timer_t end_time;
int status;
@@ -56,56 +56,53 @@ static void benchmark_create_pthread_mutexattr(void)
put_time(
"pthread_mutexattr_init: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_mutexattr_setprioceiling(void)
static void benchmark_pthread_mutexattr_setprioceiling( void )
{
benchmark_timer_t end_time;
int status;
benchmark_timer_initialize();
status = pthread_mutexattr_setprioceiling( &attr, SCHED_FIFO);
status = pthread_mutexattr_setprioceiling( &attr, SCHED_FIFO );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_mutexattr_setprioceiling: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_mutexattr_getprioceiling(void)
static void benchmark_pthread_mutexattr_getprioceiling( void )
{
benchmark_timer_t end_time;
int status;
int prioceiling;
benchmark_timer_initialize();
status = pthread_mutexattr_getprioceiling( &attr, &prioceiling);
status = pthread_mutexattr_getprioceiling( &attr, &prioceiling );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
rtems_test_assert( prioceiling == SCHED_FIFO);
rtems_test_assert( prioceiling == SCHED_FIFO );
put_time(
"pthread_mutexattr_getprioceiling: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_mutexattr_setprotocol(void)
static void benchmark_pthread_mutexattr_setprotocol( void )
{
benchmark_timer_t end_time;
int status;
@@ -118,14 +115,13 @@ static void benchmark_pthread_mutexattr_setprotocol(void)
put_time(
"pthread_mutexattr_setprotocol: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_mutexattr_getprotocol(void)
static void benchmark_pthread_mutexattr_getprotocol( void )
{
benchmark_timer_t end_time;
int status;
@@ -140,14 +136,13 @@ static void benchmark_pthread_mutexattr_getprotocol(void)
put_time(
"pthread_mutexattr_getprotocol: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_mutexattr_setpshared(void)
static void benchmark_pthread_mutexattr_setpshared( void )
{
benchmark_timer_t end_time;
int status;
@@ -160,14 +155,13 @@ static void benchmark_pthread_mutexattr_setpshared(void)
put_time(
"pthread_mutexattr_setpshared: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_mutexattr_getpshared(void)
static void benchmark_pthread_mutexattr_getpshared( void )
{
benchmark_timer_t end_time;
int status;
@@ -182,14 +176,13 @@ static void benchmark_pthread_mutexattr_getpshared(void)
put_time(
"pthread_mutexattr_getpshared: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_mutexattr_settype(void)
static void benchmark_pthread_mutexattr_settype( void )
{
benchmark_timer_t end_time;
int status;
@@ -202,14 +195,13 @@ static void benchmark_pthread_mutexattr_settype(void)
put_time(
"pthread_mutexattr_settype: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_mutexattr_gettype(void)
static void benchmark_pthread_mutexattr_gettype( void )
{
benchmark_timer_t end_time;
int status;
@@ -224,14 +216,13 @@ static void benchmark_pthread_mutexattr_gettype(void)
put_time(
"pthread_mutexattr_gettype: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_destroy_pthread_mutexattr(void)
static void benchmark_destroy_pthread_mutexattr( void )
{
benchmark_timer_t end_time;
int status;
@@ -244,16 +235,13 @@ static void benchmark_destroy_pthread_mutexattr(void)
put_time(
"pthread_mutexattr_destroy: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -271,7 +259,7 @@ void *POSIX_Init(
benchmark_destroy_pthread_mutexattr();
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -279,8 +267,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
@@ -37,16 +37,14 @@
const char rtems_test_name[] = "PSXTMNANOSLEEP 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
benchmark_timer_t end_time;
struct timespec sleepTime;
struct timespec sleepTime;
sleepTime.tv_sec = 0;
sleepTime.tv_nsec = 0;
@@ -54,14 +52,14 @@ void *POSIX_Init(
TEST_BEGIN();
benchmark_timer_initialize();
nanosleep( &sleepTime, (struct timespec *) NULL );
nanosleep( &sleepTime, (struct timespec *) NULL );
end_time = benchmark_timer_read();
put_time( "nanosleep: yield", end_time, 1, 0, 0 );
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -69,7 +67,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+15 -27
View File
@@ -39,13 +39,11 @@
const char rtems_test_name[] = "PSXTMNANOSLEEP 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -53,13 +51,7 @@ void *Low(
end_time = benchmark_timer_read();
put_time(
"nanosleep: blocking",
end_time,
OPERATION_COUNT,
0,
0
);
put_time( "nanosleep: blocking", end_time, OPERATION_COUNT, 0, 0 );
TEST_END();
@@ -67,9 +59,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -78,20 +68,18 @@ void *Middle(
sleepTime.tv_sec = 0;
sleepTime.tv_nsec = 1;
nanosleep(&sleepTime, (struct timespec *) NULL);
nanosleep( &sleepTime, (struct timespec *) NULL );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
struct timespec sleepTime;
struct timespec remainder;
@@ -102,7 +90,7 @@ void *POSIX_Init(
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -113,7 +101,7 @@ void *POSIX_Init(
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
/* calling nanosleep*/
nanosleep(&sleepTime, &remainder);
nanosleep( &sleepTime, &remainder );
return NULL;
}
@@ -123,10 +111,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+6 -10
View File
@@ -39,11 +39,9 @@ const char rtems_test_name[] = "PSXTMONCE01";
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
static void initRoutine(void)
{
}
static void initRoutine( void ) {}
static void benchmark_first_time(void)
static void benchmark_first_time( void )
{
benchmark_timer_t end_time;
int status;
@@ -56,15 +54,13 @@ static void benchmark_first_time(void)
put_time(
"pthread_once: first time",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void *POSIX_Init(
void *argument
)
static void *POSIX_Init( void *argument )
{
(void) argument;
@@ -72,7 +68,7 @@ static void *POSIX_Init(
benchmark_first_time();
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -80,7 +76,7 @@ static void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+63 -71
View File
@@ -39,167 +39,162 @@
const char rtems_test_name[] = "PSXTMRWLOCK 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
pthread_rwlock_t rwlock;
pthread_rwlock_t rwlock;
static void benchmark_pthread_rwlock_init(void)
static void benchmark_pthread_rwlock_init( void )
{
benchmark_timer_t end_time;
int status;
benchmark_timer_t end_time;
int status;
pthread_rwlockattr_t attr;
pthread_rwlockattr_init( &attr );
benchmark_timer_initialize();
status = pthread_rwlock_init( &rwlock, &attr );
status = pthread_rwlock_init( &rwlock, &attr );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_rwlock_init: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_rwlock_rdlock(void)
static void benchmark_pthread_rwlock_rdlock( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_rdlock(&rwlock);
status = pthread_rwlock_rdlock( &rwlock );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_rwlock_rdlock: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_rwlock_unlock(int print)
static void benchmark_pthread_rwlock_unlock( int print )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_unlock(&rwlock);
status = pthread_rwlock_unlock( &rwlock );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
if ( print == 1 ){
if ( print == 1 ) {
put_time(
"pthread_rwlock_unlock: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
}
static void benchmark_pthread_rwlock_tryrdlock(void)
static void benchmark_pthread_rwlock_tryrdlock( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_tryrdlock(&rwlock);
status = pthread_rwlock_tryrdlock( &rwlock );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 || status == EBUSY );
if (status == EBUSY) {
if ( status == EBUSY ) {
put_time(
"pthread_rwlock_tryrdlock: not available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
} else if (status == 0) {
} else if ( status == 0 ) {
put_time(
"pthread_rwlock_tryrdlock: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
}
static void benchmark_pthread_rwlock_timedrdlock(void)
static void benchmark_pthread_rwlock_timedrdlock( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_timedrdlock(&rwlock, 0);
status = pthread_rwlock_timedrdlock( &rwlock, 0 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_rwlock_timedrdlock: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_rwlock_clockrdlock(void)
static void benchmark_pthread_rwlock_clockrdlock( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_clockrdlock( &rwlock, CLOCK_MONOTONIC, 0 );
status = pthread_rwlock_clockrdlock( &rwlock, CLOCK_MONOTONIC, 0 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_rwlock_clockrdlock: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_rwlock_wrlock(void)
static void benchmark_pthread_rwlock_wrlock( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_wrlock(&rwlock);
status = pthread_rwlock_wrlock( &rwlock );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_rwlock_wrlock: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_rwlock_trywrlock(void)
static void benchmark_pthread_rwlock_trywrlock( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_trywrlock(&rwlock);
status = pthread_rwlock_trywrlock( &rwlock );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 || status == EBUSY );
@@ -207,7 +202,7 @@ static void benchmark_pthread_rwlock_trywrlock(void)
put_time(
"pthread_rwlock_trywrlock: not available ",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
@@ -215,74 +210,71 @@ static void benchmark_pthread_rwlock_trywrlock(void)
put_time(
"pthread_rwlock_trywrlock: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
}
static void benchmark_pthread_rwlock_timedwrlock(void)
static void benchmark_pthread_rwlock_timedwrlock( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_timedwrlock(&rwlock,0);
status = pthread_rwlock_timedwrlock( &rwlock, 0 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_rwlock_timedwrlock: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_rwlock_clockwrlock(void)
static void benchmark_pthread_rwlock_clockwrlock( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_clockwrlock( &rwlock, CLOCK_MONOTONIC, 0 );
status = pthread_rwlock_clockwrlock( &rwlock, CLOCK_MONOTONIC, 0 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_rwlock_clockwrlock: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_pthread_rwlock_destroy(void)
static void benchmark_pthread_rwlock_destroy( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = pthread_rwlock_destroy(&rwlock);
status = pthread_rwlock_destroy( &rwlock );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"pthread_rwlock_destroy: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -293,45 +285,45 @@ void *POSIX_Init(
/* applying a read lock */
benchmark_pthread_rwlock_rdlock();
/* unlocking rwlock */
benchmark_pthread_rwlock_unlock(0);
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(0);
benchmark_pthread_rwlock_unlock( 0 );
/* applying a timed read lock */
benchmark_pthread_rwlock_timedrdlock();
/* unlocking rwlock */
benchmark_pthread_rwlock_unlock(0);
benchmark_pthread_rwlock_unlock( 0 );
/* applying a clock read lock */
benchmark_pthread_rwlock_clockrdlock();
/* unlocking rwlock */
benchmark_pthread_rwlock_unlock(0);
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(0);
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(0);
benchmark_pthread_rwlock_unlock( 0 );
/* applying a timed write lock */
benchmark_pthread_rwlock_timedwrlock();
/* unlocking rwlock */
benchmark_pthread_rwlock_unlock(0);
benchmark_pthread_rwlock_unlock( 0 );
/* applying a clock write lock */
benchmark_pthread_rwlock_clockwrlock();
/* unlocking rwlock */
benchmark_pthread_rwlock_unlock(1);
benchmark_pthread_rwlock_unlock( 1 );
/* destroying rwlock */
benchmark_pthread_rwlock_destroy();
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -339,7 +331,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+19 -25
View File
@@ -40,15 +40,13 @@
const char rtems_test_name[] = "PSXTMRWLOCK 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_rwlock_t rwlock;
pthread_rwlock_t rwlock;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -60,7 +58,7 @@ void *Low(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
end_time = benchmark_timer_read();
@@ -78,9 +76,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -92,28 +88,26 @@ void *Middle(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* this read lock operation will be blocked
* cause a write operation has the lock */
status = pthread_rwlock_rdlock(&rwlock);
status = pthread_rwlock_rdlock( &rwlock );
rtems_test_assert( status == 0 );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
pthread_rwlockattr_t attr;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -127,19 +121,19 @@ void *POSIX_Init(
*/
status = pthread_rwlockattr_init( &attr );
rtems_test_assert( status == 0 );
status = pthread_rwlock_init( &rwlock, &attr );
status = pthread_rwlock_init( &rwlock, &attr );
rtems_test_assert( status == 0 );
/*
* Let the other threads start so the thread startup overhead,
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
/* write lock operation */
status = pthread_rwlock_wrlock(&rwlock);
status = pthread_rwlock_wrlock( &rwlock );
rtems_test_assert( status == 0 );
return NULL;
}
@@ -149,10 +143,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+19 -25
View File
@@ -40,16 +40,14 @@
const char rtems_test_name[] = "PSXTMRWLOCK 03";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_rwlock_t rwlock;
struct timespec abstime;
pthread_rwlock_t rwlock;
struct timespec abstime;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -61,7 +59,7 @@ void *Low(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
end_time = benchmark_timer_read();
@@ -79,9 +77,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -93,29 +89,27 @@ void *Middle(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* this timed read lock operation will be blocked
* cause a write operation has the lock */
status = pthread_rwlock_timedrdlock(&rwlock, &abstime);
status = pthread_rwlock_timedrdlock( &rwlock, &abstime );
rtems_test_assert( status == 0 );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
pthread_rwlockattr_t attr;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -136,7 +130,7 @@ void *POSIX_Init(
*/
status = pthread_rwlockattr_init( &attr );
rtems_test_assert( status == 0 );
status = pthread_rwlock_init( &rwlock, &attr );
status = pthread_rwlock_init( &rwlock, &attr );
rtems_test_assert( status == 0 );
/*
@@ -144,7 +138,7 @@ void *POSIX_Init(
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
@@ -152,7 +146,7 @@ void *POSIX_Init(
/*
* Write lock operation, this could be any write lock
*/
status = pthread_rwlock_timedwrlock(&rwlock,0);
status = pthread_rwlock_timedwrlock( &rwlock, 0 );
rtems_test_assert( status == 0 );
return NULL;
}
@@ -162,7 +156,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+20 -26
View File
@@ -40,15 +40,13 @@
const char rtems_test_name[] = "PSXTMRWLOCK 04";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_rwlock_t rwlock;
pthread_rwlock_t rwlock;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -60,7 +58,7 @@ void *Low(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
end_time = benchmark_timer_read();
@@ -78,9 +76,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -92,33 +88,31 @@ void *Middle(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* this write lock operation will be blocked
* cause another write operation has the lock */
status = pthread_rwlock_wrlock(&rwlock);
status = pthread_rwlock_wrlock( &rwlock );
rtems_test_assert( status == 0 );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
pthread_rwlockattr_t attr;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
status = pthread_create( &threadId, NULL, Low, NULL );
rtems_test_assert( !status );
@@ -128,19 +122,19 @@ void *POSIX_Init(
*/
status = pthread_rwlockattr_init( &attr );
rtems_test_assert( status == 0 );
status = pthread_rwlock_init( &rwlock, &attr );
status = pthread_rwlock_init( &rwlock, &attr );
rtems_test_assert( status == 0 );
/*
* Let the other threads start so the thread startup overhead,
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
/* write lock operation */
status = pthread_rwlock_wrlock(&rwlock);
status = pthread_rwlock_wrlock( &rwlock );
rtems_test_assert( status == 0 );
return NULL;
}
@@ -150,7 +144,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+21 -28
View File
@@ -40,16 +40,14 @@
const char rtems_test_name[] = "PSXTMRWLOCK 05";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_rwlock_t rwlock;
struct timespec abstime;
pthread_rwlock_t rwlock;
struct timespec abstime;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -61,7 +59,7 @@ void *Low(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
end_time = benchmark_timer_read();
@@ -79,9 +77,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -93,34 +89,32 @@ void *Middle(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* This timed write lock operation will be blocked
* because the other write operation has the lock
*/
status = pthread_rwlock_timedwrlock(&rwlock, &abstime);
status = pthread_rwlock_timedwrlock( &rwlock, &abstime );
rtems_test_assert( status == 0 );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
pthread_rwlockattr_t attr;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
status = pthread_create( &threadId, NULL, Low, NULL );
rtems_test_assert( !status );
@@ -137,22 +131,21 @@ void *POSIX_Init(
*/
status = pthread_rwlockattr_init( &attr );
rtems_test_assert( status == 0 );
status = pthread_rwlock_init( &rwlock, &attr );
status = pthread_rwlock_init( &rwlock, &attr );
rtems_test_assert( status == 0 );
/*
* Let the other threads start so the thread startup overhead,
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
/* write lock operation, this could be any write lock
* I decided to use timedwrlock just to continue in the timed line */
status = pthread_rwlock_timedwrlock(&rwlock,0);
status = pthread_rwlock_timedwrlock( &rwlock, 0 );
rtems_test_assert( status == 0 );
return NULL;
}
@@ -162,10 +155,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+16 -20
View File
@@ -40,34 +40,30 @@
const char rtems_test_name[] = "PSXTMRWLOCK 06";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Blocker(void *argument);
void *POSIX_Init( void *argument );
void *Blocker( void *argument );
pthread_rwlock_t rwlock;
pthread_rwlock_t rwlock;
void *Blocker(
void *argument
)
void *Blocker( void *argument )
{
(void) argument;
(void) pthread_rwlock_wrlock(&rwlock);
(void) pthread_rwlock_wrlock( &rwlock );
/* should never return */
rtems_test_assert( FALSE );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
pthread_t threadId;
benchmark_timer_t end_time;
pthread_rwlockattr_t attr;
int status;
pthread_t threadId;
benchmark_timer_t end_time;
pthread_rwlockattr_t attr;
TEST_BEGIN();
@@ -79,7 +75,7 @@ void *POSIX_Init(
*/
/* creating rwlock */
status = pthread_rwlockattr_init( &attr );
status = pthread_rwlockattr_init( &attr );
rtems_test_assert( status == 0 );
status = pthread_rwlock_init( &rwlock, &attr );
rtems_test_assert( status == 0 );
@@ -88,7 +84,7 @@ void *POSIX_Init(
* Ensure the rwlock is unavailable so the other threads block.
*/
/* lock rwlock to ensure thread blocks */
status = pthread_rwlock_wrlock(&rwlock);
status = pthread_rwlock_wrlock( &rwlock );
rtems_test_assert( status == 0 );
/*
@@ -96,10 +92,10 @@ void *POSIX_Init(
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other thread run */
/* let other thread run */
benchmark_timer_initialize();
status = pthread_rwlock_unlock(&rwlock); /* unlock the rwlock */
status = pthread_rwlock_unlock( &rwlock ); /* unlock the rwlock */
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
@@ -122,10 +118,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+24 -31
View File
@@ -40,23 +40,21 @@
const char rtems_test_name[] = "PSXTMRWLOCK 07";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
pthread_rwlock_t rwlock;
pthread_rwlock_t rwlock;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
int status;
int status;
benchmark_timer_t end_time;
/* write locking */
status = pthread_rwlock_wrlock(&rwlock);
status = pthread_rwlock_wrlock( &rwlock );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
@@ -74,40 +72,36 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
int status;
/* write locking */
status = pthread_rwlock_wrlock(&rwlock);
status = pthread_rwlock_wrlock( &rwlock );
rtems_test_assert( status == 0 );
/* thread switch occurs */
/* thread switch occurs */
status = pthread_rwlock_unlock(&rwlock); /* unlock the rwlock */
status = pthread_rwlock_unlock( &rwlock ); /* unlock the rwlock */
rtems_test_assert( status == 0 );
/* thread switch occurs */
/* thread switch occurs */
/* should never return */
rtems_test_assert( FALSE );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
int i;
int status;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
pthread_rwlockattr_t rw_attr;
TEST_BEGIN();
@@ -124,7 +118,7 @@ void *POSIX_Init(
/*
* Obtain the lock so the threads will block.
*/
status = pthread_rwlock_wrlock(&rwlock);
status = pthread_rwlock_wrlock( &rwlock );
rtems_test_assert( status == 0 );
/*
@@ -147,8 +141,7 @@ void *POSIX_Init(
* And create rest of threads as more important than we are. They
* will preempt us as they are created and block.
*/
for ( i=0 ; i < OPERATION_COUNT ; i++ ) {
for ( i = 0; i < OPERATION_COUNT; i++ ) {
param.sched_priority = 3 + i;
status = pthread_attr_setschedparam( &attr, &param );
rtems_test_assert( status == 0 );
@@ -156,7 +149,7 @@ void *POSIX_Init(
status = pthread_create(
&threadId,
&attr,
(i == OPERATION_COUNT - 1) ? Low : Middle,
( i == OPERATION_COUNT - 1 ) ? Low : Middle,
NULL
);
rtems_test_assert( status == 0 );
@@ -168,8 +161,8 @@ void *POSIX_Init(
*/
benchmark_timer_initialize();
status = pthread_rwlock_unlock(&rwlock);
/* thread switch occurs */
status = pthread_rwlock_unlock( &rwlock );
/* thread switch occurs */
/* should never return */
rtems_test_assert( FALSE );
@@ -181,7 +174,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+41 -41
View File
@@ -41,78 +41,78 @@
const char rtems_test_name[] = "PSXTMSEM 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
#define MAX_SEMS 2
#define MAX_SEMS 2
sem_t sem1;
sem_t *n_sem1;
sem_t *n_sem2;
sem_t sem1;
sem_t *n_sem1;
sem_t *n_sem2;
static void benchmark_sem_init(void)
static void benchmark_sem_init( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = sem_init( &sem1, 0, 1 );
status = sem_init( &sem1, 0, 1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_init: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_sem_destroy(void)
static void benchmark_sem_destroy( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = sem_destroy( &sem1 );
status = sem_destroy( &sem1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_destroy: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_sem_open(bool report_time)
static void benchmark_sem_open( bool report_time )
{
benchmark_timer_t end_time;
benchmark_timer_initialize();
n_sem1 = sem_open( "sem1", O_CREAT, 0777, 1 );
n_sem1 = sem_open( "sem1", O_CREAT, 0777, 1 );
end_time = benchmark_timer_read();
if ( report_time ) {
put_time(
"sem_open: first open O_CREAT",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
}
static void benchmark_sem_close(bool report_time)
static void benchmark_sem_close( bool report_time )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = sem_close( n_sem1 );
status = sem_close( n_sem1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
@@ -120,69 +120,69 @@ static void benchmark_sem_close(bool report_time)
put_time(
"sem_close: named first/nested close",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
}
static void benchmark_sem_unlink(const char *message)
static void benchmark_sem_unlink( const char *message )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = sem_unlink( "sem1" );
status = sem_unlink( "sem1" );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
message,
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_sem_open_second(void)
static void benchmark_sem_open_second( void )
{
benchmark_timer_t end_time;
benchmark_timer_initialize();
n_sem2 = sem_open( "sem1", O_EXCL, 0777, 1 );
n_sem2 = sem_open( "sem1", O_EXCL, 0777, 1 );
end_time = benchmark_timer_read();
put_time(
"sem_open: second open O_EXCL",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_sem_close_second(void)
static void benchmark_sem_close_second( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = sem_close( n_sem2 );
status = sem_close( n_sem2 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_close: named second close",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(void *argument)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -194,24 +194,24 @@ void *POSIX_Init(void *argument)
benchmark_sem_destroy();
/* opening named semaphore first time o_flag = O_CREAT */
benchmark_sem_open(true);
benchmark_sem_open( true );
/* opening named semaphore second time o_flag = O_EXCL */
benchmark_sem_open_second();
/* close named semaphore first time -- does not delete */
benchmark_sem_close(true);
benchmark_sem_close( true );
/* unlink named semaphore -- does not delete */
benchmark_sem_unlink("sem_unlink: does not delete");
benchmark_sem_unlink( "sem_unlink: does not delete" );
/* close semaphore the second time, this actually deletes it */
benchmark_sem_close_second();
/* recrate named semaphore first time o_flag = O_CREAT */
benchmark_sem_open(false);
benchmark_sem_close(false);
benchmark_sem_unlink("sem_unlink: deletes semaphore");
benchmark_sem_open( false );
benchmark_sem_close( false );
benchmark_sem_unlink( "sem_unlink: deletes semaphore" );
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -219,8 +219,8 @@ void *POSIX_Init(void *argument)
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES MAX_SEMS
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES MAX_SEMS
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+28 -28
View File
@@ -41,95 +41,95 @@
const char rtems_test_name[] = "PSXTMSEM 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
sem_t sem1;
sem_t *n_sem1;
sem_t sem1;
sem_t *n_sem1;
static void benchmark_sem_getvalue(void)
static void benchmark_sem_getvalue( void )
{
benchmark_timer_t end_time;
int status;
int value;
int status;
int value;
benchmark_timer_initialize();
status = sem_getvalue(&sem1, &value);
status = sem_getvalue( &sem1, &value );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_getvalue: only case",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_sem_wait(void)
static void benchmark_sem_wait( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = sem_wait(&sem1);
status = sem_wait( &sem1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_wait: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_sem_post(void)
static void benchmark_sem_post( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = sem_post(&sem1);
status = sem_post( &sem1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_post: no threads waiting",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_sem_trywait_available(void)
static void benchmark_sem_trywait_available( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = sem_trywait(&sem1);
status = sem_trywait( &sem1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_trywait: available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
static void benchmark_sem_trywait_not_available(void)
static void benchmark_sem_trywait_not_available( void )
{
benchmark_timer_t end_time;
int status;
int status;
benchmark_timer_initialize();
status = sem_trywait(&sem1);
status = sem_trywait( &sem1 );
end_time = benchmark_timer_read();
/*it must be non avalible, so status should be non zero*/
rtems_test_assert( status != 0 );
@@ -137,13 +137,13 @@ static void benchmark_sem_trywait_not_available(void)
put_time(
"sem_trywait: not available",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(void *argument)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -168,10 +168,10 @@ void *POSIX_Init(void *argument)
TEST_END();
/*Destroying the semaphore*/
status = sem_destroy(&sem1);
status = sem_destroy( &sem1 );
rtems_test_assert( status == 0 );
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -179,7 +179,7 @@ void *POSIX_Init(void *argument)
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+23 -35
View File
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -47,17 +47,15 @@
const char rtems_test_name[] = "PSXTMSEM 03";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
#define MAX_SEMS 2
#define MAX_SEMS 2
sem_t sem1;
sem_t sem1;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -69,17 +67,11 @@ void *Low(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
end_time = benchmark_timer_read();
put_time(
"sem_wait: not available block",
end_time,
OPERATION_COUNT,
0,
0
);
put_time( "sem_wait: not available block", end_time, OPERATION_COUNT, 0, 0 );
TEST_END();
@@ -87,9 +79,7 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -99,26 +89,24 @@ void *Middle(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
(void) sem_wait( &sem1 );
rtems_test_assert( FALSE );
(void) sem_wait( &sem1 );
rtems_test_assert( FALSE );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( status == 0 );
}
@@ -130,7 +118,7 @@ void *POSIX_Init(
* Deliberately create the semaphore after the threads. This way if the
* threads do run before we intend, they will get an error.
*/
status = sem_init( &sem1, 0, 1 );
status = sem_init( &sem1, 0, 1 );
rtems_test_assert( status == 0 );
/*
@@ -138,11 +126,11 @@ void *POSIX_Init(
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
status = sem_wait(&sem1);
status = sem_wait( &sem1 );
rtems_test_assert( status == 0 );
return NULL;
}
@@ -152,10 +140,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+17 -23
View File
@@ -43,38 +43,38 @@
const char rtems_test_name[] = "PSXTMSEM 04";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Blocker(void *argument);
void *POSIX_Init( void *argument );
void *Blocker( void *argument );
#define MAX_SEMS 2
#define MAX_SEMS 2
sem_t sem1;
sem_t *n_sem1;
sem_t sem1;
sem_t *n_sem1;
void *Blocker( void *argument)
void *Blocker( void *argument )
{
(void) argument;
(void) sem_wait(&sem1);
(void) sem_wait( &sem1 );
/* should never return */
rtems_test_assert( FALSE );
return NULL;
}
void *POSIX_Init(void *argument)
void *POSIX_Init( void *argument )
{
(void) argument;
int status;
pthread_t threadId;
int status;
pthread_t threadId;
benchmark_timer_t end_time;
TEST_BEGIN();
status = pthread_create( &threadId, NULL, Blocker, NULL );
rtems_test_assert( status == 0 );
/*
* Deliberately create the semaphore after the threads. This way if the
* threads do run before we intend, they will get an error.
@@ -86,7 +86,7 @@ void *POSIX_Init(void *argument)
* Ensure the semaphore is unavailable so the other threads block.
* Lock semaphore resource to ensure thread blocks.
*/
status = sem_wait(&sem1);
status = sem_wait( &sem1 );
rtems_test_assert( status == 0 );
/*
@@ -94,20 +94,14 @@ void *POSIX_Init(void *argument)
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other thread run */
/* let other thread run */
benchmark_timer_initialize();
status = sem_post( &sem1 ); /* semaphore unblocking operation */
status = sem_post( &sem1 ); /* semaphore unblocking operation */
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_post: thread waiting no preempt",
end_time,
1,
0,
0
);
put_time( "sem_post: thread waiting no preempt", end_time, 1, 0, 0 );
TEST_END();
rtems_test_exit( 0 );
@@ -120,10 +114,10 @@ void *POSIX_Init(void *argument)
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+26 -33
View File
@@ -43,24 +43,22 @@
const char rtems_test_name[] = "PSXTMSEM 05";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
#define MAX_SEMS 2
#define MAX_SEMS 2
sem_t sem1;
sem_t sem1;
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
int status;
int status;
benchmark_timer_t end_time;
status = sem_wait(&sem1); /* semaphore blocks */
status = sem_wait( &sem1 ); /* semaphore blocks */
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
@@ -78,40 +76,36 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
int status;
status = sem_wait(&sem1); /* semaphore blocks */
status = sem_wait( &sem1 ); /* semaphore blocks */
rtems_test_assert( status == 0 );
/* thread switch occurs */
/* thread switch occurs */
status = sem_post(&sem1);
status = sem_post( &sem1 );
rtems_test_assert( status == 0 );
/* thread switch occurs */
/* thread switch occurs */
/* should never return */
rtems_test_assert( FALSE );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
int i;
int status;
pthread_t threadId;
pthread_attr_t attr;
struct sched_param param;
TEST_BEGIN();
@@ -148,8 +142,7 @@ void *POSIX_Init(
* And create rest of threads as more important than we are. They
* will preempt us as they are created and block.
*/
for ( i=0 ; i < OPERATION_COUNT ; i++ ) {
for ( i = 0; i < OPERATION_COUNT; i++ ) {
param.sched_priority = 3 + i;
status = pthread_attr_setschedparam( &attr, &param );
rtems_test_assert( status == 0 );
@@ -157,20 +150,20 @@ void *POSIX_Init(
status = pthread_create(
&threadId,
&attr,
(i == OPERATION_COUNT - 1) ? Low : Middle,
( i == OPERATION_COUNT - 1 ) ? Low : Middle,
NULL
);
rtems_test_assert( status == 0 );
}
/*
* Now start the timer which will be stopped in Low.
* Release the semaphore so threads unblock and preempt.
*/
benchmark_timer_initialize();
status = sem_post( &sem1 );
/* thread switch occurs */
status = sem_post( &sem1 );
/* thread switch occurs */
/* should never return */
rtems_test_assert( FALSE );
@@ -182,10 +175,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+6 -14
View File
@@ -39,11 +39,9 @@
const char rtems_test_name[] = "PSXTMSLEEP 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init( void *argument );
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -52,20 +50,14 @@ void *POSIX_Init(
TEST_BEGIN();
benchmark_timer_initialize();
sleep(0);
sleep( 0 );
end_time = benchmark_timer_read();
put_time(
"sleep: yield",
end_time,
1,
0,
0
);
put_time( "sleep: yield", end_time, 1, 0, 0 );
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -73,7 +65,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+15 -27
View File
@@ -39,13 +39,11 @@
const char rtems_test_name[] = "PSXTMSLEEP 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -53,13 +51,7 @@ void *Low(
end_time = benchmark_timer_read();
put_time(
"sleep: blocking",
end_time,
OPERATION_COUNT,
0,
0
);
put_time( "sleep: blocking", end_time, OPERATION_COUNT, 0, 0 );
TEST_END();
@@ -67,29 +59,25 @@ void *Low(
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
sleep(1);
sleep( 1 );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
@@ -99,7 +87,7 @@ void *POSIX_Init(
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
sleep(1);
sleep( 1 );
return NULL;
}
@@ -108,10 +96,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */
+8 -17
View File
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(OPERATION_COUNT)
#if !defined( OPERATION_COUNT )
#define OPERATION_COUNT 100
#endif
@@ -43,25 +43,19 @@
const char rtems_test_name[] = "PSXTMTHREAD 01";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *TestThread(void *argument);
void *POSIX_Init( void *argument );
void *TestThread( void *argument );
pthread_t ThreadId;
void *TestThread(
void *argument
)
void *TestThread( void *argument )
{
(void) argument;
return NULL;
}
static void benchmark_pthread_create(
int iteration,
void *argument
)
static void benchmark_pthread_create( int iteration, void *argument )
{
(void) iteration;
(void) argument;
@@ -72,9 +66,7 @@ static void benchmark_pthread_create(
rtems_test_assert( !status );
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -88,10 +80,9 @@ void *POSIX_Init(
0
);
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -99,7 +90,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+18 -22
View File
@@ -39,38 +39,36 @@
const char rtems_test_name[] = "PSXTMTHREAD 02";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void benchmark_pthread_create(void);
void *thread(void *argument);
void *POSIX_Init( void *argument );
void benchmark_pthread_create( void );
void *thread( void *argument );
void benchmark_pthread_create(void)
void benchmark_pthread_create( void )
{
int status;
pthread_t thread_ID;
pthread_attr_t attr;
int status;
pthread_t thread_ID;
pthread_attr_t attr;
struct sched_param param;
status = pthread_attr_init(&attr);
status = pthread_attr_init( &attr );
rtems_test_assert( status == 0 );
status = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
rtems_test_assert( status == 0 );
status = pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
status = pthread_attr_setschedpolicy( &attr, SCHED_FIFO );
rtems_test_assert( status == 0 );
param.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1;
status = pthread_attr_setschedparam(&attr, &param);
param.sched_priority = sched_get_priority_max( SCHED_FIFO ) - 1;
status = pthread_attr_setschedparam( &attr, &param );
rtems_test_assert( status == 0 );
/* create second thread with max priority and get preempted on creation */
benchmark_timer_initialize();
status = pthread_create(&thread_ID, &attr, thread, NULL);
status = pthread_create( &thread_ID, &attr, thread, NULL );
}
void *thread(
void *argument
)
void *thread( void *argument )
{
(void) argument;
@@ -80,16 +78,14 @@ void *thread(
put_time(
"pthread_create: preempt",
end_time,
1, /* Only executed once */
1, /* Only executed once */
0,
0
);
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
@@ -98,7 +94,7 @@ void *POSIX_Init(
benchmark_pthread_create();
TEST_END();
rtems_test_exit(0);
rtems_test_exit( 0 );
}
/* configuration information */
@@ -106,7 +102,7 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
+17 -29
View File
@@ -40,13 +40,11 @@
const char rtems_test_name[] = "PSXTMTHREAD 03";
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *Middle(void *argument);
void *Low(void *argument);
void *POSIX_Init( void *argument );
void *Middle( void *argument );
void *Low( void *argument );
void *Low(
void *argument
)
void *Low( void *argument )
{
(void) argument;
@@ -58,26 +56,18 @@ void *Low(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
end_time = benchmark_timer_read();
put_time(
"pthread_exit: only case",
end_time,
OPERATION_COUNT,
0,
0
);
put_time( "pthread_exit: only case", end_time, OPERATION_COUNT, 0, 0 );
TEST_END();
rtems_test_exit( 0 );
return NULL;
}
void *Middle(
void *argument
)
void *Middle( void *argument )
{
(void) argument;
@@ -87,29 +77,27 @@ void *Middle(
* finish the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
pthread_exit( NULL );
return NULL;
}
void *POSIX_Init(
void *argument
)
void *POSIX_Init( void *argument )
{
(void) argument;
int i;
int status;
pthread_t threadId;
int i;
int status;
pthread_t threadId;
TEST_BEGIN();
for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
for ( i = 0; i < OPERATION_COUNT - 1; i++ ) {
status = pthread_create( &threadId, NULL, Middle, NULL );
rtems_test_assert( !status );
}
status = pthread_create( &threadId, NULL, Low, NULL );
rtems_test_assert( !status );
@@ -118,7 +106,7 @@ void *POSIX_Init(
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other threads run */
/* let other threads run */
/* start the timer and switch through all the other tasks */
benchmark_timer_initialize();
@@ -131,10 +119,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_MAXIMUM_POSIX_THREADS OPERATION_COUNT + 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
/* end of file */

Some files were not shown because too many files have changed in this diff Show More