OS Demos

# Operating System (OS) Sample Demos

## Location

`$TwlSDK/build/demos/os`
`$TwlSDK/build/demos.TWL/os`

## Compilation

Move to the `$TwlSDK/build/demos/os` (or `$TwlSDK/build/demos.TWL/os) directory, and enter`

> `% make`

Compiling will begin, and the SRL executable file and the NEF or TEF files with binary information will be generated in `$TwlSDK/build/demos/os/(sample name)/bin/(platform)/(target)/`
`$TwlSDK/build/demos.TWL/os/(sample name)/bin/(platform)/(target)/`

For example:

> `$TwlSDK/build/demos/os/thread-1/bin/ARM9-TS/Release/main.srl`

will be the executable file for the `thread-1` demo.

## Execution

### For NITRO ROMs

If using the Ensata emulator:

- Execute NEF and SRL files with ensata

If using IS-NITRO-DEBUGGER:

- Load and execute an NLF file with IS-NITRO-DEBUGGER
- Execute an SRL file with IS-NITRO-DEBUGGER
- Execute an SRL file with IS-NITRO-DEBUGGER using the `loadrun.exe` tool from a command line

If using IS-TWL-DEBUGGER:

- Load and execute an NLF file with IS-TWL-DEBUGGER.
- Execute an SRL file with IS-TWL-DEBUGGER
- Execute an SRL file with IS-TWL-DEBUGGER using the `loadrun.TWL.exe` tool from a command line

### For TWL/NITRO HYBRID ROMs

If using IS-NITRO-DEBUGGER:

- Execute an SRL file with IS-NITRO-DEBUGGER
- Execute an SRL file with IS-NITRO-DEBUGGER using the `loadrun.exe` tool from a command line

If using IS-TWL-DEBUGGER:

- Load and execute a TLF file with IS-TWL-DEBUGGER
- Execute an SRL file with IS-TWL-DEBUGGER
- Execute an SRL file with IS-TWL-DEBUGGER using the `loadrun.TWL.exe` tool from a command line

### For TWL LIMITED ROMs

If using IS-TWL-DEBUGGER:

- Load and execute a TLF file with IS-TWL-DEBUGGER
- Execute an SRL file with IS-TWL-DEBUGGER
- Execute an SRL file with IS-TWL-DEBUGGER using the `loadrun.TWL.exe` tool from a command line

## Description

Name | Directories | Operation
--- | --- | ---
`alarm-1` | `demos` | Uses one one-time alarm.
`alarm-2` | `demos` | Uses the periodic alarm and a one-time alarm.
`arena-1` | `demos` | Sets up the arena and acquires memory.
`argument-1` | `demos` | Embeds argument data in the ROM image and display.
`argument-2` | `demos` | Creates argument data from a string in real-time and sets it.
`callTrace-1` | `demos` | Carries out the function call trace display without using the thread system.
`callTrace-2` | `demos` | Carries out the function call trace display using the thread system.
`consoleType-1` | `demos` | Displays information about the operating environment on the screen.
`cplusplus-1` | `demos` | Initializes the memory control before calling the static initializer for C++ implementation.
`cpuSpeed-1` | `demos.TWL` | Changes the CPU speed between normal speed and double speed.
`entropy-1` | `demos` | Uses the `OS_GetLowEntropyData` function..
`event-1` | `demos` | Starts a thread in response to an event.
`exceptionDisplay-1` | `demos` | Displays exceptions and uses the exception callback.
`exceptionDisplay-2` | `demos` | Pseudo-generates an exception when dividing by zero.
`exceptionDisplay-3` | `demos` | Shows the function call trace information when an exception occurs.
`exceptionDisplay-4` | `demos` | Displays the exception context to the screen when an exception occurs.
`forChina-1` | `demos` | A simplified sample for creating applications designed for China.
`forChina-fs` | `demos` | The same as `forChina-1`, but it uniquely defines the `OS_ShowAttentionChina` function and gets the image data from the file system.
`forKorea-1` | `demos` | A simplified sample for creating applications designed for Korea.
`functionCost-1` | `demos` | Measures and displays the function cost.
`functionCost-2` | `demos` | Measures and displays the function cost with multiple threads.
`functionCost-3` | `demos` | Calculates and displays the total function cost measured with multiple threads.
`heap-1` | `demos` | Creates a heap and then allocates and frees memory areas.
`message-1` | `demos` | Starts a thread in response to an event.
`mutex-1` | `demos` | When accessing one function from multiple threads, uses mutex to gain exclusive control.
`mutex-2` | `demos` | Unlocks a mutex when a thread is completed.
`os_jump` | `demos.TWL` | Demonstrates the operation of functions that go through hardware reset such as `OS_JumpToSystemMenu` and `OS_RebootSystem`.
`reset-1` | `demos` | Resets software.
`simple-1` | `demos` | The most simple of the demos.
`sleep-1` | `demos` | Puts a thread to sleep for a specified length of time.
`spinwait-1` | `demos` | Uses `OS_SpinWait()` to wait for a fixed period of time.
`thread-1` | `demos` | Creates two threads so that one directly wakes up the other.
`thread-2` | `demos` | Creates two threads, and starts each one from an interrupt handler.
`thread-3` | `demos` | An example of how to use the `OS_JoinThread` function.
`threadQueue-1` | `demos` | Starts a thread using a thread queue.
`threadYield-1` | `demos` | An example of how to use the `OS_YieldThread` function.
`tick-1` | `demos` | Gets the system's tick value.
`timer-1` | `demos` | Uses a 16-bit timer and a 32-bit timer.
`valarm-1` | `demos` | Uses an alarm that uses `V-count`.
`waitIrq-1` | `demos` | Waits for a V-Blank while operating a separate thread.
`waitIrq-2` | `demos` | Shows the difference in operation between the `OS_WaitIrq` and `OS_WaitAnyIrq` functions.

## Operation

The `exceptionDisplay-*` and `reset-1` demos do not work properly with `ensata`.

With IS-TWL-DEBUGGER, the `exceptionDisplay-*` demos will halt on the code where the exception occurs.

Several of the demos use the `OS_Printf` function to display information in the debug console. However, the FINALROM build of a ROM will disable the `OS_Printf` function, so this information cannot be verified with the FINALROM build.

## See Also

OS Function List

## Revision History

2008/07/09 Added the `argument-1` and `argument-2` demos, which had been removed for some time.
2008/04/25 Changed the lists for TWL.
2006/10/19 Added description for `forKorea-1` sample.
2005/09/09 Added `argument-2`.
2005/07/22 Corrected the erroneous omission of `functionCost-1`.
2005/07/21 Added `argument-1`.
2005/07/14 Added `thread-10`.
2005/07/13 Added `thread-6`, `thread-7`, `thread-8`, and `thread-9`.
2005/07/11 Added description for `forChina-1` and `forChina-fs` samples.
2005/05/10 Added description of `favorite-color` demo.
2005/03/02 Revised descriptions to reflect current support environment conditions.
2004/12/08 Removed `interrupt-key-1`, Revised Operation
2004/09/01 Added `reset-1`.
2004/08/17 Standardized the notation of the IS-NITRO-EMULATOR.
2004/07/10 Changed from `.bin` to `.srl.`
2004/06/25 Added `thread-5.`
2004/06/08 Made it possible to insert the demo of the `profile` function into `Makefile` by default.
2004/05/24 Added `functionCost-1`, `functionCost-2`, `functionCost-3`, `waitlrq-1`, and `waitlrq-2`. Added description about necessary `profile` functions.
2004/04/15 Added description of `callTrace-1`, `callTrace-2`, `cplusplus-1`, and `exceptionDisplay-3`.
2004/04/05 Added description of `mutex-2`, `sleep-1`, and `timer-1`. Changed `systemClock-1` to `tick-1`.
2004/03/17 Added description of `exceptionDisplay-2`, `valarm-1`, and `spinWait-1.`
2004/02/05 Added description of `alarm-1`, `alarm-2`, `exceptionDisplay-1`, and `systemClock-1`.
2004/01/18 Moved `interrupt-dma-1` sample to `MI` as `dmaCallback-1`.
2004/01/09 Initial version.

CONFIDENTIAL