Multitasking Symbian OS

MIDlet suite runs in a VM process and there can be multiple MIDlet suites running at the same time. Java VM process is a normal process among other native applications, such as Browser or Calendar in Symbian OS.

Symbian OS scheduler handles execution between running threads. Scheduling is based on thread and process priority. Symbian OS scheduling is pre-emptive and round-robin method is used for same priority threads. Since Java uses native threading, the generated threads are scheduled by Symbian OS scheduler as well.

Process priority is typically assigned to be either background or foreground. Symbian OS changes process priority automatically depending whether application is on foreground or not. This applies also for Java VM process. The foreground and background MIDlets comply to the following guidelines:


  • The foreground application gets basically all the CPU time it requires.

  • The MIDlet is not paused automatically when it is assigned to the background. It can still consume CPU resources.

MIDlet developer can not affect to VM process priority itself but Java thread priorities can be set via Thread.setPriority(), see section Thread for more details.

If a MIDlet is the foreground application, its threads run on higher priority than most native applications. If the MIDlet is performing very resource consuming tasks, it may have a negative effect to native applications.

Multitasking error example

It is quite easy to make MIDlet that consumes a lot of CPU resources by accident. For example, let’s consider following code snippet:

void run()
{
  while(true)
  {
    if( onForeground )
    {
      doMyStuff();
    }
    else
    {
      yield();
    }
}
}

Intention was that if the MIDlet is not on foreground, the MIDlet should not do anything. Instead this MIDlet will have busy loop when it’s on background. This might have effects to other applications and even more importantly it will prevent device to go on power saving mode, which will have a drastic effect on battery life.

Better way to implement this would be using wait – notify mechanism instead of yield, see section Thread for more details.