Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What's the official explanation for that one? I always seem to forget.

share|improve this question
2  
Can you be a little more specific what on earth you mean by "multitasking illusion"? Just because a processor is single-threaded doesn't mean you can't "multitask" unless you're going to be very academic about the meaning of the word. –  Shinrai Apr 11 '11 at 22:47

4 Answers 4

up vote 3 down vote accepted

Multi-tasking, or multi-threading on a single processor is also called perceived multi-threading. Obviously with one CPU, it is not possible to execute commands simultaneously. Instead we interleave processes, giving the illusion of multi-threading.

As @Journeyman Geek added, this uses preemption. This is where we have some sort of structure (think a queue) where the programs are stored and each process gets so many cycles to execute. Then the currently running program is preempted (or swapped out with another program) and then that program runs. There are many strategies to determining which programs execute when. We could be completely fair (ex: Round Robin) and each program receives a certain time-quantum or we could separate the programs by priority and only execute the lower priority program when there are no more higher-priority programs to execute (ex: Priority Queue).

This is helpful when say you are writing a GUI application and running a long background-task. If this were to be written as a single threaded app, the front-end of the GUI would freeze. However, with two threads, the GUI remains responsive. Even if there is only one CPU, the interleaving of the processes means that the GUI remains responsive while the background-process continues to run and make progress.

share|improve this answer

hyperthreading most likely, with modern systems - in short, part of, but not whole core is duplicated so more threads can be run, per core

share|improve this answer
    
I'm aware of hyperthreading, that's why I'm asking specifically about single threaded processors, Like a pre-HT Pentium 4, running several applications supposedly at the same time. –  overmann Apr 11 '11 at 22:46
    
oh, you mean pre-emptive or co-operative multitasking? –  Journeyman Geek Apr 11 '11 at 22:49
    
Heh, that's the problem, I don't really know. Maybe those are the terms I'm looking for. Could you explain those in your answer? –  overmann Apr 11 '11 at 22:51
    
chris and john seem to have already. –  Journeyman Geek Apr 11 '11 at 22:56

Basically the operating system takes each application (and each thread within each application) in turn and runs it for a few CPU cycles. So if you have 10 applications running, over a 10 second period each will get 1 second's worth of time actually running.

It means that each application runs more slowly than it would if it were the only application running on the computer - but for the vast majority of applications most of their time is spent waiting for user input.

See Wikipedia for more information.

share|improve this answer

I'm not sure what you have in mind, but it brings to mind the user perception that applications are running in parallel. This effect is achieved by interleaving the demands of concurrent processes at such a rate that it looks like every, or at least most, processes are running at the same point in time.

Incidentally, in Unix parlance the focus shifts to the perception that the system appears dedicated to each user's requests. We call this simply "multiuser."

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.