diff options
Diffstat (limited to 'c/src/tests/sptests/sp04')
-rw-r--r-- | c/src/tests/sptests/sp04/init.c | 113 | ||||
-rw-r--r-- | c/src/tests/sptests/sp04/sp04.doc | 38 | ||||
-rw-r--r-- | c/src/tests/sptests/sp04/sp04.scn | 24 | ||||
-rw-r--r-- | c/src/tests/sptests/sp04/system.h | 30 | ||||
-rw-r--r-- | c/src/tests/sptests/sp04/task1.c | 104 | ||||
-rw-r--r-- | c/src/tests/sptests/sp04/task2.c | 29 | ||||
-rw-r--r-- | c/src/tests/sptests/sp04/task3.c | 29 | ||||
-rw-r--r-- | c/src/tests/sptests/sp04/tswitch.c | 59 |
8 files changed, 426 insertions, 0 deletions
diff --git a/c/src/tests/sptests/sp04/init.c b/c/src/tests/sptests/sp04/init.c new file mode 100644 index 0000000000..b9fd541103 --- /dev/null +++ b/c/src/tests/sptests/sp04/init.c @@ -0,0 +1,113 @@ +/* Init + * + * This routine is the initialization task for this test program. + * It is a user initialization task and has the responsibility for creating + * and starting the tasks that make up the test. If the time of day + * clock is required for the test, it should also be set to a known + * value by this function. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" +#undef EXTERN +#define EXTERN +#include "conftbl.h" +#include "gvar.h" + +rtems_extensions_table Extensions = { + NULL, /* task create user extension */ + NULL, /* task start user extension */ + NULL, /* task restart user extension */ + NULL, /* task delete user extension */ + Task_switch, /* task switch user extension */ + NULL, /* task begin user extension */ + NULL, /* task exitted user extension */ + NULL /* fatal error user extension */ +}; + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_time_of_day time; + + puts( "\n\n*** TEST 4 ***" ); + build_time( &time, 12, 31, 1988, 9, 15, 0, 0 ); + + status = rtems_clock_set( &time ); + directive_failed( status, "rtems_clock_set" ); + + Extension_name[ 1 ] = rtems_build_name( 'E', 'X', 'T', ' ' ); + + status = rtems_extension_create( + Extension_name[ 1 ], + &Extensions, + &Extension_id[ 1 ] + ); + directive_failed( status, "rtems_extension_create" ); + + Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); + Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); + Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); + + Run_count[ 1 ] = 0; + Run_count[ 2 ] = 0; + Run_count[ 3 ] = 0; + + status = rtems_task_create( + Task_name[ 1 ], + 1, + 2048, + RTEMS_TIMESLICE, + RTEMS_DEFAULT_ATTRIBUTES, + &Task_id[ 1 ] + ); + directive_failed( status, "rtems_task_create of TA1" ); + + status = rtems_task_create( + Task_name[ 2 ], + 1, + 2048, + RTEMS_TIMESLICE, + RTEMS_DEFAULT_ATTRIBUTES, + &Task_id[ 2 ] + ); + directive_failed( status, "rtems_task_create of TA2" ); + + status = rtems_task_create( + Task_name[ 3 ], + 1, + 2048, + RTEMS_TIMESLICE, + RTEMS_DEFAULT_ATTRIBUTES, + &Task_id[ 3 ] + ); + directive_failed( status, "rtems_task_create of TA3" ); + + status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); + directive_failed( status, "rtems_task_start of TA1" ); + + status = rtems_task_start( Task_id[ 2 ], Task_2, 0 ); + directive_failed( status, "rtems_task_start of TA2" ); + + status = rtems_task_start( Task_id[ 3 ], Task_3, 0 ); + directive_failed( status, "rtems_task_start of TA3" ); + + status = rtems_task_delete( RTEMS_SELF ); + directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); +} diff --git a/c/src/tests/sptests/sp04/sp04.doc b/c/src/tests/sptests/sp04/sp04.doc new file mode 100644 index 0000000000..6f6355abfa --- /dev/null +++ b/c/src/tests/sptests/sp04/sp04.doc @@ -0,0 +1,38 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. +# On-Line Applications Research Corporation (OAR). +# All rights assigned to U.S. Government, 1994. +# +# This material may be reproduced by or for the U.S. Government pursuant +# to the copyright license under the clause at DFARS 252.227-7013. This +# notice must appear in all copies of this file and its derivatives. +# + + +This file describes the directives and concepts tested by this test set. + +test set name: test4 + +directives: + ex_init, ex_start, t_create, t_start, tm_tick, i_return, + tm_set, tm_get, ev_receive, t_mode + +concepts: + + a. Verifies timeslicing ( all tasks are in timeslice mode ). + + b. Verifies the tswitch user extension. + + c. Verifies the no preemption mode. + + d. Verifies time-slice gets reset even if only one task ready. + +output: + The task name and the current time are printed out each time that a new + task is being dispatched. The configured timeslice is 100 ticks + ( 1 second ); therefore, a task name and the time are printed once + every second. After each task runs 3 times, task 1 changes its mode to + no preempt and runs for about 6 seconds and then changes its mode back to + preempt mode. diff --git a/c/src/tests/sptests/sp04/sp04.scn b/c/src/tests/sptests/sp04/sp04.scn new file mode 100644 index 0000000000..f104c0c482 --- /dev/null +++ b/c/src/tests/sptests/sp04/sp04.scn @@ -0,0 +1,24 @@ +*** TEST 4 *** +TA1 - 09:15:00 12/31/1988 +TA1 - rtems_task_suspend - on Task 2 +TA1 - rtems_task_suspend - on Task 3 +TA1 - killing time +TA1 - rtems_task_resume - on Task 2 +TA1 - rtems_task_resume - on Task 3 +TA2 - 09:15:03 12/31/1988 +TA3 - 09:15:04 12/31/1988 +TA1 - 09:15:05 12/31/1988 +TA2 - 09:15:06 12/31/1988 +TA3 - 09:15:07 12/31/1988 +TA1 - 09:15:08 12/31/1988 +TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT +TA1 - 09:15:09 12/31/1988 +TA1 - 09:15:10 12/31/1988 +TA1 - 09:15:11 12/31/1988 +TA1 - 09:15:12 12/31/1988 +TA1 - 09:15:13 12/31/1988 +TA1 - 09:15:14 12/31/1988 +TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT +TA2 - 09:15:15 12/31/1988 +TA3 - 09:15:16 12/31/1988 +*** END OF TEST 4 *** diff --git a/c/src/tests/sptests/sp04/system.h b/c/src/tests/sptests/sp04/system.h new file mode 100644 index 0000000000..aa2c6d17e4 --- /dev/null +++ b/c/src/tests/sptests/sp04/system.h @@ -0,0 +1,30 @@ +/* system.h + * + * This include file contains information that is included in every + * function in the test set. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include <rtems.h> +#include "tmacros.h" + +/* Miscellaneous */ + +#define EXTERN extern /* external definition */ + +/* macros */ + +/* structures */ + +#include "gvar.h" + +/* end of include file */ diff --git a/c/src/tests/sptests/sp04/task1.c b/c/src/tests/sptests/sp04/task1.c new file mode 100644 index 0000000000..8d0a620ec3 --- /dev/null +++ b/c/src/tests/sptests/sp04/task1.c @@ -0,0 +1,104 @@ +/* Task_1 + * + * This test serves as a test task. It verifies timeslicing activities + * and tswitch extension processing. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" +#include "clockdrv.h" + +rtems_task Task_1( + rtems_task_argument argument +) +{ + rtems_unsigned32 seconds; + rtems_unsigned32 old_seconds; + rtems_mode previous_mode; + rtems_time_of_day time; + rtems_status_code status; + rtems_unsigned32 start; + rtems_unsigned32 end; + + puts( "TA1 - rtems_task_suspend - on Task 2" ); + status = rtems_task_suspend( Task_id[ 2 ] ); + directive_failed( status, "rtems_task_suspend of TA2" ); + + puts( "TA1 - rtems_task_suspend - on Task 3" ); + status = rtems_task_suspend( Task_id[ 3 ] ); + directive_failed( status, "rtems_task_suspend of TA3" ); + + status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &start ); + directive_failed( status, "rtems_clock_get" ); + + puts( "TA1 - killing time" ); + + for ( ; ; ) { + status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &end ); + directive_failed( status, "rtems_clock_get" ); + + if ( end > (start + 2) ) + break; + } + + puts( "TA1 - rtems_task_resume - on Task 2" ); + status = rtems_task_resume( Task_id[ 2 ] ); + directive_failed( status, "rtems_task_resume of TA2" ); + + puts( "TA1 - rtems_task_resume - on Task 3" ); + status = rtems_task_resume( Task_id[ 3 ] ); + directive_failed( status, "rtems_task_resume of TA3" ); + + while ( FOREVER ) { + if ( Run_count[ 1 ] == 3 ) { + puts( "TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT" ); + + status = rtems_task_mode( + RTEMS_NO_PREEMPT, + RTEMS_PREEMPT_MASK, + &previous_mode + ); + directive_failed( status, "rtems_task_mode" ); + + status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); + directive_failed( status, "rtems_clock_get" ); + + old_seconds = time.second; + + for ( seconds = 0 ; seconds < 6 ; ) { + status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); + directive_failed( status, "rtems_clock_get" ); + + if ( time.second != old_seconds ) { + old_seconds = time.second; + seconds++; + print_time( "TA1 - ", &time, "\n" ); + } + } + + puts( "TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT" ); + status = rtems_task_mode( + RTEMS_PREEMPT, + RTEMS_PREEMPT_MASK, + &previous_mode + ); + directive_failed( status, "rtems_task_mode" ); + + while ( FOREVER ); + } + } +} diff --git a/c/src/tests/sptests/sp04/task2.c b/c/src/tests/sptests/sp04/task2.c new file mode 100644 index 0000000000..7574e7dc9f --- /dev/null +++ b/c/src/tests/sptests/sp04/task2.c @@ -0,0 +1,29 @@ +/* Task_2 + * + * This routine serves as a test task. It is just a CPU bound task + * requiring timesliced operation. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" + +rtems_task Task_2( + rtems_task_argument argument +) +{ + while( FOREVER ); +} diff --git a/c/src/tests/sptests/sp04/task3.c b/c/src/tests/sptests/sp04/task3.c new file mode 100644 index 0000000000..a0e7482944 --- /dev/null +++ b/c/src/tests/sptests/sp04/task3.c @@ -0,0 +1,29 @@ +/* Task_3 + * + * This routine serves as a test task. It is just a CPU bound task + * requiring timesliced operation. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" + +rtems_task Task_3( + rtems_task_argument argument +) +{ + while( FOREVER ); +} diff --git a/c/src/tests/sptests/sp04/tswitch.c b/c/src/tests/sptests/sp04/tswitch.c new file mode 100644 index 0000000000..3f0c2047bc --- /dev/null +++ b/c/src/tests/sptests/sp04/tswitch.c @@ -0,0 +1,59 @@ +/* Task_switch + * + * This routine is the tswitch user extension. It determines which + * task is being switched to and displays a message indicating the + * time and date that it gained control. + * + * Input parameters: + * unused - pointer to currently running TCB + * heir - pointer to heir TCB + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" + +rtems_extension Task_switch( + rtems_tcb *unused, + rtems_tcb *heir +) +{ + rtems_unsigned32 index; + rtems_time_of_day time; + rtems_status_code status; + + index = task_number( heir->Object.id ); + + switch( index ) { + case 1: + case 2: + case 3: + Run_count[ index ] += 1; + + status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); + directive_failed( status, "rtems_clock_get" ); + + put_name( Task_name[ index ], FALSE ); + print_time( " - ", &time, "\n" ); + + if ( time.second >= 16 ) { + puts( "*** END OF TEST 4 ***" ); + exit( 0 ); + } + break; + + case 0: + default: + break; + } +} |