source:
rtems/testsuites/sptests/sp04/tswitch.c
@
ac85d56
Last change on this file since ac85d56 was ac85d56, checked in by Joel Sherrill <joel.sherrill@…>, on 09/26/09 at 15:47:16 | |
---|---|
|
|
File size: 1.5 KB |
Rev | Line | |
---|---|---|
[ac7d5ef0] | 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 | * | |
[b84f1fdc] | 13 | * COPYRIGHT (c) 1989-2009. |
[ac7d5ef0] | 14 | * On-Line Applications Research Corporation (OAR). |
15 | * | |
[98e4ebf5] | 16 | * The license and distribution terms for this file may be |
17 | * found in the file LICENSE in this distribution or at | |
[d2b93bfd] | 18 | * http://www.rtems.com/license/LICENSE. |
[ac7d5ef0] | 19 | * |
[3235ad9] | 20 | * $Id$ |
[ac7d5ef0] | 21 | */ |
22 | ||
23 | #include "system.h" | |
24 | ||
[a1c219b] | 25 | #if BSP_SMALL_MEMORY |
26 | struct taskSwitchLog taskSwitchLog[100]; | |
27 | #else | |
[9b413ea] | 28 | struct taskSwitchLog taskSwitchLog[1000]; |
[a1c219b] | 29 | #endif |
[b84f1fdc] | 30 | unsigned int taskSwitchLogIndex; |
[df49c60] | 31 | volatile int testsFinished; |
[9b413ea] | 32 | |
[ac85d56] | 33 | void Task_switch( |
[ac7d5ef0] | 34 | rtems_tcb *unused, |
35 | rtems_tcb *heir | |
36 | ) | |
37 | { | |
[c87608f] | 38 | uint32_t index; |
[ac7d5ef0] | 39 | rtems_time_of_day time; |
40 | rtems_status_code status; | |
41 | ||
[fabacfe] | 42 | index = task_number( heir->Object.id ) - task_number( Task_id[1] ) + 1; |
[ac7d5ef0] | 43 | |
44 | switch( index ) { | |
45 | case 1: | |
46 | case 2: | |
47 | case 3: | |
48 | Run_count[ index ] += 1; | |
49 | ||
[bcf16c0] | 50 | status = rtems_clock_get_tod( &time ); |
51 | directive_failed_with_level( status, "rtems_clock_get_tod", 1 ); | |
[ac7d5ef0] | 52 | |
[9b413ea] | 53 | if (taskSwitchLogIndex < (sizeof taskSwitchLog / sizeof taskSwitchLog[0])) { |
54 | taskSwitchLog[taskSwitchLogIndex].taskIndex = index; | |
55 | taskSwitchLog[taskSwitchLogIndex].when = time; | |
56 | taskSwitchLogIndex++; | |
[ac7d5ef0] | 57 | } |
[9b413ea] | 58 | if ( time.second >= 16 ) |
59 | testsFinished = 1; | |
[ac7d5ef0] | 60 | break; |
61 | ||
62 | case 0: | |
63 | default: | |
64 | break; | |
65 | } | |
66 | } |
Note: See TracBrowser
for help on using the repository browser.