1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - OS - demos - spinwait-1
3 File: main.c
4
5 Copyright 2003-2008 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Date:: 2008-04-01#$
14 $Rev: 5205 $
15 $Author: yada $
16 *---------------------------------------------------------------------------*/
17 #include <nitro.h>
18
19 #define TicksToCPUCycles( tick ) ((tick)*64*2)
20
21 //================================================================================
22 /*---------------------------------------------------------------------------*
23 Name: NitroMain
24
25 Description: main
26
27 Arguments: None
28
29 Returns: None
30 *---------------------------------------------------------------------------*/
NitroMain()31 void NitroMain()
32 {
33 OSTick begin, end;
34 u32 n;
35
36 OS_Init();
37 OS_InitTick();
38
39 n = 1000;
40 for (n = 1000; n <= 1000000; n *= 2)
41 {
42 begin = OS_GetTick();
43 OS_SpinWait(n);
44 end = OS_GetTick();
45
46 OS_Printf("OS_SpinWait(%d) Wait=%lld cycles\n", n, TicksToCPUCycles((u64)end - (u64)begin));
47 }
48
49 OS_Printf("==== Finish sample.\n");
50 OS_Terminate();
51 }
52
53 /*====== End of main.c ======*/
54