Files
rtems/testsuites/sptests/sp04/tswitch.c
T
Joel Sherrill bcf16c034d 2009-08-10 Joel Sherrill <joel.sherrill@oarcorp.com>
* sp01/sp01.scn, sp01/task1.c, sp03/task1.c, sp03/task2.c,
	sp04/task1.c, sp04/tswitch.c, sp09/screen02.c, sp09/screen13.c,
	sp09/screen14.c, sp09/sp09.scn, sp11/sp11.scn, sp11/task1.c,
	sp11/task2.c, sp19/fptask.c, sp19/sp19.scn, sp19/task1.c,
	sp22/prtime.c, sp22/sp22.scn, sp22/task1.c, sp24/sp24.scn,
	sp24/task1.c, sp30/task1.c, sp31/prtime.c, sp31/sp31.scn,
	sp31/task1.c, spwatchdog/prtime.c, spwatchdog/spwatchdog.scn,
	spwatchdog/task1.c: Convert calls to legacy routine rtems_clock_get(
	RTEMS_CLOCK_GET_TOD, ..) to rtems_clock_get_tod(..).
2009-08-10 14:49:51 +00:00

67 lines
1.5 KiB
C

/* 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-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#include "system.h"
#if BSP_SMALL_MEMORY
struct taskSwitchLog taskSwitchLog[100];
#else
struct taskSwitchLog taskSwitchLog[1000];
#endif
unsigned int taskSwitchLogIndex;
volatile int testsFinished;
rtems_extension Task_switch(
rtems_tcb *unused,
rtems_tcb *heir
)
{
uint32_t index;
rtems_time_of_day time;
rtems_status_code status;
index = task_number( heir->Object.id ) - task_number( Task_id[1] ) + 1;
switch( index ) {
case 1:
case 2:
case 3:
Run_count[ index ] += 1;
status = rtems_clock_get_tod( &time );
directive_failed_with_level( status, "rtems_clock_get_tod", 1 );
if (taskSwitchLogIndex < (sizeof taskSwitchLog / sizeof taskSwitchLog[0])) {
taskSwitchLog[taskSwitchLogIndex].taskIndex = index;
taskSwitchLog[taskSwitchLogIndex].when = time;
taskSwitchLogIndex++;
}
if ( time.second >= 16 )
testsFinished = 1;
break;
case 0:
default:
break;
}
}