How a Computer Works: Multi-Tasking

Multi-Tasking

As I noted in the CPU article, the central processor of a computer can only do one thing at a time. (Well, maybe two or four, depending on the number of cores, but not 20 or sixty.) Yet typically, a modern computer will have several programs running at one time, and each of these will have multiple processes and the operating system may have dozens of processes going.

Each process is essentially a separate program. The operating system has many small processes running that are called daemons. These do one small thing that the OS needs to do, perhaps watching the keyboard, or monitoring security, or communicating with a printer, etc., etc. Many are sleeping to be awakened when something happens (like typing on the keyboard). Others. like the WindowServer, are running all the time, using a significant amount of CPU time, depending on your usage.

So, how does this all happen. If we were to go back ten years or so, the microprocessors of even the workstation computers had only one single core. So they could do literally only one thing at a time. Yet they still managed to perform multiple tasks.

They did this, and still do so, by a process called multi-tasking. Essentially, it is just like what you do whenever you multi-task. You put aside what you are currently working on, and shift your attention to the new task. You hide Word and  bring the mail program forward on your computer, so you can reply to an important email. Then you bring Word up again and continue where you left off.

Computer operating systems do exactly this. It is also called Context Switching. Every number of microseconds, it pauses to see what else it is doing “at the same time.” (It may also pause the current task if an interrupt is detected, sent from another program or from hardware.) Before it can switch to the other process, it first must save the current context: data in the registers, program counter, etc. Then it can load the saved context from the new program and continue from where it left off. All this happens so quickly – dozens of times per second – that it appears to the user that the multiple programs are running simultaneously. You may be watching a video on Vimeo and sending a message on Facebook, it all seems to be concurrent. The changes are just too swift for us to notice.

Multi-tasking is essential to modern day computing.


If you appreciate this work

Then please check out my short fiction anthologies.

(Both available in both Amazon and iBooks stores.)

50CentFlash.com


View on Amazon
View iBooks Store


“They build up and then the surprise at the end turns things over.”  Ãsa S.
“The writing of short stories has been a lost art, but is making a timely reemergence. Jaan Seunnasepp delivers an enjoyable experience well before anyone noticed I was mentally lost in the moment.” Andrew

 


 

Advertisements