What happens when a program runs?
Double-click an app icon and the program "runs." But what exactly is running? It's the moment a file that sat still becomes something alive and moving.
A program and running it are different
First, tell two things apart.
One is the program.
A file sitting still
in storage.
The other is it in a running state.
Alive and moving right now,
doing work.
A recipe on paper
versus cooking in progress,
that's the difference.
Program (code)
A file sitting still in storage. Like a sheet of paper with a recipe on it.
Process (running)
That program actually running. Cooking while reading the paper.
Two that seem alike but aren't.
A program that's running,
this is called a process.
Just as the same recipe
has to be started cooking
before steam and smell rise,
a program too has to run
before it starts real work.
Run it and a process is born
The moment you double-click an app,
the operating system goes to work.
It loads the code from storage
into memory,
and wakes it up:
"alright, start now."
This awakened state
is a process.
Try running it yourself.
Press the run button.
The file stays as it is.
A copy goes up into memory
and becomes a process.
So even if you turn the same app
off and on,
the original file doesn't change.
A process has its own place
When a process is born,
the operating system gives it a place.
"You use these memory cells."
The addressed memory
we learned in the earlier area.
Each process
gets its own workspace,
separately.
Each process has its own memory space.
Because the places are separate,
they don't interfere with each other.
Even if one app suddenly freezes,
another app is fine.
So that yours and mine
don't get mixed up,
the operating system divided them.
You can open many copies of the same app
Here's an interesting point.
There's one program,
but there can be many processes.
Open three browser windows
and from the same program,
three processes have been made.
Open more windows.
Each window you open is one more process.
Just as one recipe sheet
cooks in several pots at once,
one program
can run many processes.
Each working separately
in its own space.
The operating system manages them all in a list
The operating system
holds every running process
in a list.
What its name is,
how much it works,
how much memory it uses.
When a computer slows down,
what you see in the "task manager"
is exactly this list.
The OS gives them all a number (PID) and manages each separately.
Each single process
is alive in its own space,
and the operating system keeps track
of them all in a list.
But there's only one set of parts,
so how do this many processes
run at once?
Next time we unravel that secret.