source: rtems/testsuites/sptests/sp04/tswitch.c @ d5ae827

4.104.115
Last change on this file since d5ae827 was a1c219b, checked in by Chris Johns <chrisj@…>, on 05/18/09 at 23:49:15

2009-05-19 Chris Johns <chrisj@…>

  • sp04/tswitch.c: Lower sample count for small memory targets.
  • 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#if BSP_SMALL_MEMORY
26struct taskSwitchLog taskSwitchLog[100];
27#else
28struct taskSwitchLog taskSwitchLog[1000];
29#endif
30unsigned int taskSwitchLogIndex;
31volatile int testsFinished;
32
33rtems_extension Task_switch(
34  rtems_tcb *unused,
35  rtems_tcb *heir
36)
37{
38  uint32_t    index;
39  rtems_time_of_day time;
40  rtems_status_code status;
41
42  index = task_number( heir->Object.id ) - task_number( Task_id[1] ) + 1;
43
44  switch( index ) {
45    case 1:
46    case 2:
47    case 3:
48      Run_count[ index ] += 1;
49
50      status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
51      directive_failed_with_level( status, "rtems_clock_get", 1 );
52
53      if (taskSwitchLogIndex < (sizeof taskSwitchLog / sizeof taskSwitchLog[0])) {
54        taskSwitchLog[taskSwitchLogIndex].taskIndex = index;
55        taskSwitchLog[taskSwitchLogIndex].when = time;
56        taskSwitchLogIndex++;
57      }
58      if ( time.second >= 16 )
59        testsFinished = 1;
60      break;
61
62    case 0:
63    default:
64      break;
65  }
66}
Note: See TracBrowser for help on using the repository browser.