Foreground State

Introduction

When your game starts up, it runs as a unique process and is considered to be in the foreground state.

Resources

Only one process in the system can be in the foreground. For information on the resources that the foreground process has access to, see Foreground Resources.

NOTE:
Background processes have no access to Foreground Resources. For more information about resources that are available to background processes, see Background Resources.

Foreground Memory Regions

There are two regions of memory that are limited to the foreground process: MEM1 and the foreground bucket. You can use these regions to improve the performance and operation of your application when it is in the foreground. When a foreground-to-background switch occurs, both of these memory regions are cleared to prevent the new foreground process from accessing data belonging to the old foreground process.

Foreground Is Cooperative

Background Process and Foreground-Only Mode

A process that is not in the foreground is referred to as being in a background state. When the main title is in the background, it receives CPU time on Core 2 only and no time on Core 0 or Core 1. In addition, it is not able to use any of the foreground-only resources.

If your game does not do any processing while it is in the background, you may choose to configure it as "foreground only". This leaves Core 2 idle while your game is in the background, and never lets it execute on any core without full access to foreground resources. This may simplify your game programming if you do not have to deal with background operations.

A condition of this behavior is that if your game is asked to exit while in the background due to POWER Button press or user action, your game will still not receive CPU time and will be abandoned. It is critical in this instance that any data that needs to be saved be written to storage before your game releases the foreground.

To enable "foreground only" mode you specify the high bit of the cmdFlags in your cos.xml file for your game. The high bit has the value 2147483648, and is added to any other flag value bits.

Switching to Another Process

The foreground process can request that another process be moved into the foreground by calling the appropriate function in the SYSAPP library.

When the foreground is gained, arguments may be available from the switch. They can be retrieved by calling the SYSGetArguments function, which is also in the SYSAPP library.

Typically, this function is called after a process receives the ACQUIRED_FOREGROUND system message.

Starting a New Process

The game does not start processes. The OS kernel only permits two processes to start other processes:

Available Processes

When the system is started and prior to the game starting, several processes are started:

Foreground processes can call processes and can be called back to return from the process that they called, such as:

The Wii U Launcher is mutually exclusive with a Game. Other processes may not be ready or started when Wii U Launcher or Game is started. If a process has not started, an error code is returned, indicating that it is not ready.

HOME Button Suppression

While the game is in the foreground, the HOME Button can be pressed at any time. ProcUI receives PROCUI_MESSAGE_HBDENIED if it is pressed while the HOME Button is disabled. Your game is free to handle messages itself using the ProcUI Library. For more information on the ProcUI Library, see the ProcUI Library.

See Also

Application Lifecycle
Background State
Request to Move to the Background
Request to Move to the Foreground
Transition Messages
Multicore Processing on the Wii U
ProcUI Library
Creating an Application

Revision History

2015/03/19 Formatted as 'NOTE'.
2013/08/08 Created


CONFIDENTIAL