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 106 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 106
SEC. 1.8
THE WORLD ACCORDING TO C
75
i = max(j, k+1)
and get
i = (j > k+1 ? j : k+1)
to store the larger of
j
and
k+1
in
i
.
Headers can also contain conditional compila-
tion, for example
#ifdef X86
intel
int
ack();
#endif
which compiles into a call to the function
intel
int
ack
if the macro
X86
is defined
and nothing otherwise. Conditional compilation is heavily used to isolate architec-
ture-dependent code so that certain code is inserted only when the system is com-
piled on the X86, other code is inserted only when the system is compiled on a
SPARC, and so on.
A
.c
file can bodily include zero or more header files using the
#include
directive.
There are also many header files that are common to nearly
every
.c
and are stored in a central directory.
1.8.3 Large Programming Projects
To build the operating system, each
.c
is compiled into an
object file
by the C
compiler. Object files, which have the suffix
.o
, contain binary instructions for the
target machine. They will later be directly executed by the CPU.
There is nothing
like Java byte code or Python byte code in the C world.
The first pass of the C compiler is called the
C preprocessor
.
As it reads each
.c
file, every time it hits a
#include
directive, it goes and gets the header file named
in it and processes it, expanding macros, handling conditional compilation (and
certain other things) and passing the results to the next pass of the compiler as if
they were physically included.
Since operating systems are very large (five million lines of code is not
unusual), having to recompile the entire thing every time one file is changed would
be unbearable.
On the other hand, changing a key header file that is included in
thousands of other files does require recompiling those files. Keeping track of
which object files depend on which header files is completely unmanageable with-
out help.
Fortunately, computers are very good at precisely this sort of thing.
On UNIX
systems, there is a program called
make
(with numerous variants such as
gmake
,
pmake
, etc.) that reads the
Makefile
, which tells it which files are dependent on
which other files. What
make
does is see which object files are needed to build the
operating system binary and for each one, check to see if any of the files it depends
on (the code and headers) have been modified subsequent to the last time the ob-
ject file was created.
If so, that object file has to be recompiled.
When
make
has
determined which
.c
files have to recompiled, it then invokes the C compiler to


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