Modern Operating Systems by Herbert Bos ...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Showing 784-785 out of 1137
Modern Operating Systems by Herbert Bos and Andrew...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Modern Operating Systems by Herbert...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Page 784
SEC. 10.3
PROCESSES IN LINUX
753
Process 0
Process 1
Process 2
Page
daemon
Terminal 0
Terminal 1
Terminal 2
Login:
Password:
% cp f1 f2
login
sh
cp
getty
init
Figure 10-11.
The sequence of processes used to boot some Linux systems.
In the figure, the
getty
process running for terminal 0 is still waiting for input.
On terminal 1, a user has typed a login name, so
getty
has overwritten itself with
login
, which is asking for the password. A successful login has already occurred
on terminal 2, causing the shell to type the prompt (%).
The user then typed
cp f1 f2
which has caused the shell to fork off a child process and have that process execute
the
cp
program. The shell is blocked, waiting for the child to terminate, at which
time the shell will type another prompt and read from the keyboard. If the user at
terminal 2 had typed
cc
instead of
cp
, the main program of the C compiler would
have been started, which in turn would have forked off more processes to run the
various compiler passes.
10.4 MEMORY MANAGEMENT IN LINUX
The Linux memory model is straightforward, to make programs portable and
to make it possible to implement Linux on machines with widely differing memory
management units, ranging from essentially nothing (e.g., the original IBM PC) to
sophisticated paging hardware. This is an area of the design that has barely chang-
ed in decades.
It has worked well so it has not needed much revision. We will
now examine the model and how it is implemented.


Page 785
754
CASE STUDY 1: UNIX, LINUX, AND ANDROID
CHAP. 10
10.4.1 Fundamental Concepts
Every Linux process has an address space that logically consists of three seg-
ments: text, data, and stack.
An example process’ address space is illustrated in
Fig. 10-12(a) as process
A
. The
text segment
contains the machine instructions
that form the program’s executable code.
It is produced by the compiler and ass-
embler by translating the C, C++, or other program into machine code. The text
segment is normally read-only.
Self-modifying programs went out of style in
about 1950 because they were too difficult to understand and debug. Thus the text
segment neither grows nor shrinks nor changes in any other way.
Text
BSS
Data
Stack pointer
Stack pointer
20K
8K
0
Unused
memory
24K
8K
0K
BSS
Text
Data
(a)
(b)
(c)
OS
Physical memory
Process A
Process B
Figure 10-12.
(a) Process
A
’s virtual address space.
(b) Physical memory.
(c) Process
B
’s virtual address space.
The
data segment
contains storage for all the program’s variables, strings,
arrays, and other data.
It has two parts, the initialized data and the uninitialized
data. For historical reasons, the latter is known as the
BSS
(historically called
Block Started by Symbol
). The initialized part of the data segment contains vari-
ables and compiler constants that need an initial value when the program is started.
All the variables in the BSS part are initialized to zero after loading.
For example, in C it is possible to declare a character string and initialize it at
the same time. When the program starts up, it expects that the string has its initial
value. To implement this construction, the compiler assigns the string a location in
the address space, and ensures that when the program is started up, this location
contains the proper string. From the operating system’s point of view, initialized
data are not all that different from program text—both contain bit patterns pro-
duced by the compiler that must be loaded into memory when the program starts.
The existence of uninitialized data is actually just an optimization. When a glo-
bal variable is not explicitly initialized, the semantics of the C language say that its


Ace your assessments! Get Better Grades
Browse thousands of Study Materials & Solutions from your Favorite Schools
Concordia University
Concordia_University
School:
Operating_Systems
Course:
Great resource for chem class. Had all the past labs and assignments
Leland P.
Santa Clara University
Introducing Study Plan
Using AI Tools to Help you understand and remember your course concepts better and faster than any other resource.
Find the best videos to learn every concept in that course from Youtube and Tiktok without searching.
Save All Relavent Videos & Materials and access anytime and anywhere
Prepare Smart and Guarantee better grades

Students also viewed documents