added test cases for errors in sched_get_priority_min and

sched_get_priority_max.

added test case for sched_yield.
This commit is contained in:
Joel Sherrill
1996-08-09 18:47:38 +00:00
parent 8699a7008e
commit f643e23046
2 changed files with 60 additions and 10 deletions

View File

@@ -14,7 +14,6 @@
#include "system.h" #include "system.h"
#include <sched.h> #include <sched.h>
void *POSIX_Init( void *POSIX_Init(
void *argument void *argument
) )
@@ -90,18 +89,28 @@ void *POSIX_Init(
Init_id = pthread_self(); Init_id = pthread_self();
printf( "Init: ID is 0x%08x\n", Init_id ); printf( "Init: ID is 0x%08x\n", Init_id );
/* print the minimum priority */ /* exercise get minimum priority */
priority = sched_get_priority_min( SCHED_FIFO ); priority = sched_get_priority_min( SCHED_FIFO );
printf( "Init: Minimum priority for FIFO is %d\n", priority ); printf( "Init: sched_get_priority_min (SCHED_FIFO) -- %d\n", priority );
assert( priority != -1 ); assert( priority != -1 );
/* print the maximum priority */ puts( "Init: sched_get_priority_min -- EINVAL (invalid policy)" );
priority = sched_get_priority_min( -1 );
assert( priority == -1 );
assert( errno == EINVAL );
/* exercise get maximum priority */
priority = sched_get_priority_max( SCHED_FIFO ); priority = sched_get_priority_max( SCHED_FIFO );
printf( "Init: Maximum priority for FIFO is %d\n", priority ); printf( "Init: sched_get_priority_max (SCHED_FIFO) -- %d\n", priority );
assert( priority != -1 ); assert( priority != -1 );
puts( "Init: sched_get_priority_min -- EINVAL (invalid policy)" );
priority = sched_get_priority_min( -1 );
assert( priority == -1 );
assert( errno == EINVAL );
/* print the round robin time quantum */ /* print the round robin time quantum */
status = sched_rr_get_interval( getpid(), &tr ); status = sched_rr_get_interval( getpid(), &tr );
@@ -114,12 +123,28 @@ void *POSIX_Init(
/* create a thread */ /* create a thread */
puts( "Init: pthread_create - SUCCESSFUL" );
status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL ); status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL );
assert( !status ); assert( !status );
/* too may threads error */
puts( "Init: pthread_create - EINVAL (too many threads)" );
status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL );
assert( status == EINVAL );
puts( "Init: sched_yield to Task_1" );
status = sched_yield();
assert( !status );
/* switch to Task_1 */
/* exit this thread */ /* exit this thread */
puts( "Init: pthread_exit" );
pthread_exit( NULL ); pthread_exit( NULL );
/* switch to Task_1 */
return NULL; /* just so the compiler thinks we returned something */ return NULL; /* just so the compiler thinks we returned something */
} }

View File

@@ -14,7 +14,6 @@
#include "system.h" #include "system.h"
#include <sched.h> #include <sched.h>
void *POSIX_Init( void *POSIX_Init(
void *argument void *argument
) )
@@ -90,18 +89,28 @@ void *POSIX_Init(
Init_id = pthread_self(); Init_id = pthread_self();
printf( "Init: ID is 0x%08x\n", Init_id ); printf( "Init: ID is 0x%08x\n", Init_id );
/* print the minimum priority */ /* exercise get minimum priority */
priority = sched_get_priority_min( SCHED_FIFO ); priority = sched_get_priority_min( SCHED_FIFO );
printf( "Init: Minimum priority for FIFO is %d\n", priority ); printf( "Init: sched_get_priority_min (SCHED_FIFO) -- %d\n", priority );
assert( priority != -1 ); assert( priority != -1 );
/* print the maximum priority */ puts( "Init: sched_get_priority_min -- EINVAL (invalid policy)" );
priority = sched_get_priority_min( -1 );
assert( priority == -1 );
assert( errno == EINVAL );
/* exercise get maximum priority */
priority = sched_get_priority_max( SCHED_FIFO ); priority = sched_get_priority_max( SCHED_FIFO );
printf( "Init: Maximum priority for FIFO is %d\n", priority ); printf( "Init: sched_get_priority_max (SCHED_FIFO) -- %d\n", priority );
assert( priority != -1 ); assert( priority != -1 );
puts( "Init: sched_get_priority_min -- EINVAL (invalid policy)" );
priority = sched_get_priority_min( -1 );
assert( priority == -1 );
assert( errno == EINVAL );
/* print the round robin time quantum */ /* print the round robin time quantum */
status = sched_rr_get_interval( getpid(), &tr ); status = sched_rr_get_interval( getpid(), &tr );
@@ -114,12 +123,28 @@ void *POSIX_Init(
/* create a thread */ /* create a thread */
puts( "Init: pthread_create - SUCCESSFUL" );
status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL ); status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL );
assert( !status ); assert( !status );
/* too may threads error */
puts( "Init: pthread_create - EINVAL (too many threads)" );
status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL );
assert( status == EINVAL );
puts( "Init: sched_yield to Task_1" );
status = sched_yield();
assert( !status );
/* switch to Task_1 */
/* exit this thread */ /* exit this thread */
puts( "Init: pthread_exit" );
pthread_exit( NULL ); pthread_exit( NULL );
/* switch to Task_1 */
return NULL; /* just so the compiler thinks we returned something */ return NULL; /* just so the compiler thinks we returned something */
} }