source: rtems/testsuites/sptests/sp04/tswitch.c @ 28ab68ae

4.115
Last change on this file since 28ab68ae was 28ab68ae, checked in by Joel Sherrill <joel.sherrill@…>, on 02/02/11 at 19:02:06

2011-02-02 Joel Sherrill <joel.sherrilL@…>

  • sp04/tswitch.c: Shrink memory requirements.
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*  Task_switch
2 *
3 *  This routine is the tswitch user extension.  It determines which
4 *  task is being switched to and displays a message indicating the
5 *  time and date that it gained control.
6 *
7 *  Input parameters:
8 *    unused  - pointer to currently running TCB
9 *    heir    - pointer to heir TCB
10 *
11 *  Output parameters:  NONE
12 *
13 *  COPYRIGHT (c) 1989-2011.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.com/license/LICENSE.
19 *
20 *  $Id$
21 */
22
23#include "system.h"
24
25/*
26 *  Only require 10 task switches on sis/gdb.  --joel 2 Feb 2011
27 */
28struct taskSwitchLog taskSwitchLog[25];
29unsigned int taskSwitchLogIndex;
30volatile int testsFinished;
31
32void Task_switch(
33  rtems_tcb *unused,
34  rtems_tcb *heir
35)
36{
37  uint32_t    index;
38  rtems_time_of_day time;
39  rtems_status_code status;
40
41  index = task_number( heir->Object.id ) - task_number( Task_id[1] ) + 1;
42
43  switch( index ) {
44    case 1:
45    case 2:
46    case 3:
47      Run_count[ index ] += 1;
48
49      status = rtems_clock_get_tod( &time );
50      directive_failed_with_level( status, "rtems_clock_get_tod", 1 );
51
52      if (taskSwitchLogIndex < (sizeof taskSwitchLog / sizeof taskSwitchLog[0])) {
53        taskSwitchLog[taskSwitchLogIndex].taskIndex = index;
54        taskSwitchLog[taskSwitchLogIndex].when = time;
55        taskSwitchLogIndex++;
56      }
57      if ( time.second >= 16 )
58        testsFinished = 1;
59      break;
60
61    case 0:
62    default:
63      break;
64  }
65}
Note: See TracBrowser for help on using the repository browser.