Before you keep reading...
Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
9.3. Process Management¶
A computer program is just a static collection of code and data. Once we start running a program, there is dynamic information associated with that particular run of the program - things like the current instruction, the values that are stored in memory and the input the user has given. The word process refers to a computer program and the dynamic state associated with a particular execution of that program.
Most modern operating systems are capable of multi-tasking, that is to say running more than one process at a time. Multiple programs can be running at the same time (including multiple copies of the same program). On a computer with a single processor core, only one of these processes can be running at any given time. The other processes all have to sit in a “ready queue” waiting their turn to run. Processes that are waiting for a slow event (like reading or writing a file to a hard drive) to complete and have no work to do until that finishes are put in a “waiting” state until the event completes.
Hundreds of times a second, the hardware interrupts the running program and gives the operating system a chance to run. It also gets swapped into the processor to handle messages from the hardware (“Hey, the mouse was clicked”). Each time the OS is being run it processes any events that need to be handled and then restarts the program that was running. After one program has been running for a certain period of time, the OS sends it back to the ready queue and picks a new program to run for a while. By switching tasks every few milliseconds, the processor makes it look like it is doing multiple things at once.
Animation used by permission of Virginia Tech
Many modern CPUs feature multiple processing “cores” and can be running instructions from two or more processes at once. But the basic model still holds - each processing core is constantly switching between different processes, giving each a brief chance to run some instructions before switching to the next.