http://www.aros.orgAROS-ExecAROS-Exec ArchivesPower2People

Home

English

Česky

Deutsch

Ελληυικά

Français

Italiano

Nederlands

Polski

Português

Русский

Español

Suomi

Svenska


News

Archive

Introduction

Status
Screenshots
Ports
License

Download


Documentation

Users
Installation
Using
Shell
Applications
FAQ
Developers
Contribute
Roadmap
Bug Tracker
Working with Subversion
Compiling
Application Development Manual
Zune Application Development Manual
System Development Manual
Debugging Manual
Reference
Specifications
UI Style Guide
Documenting
Porting
Translating
Summaries
Links

Contact

Mailing lists
IRC channels

Credits

Acknowledgements


Pictures

Developers
Developers en Masse

Sponsors

Linking

Links

Get AROS Research Operating System at SourceForge.net. Fast, secure and Free Open Source software downloads

AROS Application Development Manual

Index

Warning

This document is not finished! It is highly likely that many parts are out-of-date, contain incorrect information or are simply missing altogether. If you want to help rectify this, please contact us.

The Multitasking Kernel

Background

There are two kinds of multitasking: Preemptive and Non-preemptive (also known as cooperative). Preemptive means that you get a certain amount of CPU time and then another task gets the CPU. Non-preemptive means that a task has to call a function which allows another task to run. Preemptive multitasking (PMT) has these advantages:

  • It's simple to understand
  • There is no need to make sure that your task doesn't keep the CPU forever.

and these disadvantages:

  • It's complicated to exchange data with other tasks
  • You never know how long you will stay awake
  • The OS must decide which task to run next in a clever way

Cooperative Multitasking (CMT) has these advantages:

  • It's very simple to implement
  • It's easy to exchange data
  • You know exactly how long you will stay awake
  • You get most of the CPU

and these disadvantages:

  • If a task behaves badly, there is no way to stop it (for example if it keeps the CPU forever, all you can do is turn the computer off).
  • It's hard to make sure that every task gets the CPU now and then

It seems obvious that CMT is better than PMT but that's not true. CMT is better when you have only a few tasks and a single user. Powerful OSes like Unix and AmigaOS have PMT because it's more simple to use.

How does it work?

The idea is pretty simple. Every computer has a clock and this clock can generate interrupts. An interrupt means that the CPU saves its current state on the stack of the current task and starts a special routine called the interrupt handler. Basically this handler now checks for other tasks which might want to run, selects one of them and switches the stack to the one of the newly chosen task. It then finishes and tells the CPU to continue where it was before the interrupt. Since the CPU is quite dumb, it will just load it's state from the new stack (ie. the one of the new task) and so the new task will run and the old one will be sleeping.

Now let's have a look at the details. The life of a task looks like this: birth, waiting, running and dying. In computer terms, the task is created, then waits that it gets the CPU, does its work while it has the CPU (this might happen more than once) and at some stage, it terminates (or is terminated). It's more easy to understand how it all works when we begin with the time when one task loses the CPU and another one gets it.


Copyright © 1995-2009, The AROS Development Team. All rights reserved.
Amiga® is a trademark of Amiga Inc. All other trademarks belong to their respective owners.