Information Technology Reference
In-Depth Information
2.1
The process concept
In the model you are likely familiar with, illustrated in Figure 2.2, a programmer
types up some code in some appropriately high-level language. A compiler
converts that code into a sequence of machine instructions, and stores those
instructions into a file, called the executable image of the program. The compiler
Definition: executable
image
also defines any static data the program needs, along with their initial values,
and includes them in the executable image.
To start the program running, the operating system copies the program
instructions and data from the executable image into physical memory. The
operating system sets aside some memory for the execution stack to store the
state of local variables during procedure calls. The operating system also sets
aside a region of memory, called the heap, for any dynamically allocated data
structures or objects the program might need. Of course, in order to copy the
program into memory, the operating system itself must already be loaded into
memory, with its own stack and heap.
Ignoring protection, once a program is loaded into memory, the operating
system can start running the program by setting the stack pointer and jumping
to the first instruction of the program. The compiler itself is just a regular
program: the operating system starts the compiler by copying the compiler's
executable image into memory and jumping to its first instruction.
If the user wants to run multiple copies of the same program, the operating
system can do that by making multiple copies of the program's instructions,
static data, heap and stack in memory. As we will describe in a later chapter,
most operating systems are designed to reuse memory wherever possible: they
store only a single copy of a program's instructions when multiple copies of
the program are executed at the same time. Even so, a separate copy of the
program's data, stack and heap are needed. For now, we will keep things simple
and make a separate copy of the entire program each time we run a process.
Thus, the difference between a process and a program is that a process is an
instance of a program, in much the same way that an object is an instance of a
class in object-oriented programming. At any point in time, each program can
have zero, one or more processes executing it. For each instance of a program,
there is a process with its own copy of the program in memory.
The operating system keeps track of the various processes on the computer
using a data structure called the process control block . The process control block
Definition: process control
block
stores all the information the operating system needs about a particular process:
where it is stored in memory, where its executable image is on disk, which user
asked it to start executing, what privileges the process has, and so forth.
Earlier, we defined a process to be the execution of a program with restricted
rights. Each of these roles | execution and protection | is important enough
that we will devote several chapters to each concept. In this chapter, we will
 
Search WWH ::




Custom Search