Multitasking is the simultaneous execution of more than one task (also named as process).
In the case of a electronic devices with a single CPU and human beings only one task is said to be running at any point in time, meaning that the CPU or the brain is actively executing instructions for that task.
But there are sophisticated techniques which let you think it’s multitasking.
Intelligent scheduling is the key to powerful devices.
This is a wide field where innovation within the operating system can save memory, reduce drain of battery energy, and increase performance of tasks which have to be executed by ‘temporarily sleeping’ apps.
Human beings …
People can drive a car while using a phone for a call or they can write an E-Mail while looking on a TV.
Studies validate that people show severe interference when even very simple tasks are performed at the same time. Because the brain cannot fully focus when multitasking, people take longer to complete tasks and are predisposed to error compared to sequential completion.
The brain always restarts and refocuses when switching between tasks and in the interim between each exchange there is no progress whatsoever.
So multitasking of human beings is just a rapid toggling among tasks rather than simultaneous processing. Although the brain is complex and can perform a myriad of tasks, it cannot multitask efficiently.
Electronic devices …
In computing, multitasking is a method where multiple tasks are performed during the same period of time. The tasks share common resources, such as a CPU (Central Processing Unit) and main memory.
With single CPU only one task is said to be running at any point in time, meaning that the CPU is actively executing instructions for that task.
The multitasking feature of operating systems solves the problem by scheduling each task and assigning priorities.
Like human beings the CPU has to ‘restart and refocus’ every time one task is replaced by another task. This is called context switching and modern CPUs can do this hellish fast.
If context switching is done frequently enough the illusion of parallelism of task fulfillments is achieved. Real multitasking can only be done by more than one human being or more than one CPU.
Operating systems follow these strategies for scheduling tasks:
- Multiprogramming systems
In multiprogramming systems, the running task keeps running until it performs an operation that requires waiting for an external event (e.g. getting a push notification) or until the computer’s scheduler forcibly swaps the running task out of the CPU. Multiprogramming systems are designed to maximize CPU usage.
- Time-sharing systems
In time-sharing systems, the running task is required to relinquish the CPU, either voluntarily or by an external event such as a hardware interrupt. Time sharing systems are designed to allow several programs to execute apparently simultaneously.
- Real-time systems
In real-time systems, some waiting tasks are guaranteed to be given the CPU when an external event occurs. Real time systems are designed to control mechanical devices such as industrial robots, which require timely processing.
Over time sophisticated techniques were developed to use CPU and memory efficiently. All the developments in multitasking techniques for mobile devices like the iPad or the iPhone are have to consider that there is not only a CPU and limited memory but also a battery which should keep the device alive at least for one day.
Apple’s iOS devices …
Apple’s operating system iOS 7 provides improved Multitasking although the basic system behavior remained the same compared to the predecessor iOS 6.
Regarding iOS apps we can distinguish between 5 states of execution an app can take on:
The normal state of “in use” for an app.
The app is in the foreground but does not receiving any event
This happens e.g. if the user has locked the device with the app active.
- Not Running
The app has been terminated or has not been launched yet.
The app is no longer on-screen but still visible in the multitasking view and executes tasks.
The app is still resident in memory but is not executing tasks.
When you press the home button, the app moves from Active to Background. Most apps usually then go from Background to Suspended within some seconds.
Suspended apps remain in the device’s memory to let them resume mode quickly if you choose them from the Multitasking View. Suspended apps do not use CPU time and energy from the battery.
1 People saying that you should close apps because they slow down the device, fill the memory, and drain the battery are simply wrong.
The concept of iOS ensures optimized memory and energy management. Launching a memory-intensive app will force iOS to suspend other apps and move them into the ‘Not Running’ state, that means, remove them completely from memory. Maybe you have noticed this behavior when looking at the time an app needs to relaunch. Sometimes it needs less time because the app launched before didn’t use much memory and so the relaunched app wasn’t removed from memory.
2 iOS doesn’t show the state of an app in the Multitasking View. You cannot see whether it’s suspended or executes background tasks. The Multitasking View only shows you the recently used apps. Apple again made it simple but in the Multitasking View it would be nice to see at least which app is running in the background.
Background App Refresh
Some apps can continue to run for a short period of time and are then set to a suspended state so they are not actively in use, open, or taking up system resources (CPU, battery). They will instantly launch when you tap on their icon within the Multitasking View.
Certain tasks or services can continue to run in the background. To lessen the affect on battery life, normal app background refreshing is scheduled for efficient times, such as when your device is connected to Wi-Fi, plugged into a power source, or being actively used.
You can adjust background activity of apps by going to Settings – General – Background App Refresh.
When Background App Refresh is on, apps that take advantage of this feature can refresh themselves in the background. For example, an app can check if new content is available and download the updates, or retrieve the updated content in the background when it receives a push notification, so the new content is ready for viewing when you launch the app. Apps can also schedule background refreshing based on your location.
iOS learns patterns based on your use of the device and tries to predict when an app should be updated in the background. It also learns when the device is typically inactive, such as during the night, to reduce update frequency when the device is not used.
If you turn off Background App Refresh (in total or for a specific app), data of all apps resp. specific apps are no longer updated. If you close an app via the Multitasking View, it won’t be able to refresh in the background.
A little helper …
With the release of the iPhone 5S and the iPad Air in fall 2013, Apple introduced the A7 64-Bit processor and the M7 Motion processor which is an innovative step in mobile technology because mobiles are always in motion. The M7 Motion processor is a co-processor to the A7 main processor to offload work from it.
Think of it like this:
Every time the CEO (the A7) is focused on a task and needs help from his assistant (the M7) because the proud owner again jumps for joy while viewing Apple’s Keynote he sends a request to get motion data. Then he can refocus on actions depending on the devices motion.
In relevant cases users should know about the device’s background activity to understand why the device responds with slightly slower performance.
When in use, the location icon appears in the status bar. You may also see a blue, double-height status bar if an app has turn-by-turn navigation on. If an app is using Location Services, such as geofence or turn-by-turn navigation, you can pause the service within the app.
You can view a list of apps that recently used location services in Settings – Location Services.
Voice over IP (VoIP)
A double-height status bar will appear when you leave the primary VoIP app, such as Skype, while still on a call. If you’re logged in to a VoIP service, the apps can still receive calls while on background, but won’t display the double-height status bar.
When the syncing icon appears in the status bar, the device is tethered or wirelessly syncing with iTunes.
When the network-activity icon appears in the status bar, network activity is occurring in the current app. The network-activity indicator will appear only for the following features or activities, when you’re using the corresponding app:
- Photo Stream uploads and downloads
- Regular application downloads and updates from App Store
- Automatic downloads (music, books, and applications)
- iTunes Match downloads
- Checking E-Mail
- iCloud restores
Third-party apps also use the icon to indicate network activity.
Behind the scenes …
Apps, not visible on your screen and running in the background do this usually for about 5 seconds before they are moved to the Suspended state. In some cases, e.g. when downloading a large file with FTP Client Pro, the download process would be interrupted.
To prevent these ‘task crashes’ developers can declare processes as so-called ‘background tasks’. This allows an app to get an extra timeframe to successfully complete it’s task within about 10 minutes.
Some apps are allowed to run indefinitely in the background. They can be categorized as follows:
- 1 Apps that play audio while in the background, e.g. Apple’s built-in Music or Podcast apps.
- 2 Apps that track your location, e.g. Apple’s built-in app Maps if you use it for turn-by-turn GPS navigation
- 3 Apps that listen for incoming Voice-Over-IP (VOIP) calls like Skype
- 4 Apps that listen to new incoming content and download it, e.g. Apple’s Mail or Newsstand app. These apps not only get a push notification but also download new content immediately.
It’s obvious that battery draining as well as CPU performance is reduced when using these apps. So in contrast to all other apps they should be killed from the Multitasking View if their services are no longer needed.
It would be a useful improvement in later versions of iOS 7 to show users which app is running indefinitely in the background so that the main reason for energy consumption can easily be identified.
Multi-core processors …
The multi-core processors in most current computers and mobile devices enable true multitasking because each core can be performing a separate task at any given time. An example of multitasking is the processing of an email while streaming a video.
In single-core processors, multitasking is actually accomplished by time-sharing processor resources – tasks aren’t actually simultaneous but the operating system shifts quickly between tasks, ideally transparently to the user. The operating system monitors where the user is in these tasks and goes from one to the other without losing information.
Real multitasking with one brain or one processor is not possible. iOS is optimized for keeping your device alive by killing processes, cleaning up the memory, and reducing drain of energy to a minimum. You must not take care of app management except apps are intended to run in the background indefinitely.
Related links …
Thanks for stopping by.