It varies from system to system.

In nonpreemptive multitasking systems (such as the original Oberon, or the original Apple Macintosh), the operating system periodically "polls" all tasks, giving them an opportunity to do work.  The tasks are expected to play nicely together.  If they just have a little bit of work to do, they do it and return to the OS.  If one task has a BIG chunk to do, it is expected to break it into little pieces, and work one little piece each time it is polled.

Hardware interrupts (disk drive DMA completions, serial port interrupts, what have you) cause interrupt routines to run.  These interrupt routines may in turn notify tasks of work to be done when the task next runs.

In nonpreemptive multitasking systems, the occurrence or non-occurrence of an interrupt does not affect which task is running after the interrupt routine finishes.

In preemptive multitasking systems, it is possible for an interrupt routine to force a scheduling change.  In a traditional round-robin preemptive multitasking system, a periodic timer interrupt does exactly that.  The timer interrupt fires, the timer interrupt routine does some black magic to cause the return-from-interrupt instruction to return to the operating system's preemptive schedule, rather than to the running task, taking the processor away from the current task, and (POSSIBLY) giving it to another task.  If no other task is ready to run at that point, the current task will get the processor again, having only lost some time.

Preemptive multitasking can cause a LOT of troubles.  All of that annoying stuff about mutexes and critical sections and deadly embraces and ... show up when the processor gets taken away from you without warning.  You have to use all those things to tell the operating system that you are in the middle of mixing nitroglycerin and taking the processor away from you right now is likely to result in a large smoking virtual hole in the middle of the server room floor.

How does multitasking work
Are there any open source apps for password management like Roboform in Win 7 or can Roboform be used in 11.04 64 bit? If so how?
