source: rtems/testsuites/libtests/cpuuse/tswitch.c @ e6e9cbe

4.115
Last change on this file since e6e9cbe was e6e9cbe, checked in by Joel Sherrill <joel.sherrill@…>, on 02/02/11 at 18:52:50

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

  • cpuuse/tswitch.c: Shrink memory requirements.
  • Property mode set to 100644
File size: 1.6 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-2009.
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 8 task switches on sis/gdb.  --joel 2 Feb 2011
27 */
28struct taskSwitchLog taskSwitchLog[25];
29int 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 );
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      fatal_directive_status_with_level( status, RTEMS_SUCCESSFUL,
51                                         "rtems_clock_get_tod", 1 );
52
53      if (taskSwitchLogIndex <
54          (sizeof taskSwitchLog / sizeof taskSwitchLog[0])) {
55        taskSwitchLog[taskSwitchLogIndex].taskIndex = index;
56        taskSwitchLog[taskSwitchLogIndex].when = time;
57        taskSwitchLogIndex++;
58      }
59      if ( time.second >= 16 )
60        testsFinished = 1;
61
62      break;
63
64    case 0:
65    default:
66      break;
67  }
68}
69
Note: See TracBrowser for help on using the repository browser.