Introduction
Introduction
CS 1550, cs.pitt.edu
(originaly modified by Ethan
L. Miller and Scott A. Brandt)
Second generation: batch systems
CS 1550, cs.pitt.edu
(originaly modified by Ethan
L. Miller and Scott A. Brandt)
Third generation: multiprogramming
• Multiple jobs in memory
– Protected from one another
Job 3 • Operating system
protected from each job
as well
Job 2
• Resources (time,
Memory hardware) split between
partitions Job 1
jobs
• Still not interactive
Operating – User submits job
system – Computer runs it
– User gets results minutes
(hours, days) later
Timesharing
• Multiprogramming allowed several jobs to be
active at one time
– Initially used for batch systems
– Cheaper hardware terminals -> interactive use
• Computer use got much cheaper and easier
– No more “priesthood”
– Quick turnaround meant quick fixes for problems
Views of an Operating System
• There are three classical views (in
literature):
1. Resource Manager – manages and allocates
resources.
2. Control program – controls the execution of
user programs and operations of I/O devices.
3. Command Executer – Provides an
environment for running user commands.
• But one more modern view: Operating
System as a Virtual Machine.
A. Frank - P. Weisberg
Operating System as a Resource
Manager
∙ Allow multiple programs to run at the same time
∙ Manage and protect memory, I/O devices, and other
resources
✔ Manages and protects multiple computer
resources: CPU, Processes, Internal/External
memory, Tasks, Applications, Users,
Communication channels, etc…
✔ Handles and allocates resources to multiple users
or multiple programs running at the same time
and space (e.g., processor time, memory, I/O
devices).
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Resource Manager oriented OS
names
• DEC RSX – Resource Sharing eXecutive
• MIT Multics – MULTiplexed Information and
Computing Services
• IBM MFT/MVT – Multiple Fixed/Variable Tasks
• IBM MVS – Multiple Virtual Storage
• DEC VMS – Virtual Memory System
• MVS TSO – Time Sharing Option
• CTSS – Compatible Time Sharing System
• IBM VM – Virtual machine
A. Frank - P. Weisberg
2. Control Program
• Control Program:
– Manages all the components of a complex
computer system in an integrated manner.
– Controls the execution of user programs and I/O
devices to prevent errors and improper use of
computer resources.
– Looks over and protects the computer: Monitor,
Supervisor, Executive, Controller, Master,
Coordinator ….
Control program oriented OS
names
• Unisys MCP – Master Control Program
• DR CP/M – Control
Program/Microcomputer
• IBM VM/CP – VM Control Program
• IBM AIX – Advanced Interactive eXecutive
• DEC RSX – Resource Sharing eXecutive
A. Frank - P. Weisberg
3. Command Executer
• Command Executer:
– Interfaces between the users and machine.
– Supplies services/utilities to users.
– Provides the users with a convenient CLI
(Command Language Interface), also called a
Shell (in UNIX), for entering the user commands.
A. Frank - P. Weisberg
Command Executer oriented OS names
A. Frank - P. Weisberg
UNIX System Layout
A. Frank - P. Weisberg
Storage Structure
• Ideally, we want the programs and data to reside in
main memory permanently.
• This arrangement usually is not possible for the
following two reasons:
1. Main memory is usually too small to store all
needed programs and data permanently.
2. Main memory is a volatile storage device that
loses its contents when power is turned off or
otherwise lost.
Various Storage Systems
• The main differences among the
various storage systems lie in
speed, cost, size, and volatility.
• The wide variety of storage
systems can be organized in a
hierarchy according to speed
and cost.
• The higher levels are expensive,
but they are fast.
• As we move down the hierarchy,
the cost per bit generally
decreases, whereas the access
time generally increases.
Storage pyramid
Addres Addres
0x2ffff User 0x2ffff
s program s
0x2d000
User data
0x2b000 and data 0x2bfff Limit2
User data
0x27fff User Limit 0x29000 Base
program 0x24fff User 2
Limit 1
0x23000 and data Bas 0x23000 program Base
e 1
0x1dfff
Operati 0x1dfff
Operati
ng ng
0 system 0 system
Single base/limit pair: set for each process
Two base/limit registers: one for program, one for data
The 4 Cache Questions
• When to put a new item into the cache?
• Which cache line to put the new item in?
• Which item to remove from the cache when a slot
is needed?
• Where to put a newly evicted item in main
memory?
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
OPERATING SYSTEM OVERVIEW:
Characteristics
• Time Sharing - multiprogramming
environment that's also interactive.
• Multiprocessing - Tightly coupled
systems that communicate via
shared memory. Used for scientific
applications. Used for speed
improvement by putting together a
number of off-the-shelf processors.
• Distributed Systems - Loosely
coupled systems that communicate
via message passing. Advantages
include resource sharing, speed up,
reliability, communication.
• Real Time Systems - Rapid
response time is main characteristic.
Used in control of applications
where rapid response to a stimulus
is essential.
Multiprocessor Systems
• Multiprocessor systems first appeared
prominently appeared in servers and have
since migrated to desktop and laptop
systems.
• Recently, multiple processors have
appeared on mobile devices such as
smartphones and tablet computers.
Multiprocessor System: Advantages
1. Increased throughput. By increasing the
number of processors, we expect to get more
work done in less time.
2. Economy of scale. Multiprocessor systems can
cost less than equivalent multiple
single-processor systems, because they can
share peripherals, mass storage, and power
supplies.
3. Increased reliability. If functions can be
distributed properly among several processors,
then the failure of one processor will not halt the
system, only slow it down.
Features
• Increased reliability of a computer system is crucial in
many applications.
• The ability to continue providing service proportional to
the level of surviving hardware is called graceful
degradation.
• Some systems go beyond graceful degradation and
are called fault tolerant, because they can suffer a
failure of any single component and still continue
operation.
• Fault tolerance requires a mechanism to allow the failure
to be detected, diagnosed, and, if possible, corrected.
• The HP NonStop (formerly Tandem) system uses both
hardware and software duplication to ensure continued
operation despite faults.
Multiprocessing System Types
• Asymmetric: Master-Slave
• Symmetric (SMP): Each processor performs all
tasks within the operating system.
– SMP means that all processors are peers
– An example of an SMP system is AIX, a commercial
version of UNIX designed by IBM.
– An AIX system can be configured to employ dozens of
processors.
– The benefit of this model is that many processes can run
simultaneously—N processes can run if there are N
CPUs—without causing performance to deteriorate
significantly.
• Multiprocessing adds CPUs to increase computing
power. If the CPU has an integrated memory
controller, then adding CPUs can also increase the
amount of memory addressable in the system.
SMP vs Asymmetric
• Sun Microsystems’ operating system SunOS
Version 4 provided asymmetric multiprocessing,
whereas Version 5 (Solaris) is symmetric on the
same hardware. (Software decides)
• Hardware may also decide SMP/Asymmetric.
Recent OS Design Requirements
• A recent trend in CPU design is to include multiple
computing cores on a single chip.
• Such multiprocessor systems are termed
multicore.
• They can be more efficient than multiple chips with
single cores because on-chip communication is
faster than between-chip communication.
• In addition, one chip with multiple cores uses
significantly less power than multiple single-core
chips.
• It is important to note that while multicore systems
are multiprocessor systems, not all multiprocessor
systems are multicore.
Multithreaded and Multicore Chips
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Device Driver
∙ OS software that talks to controller-gives
commands, accepts responses
∙ Each controller manufacturer supplies a driver
for each OS
∙ Driver runs in kernel mode
∙ Controller has registers which are used to
communicate with the driver
∙ Three modes of communication
∙ Polling
∙ Interrupts
∙ DMA
Tanenb aum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
I/O by polling device
∙ Driver issues command to controller
∙ Driver polls device until it is ready
∙ E.g. Send character to printer controller and
poll until it is ready to accept the next character
∙ Big use of CPU
∙ Called programmed I/O-not really used any
more
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Memory Management
• To execute a program all (or part) of the
instructions must be in memory
• All (or part) of the data that is needed by
the program must be in memory.
• Memory management determines what is in
memory and when
– Optimizing CPU utilization and computer
response to users
Memory Management Activities
• Keeping track of which parts of memory
are currently being used and by whom
• Deciding which processes (or parts
thereof) and data to move into and out of
memory
• Allocating and deallocating memory space
as needed
Storage Management
• OS provides uniform, logical view of information
storage
– Abstracts physical properties to logical storage unit - file
– Each medium is controlled by device (i.e., disk drive, tape
drive): Varying properties include access speed, capacity,
data-transfer rate, access method (sequential or random)
• File-System management
– Files usually organized into directories
– Access control on most systems to determine who can
access what
– OS activities include
• Creating and deleting files and directories
• Primitives to manipulate files and directories
• Mapping files onto secondary storage
• Backup files onto stable (non-volatile) storage media
Mass-Storage Management
• Usually disks used to store data that does not fit in main
memory or data that must be kept for a “long” period of
time
• Proper management is of central importance
• Entire speed of computer operation hinges on disk
subsystem and its algorithms
• OS activities
– Free-space management
– Storage allocation
– Disk scheduling
• Some storage need not be fast
– Tertiary storage includes optical storage, magnetic tape
– Still must be managed – by OS or applications
– Varies between WORM (write-once, read-many-times) and RW
(read-write)
Computing Environments -
Virtualization
• Emulation used when source CPU type different
from target type
– Generally slowest method
– When computer language not compiled to native code
– Interpretation
• Virtualization – OS natively compiled for CPU,
running guest
– OSes also natively compiled
– Consider VMware running WinXP guests, each running
applications, all on native WinXP host OS
– VMM provides virtualization services
Computing Environments - Virtualization
• Use cases involve laptops and desktops running
multiple OSes for exploration or compatibility
– Apple laptop running Mac OS X host, Windows as a
guest
– Developing apps for multiple OSes without having
multiple systems
– QA testing applications without having multiple systems
– Executing and managing compute environments within
data centers
• VMM can run natively, in which case they are also the host
– There is no general purpose host then (VMware ESX and
Citrix XenServer)
Computing Environments -
Virtualization
Virtual Machines (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Computing Environments – Cloud
Computing
• Delivers computing, storage, even apps as a service across
a network
• Logical extension of virtualization as based on virtualization
– Amazon EC2 has thousands of servers, millions of VMs, PBs of
storage available across the Internet, pay based on usage
• Many types
– Public cloud – available via Internet to anyone willing to pay
– Private cloud – run by a company for the company’s own use
– Hybrid cloud – includes both public and private cloud components
– Software as a Service (SaaS) – one or more applications available via
the Internet (i.e. word processor)
– Platform as a Service (PaaS) – software stack ready for application
use via the Internet (i.e a database server)
– Infrastructure as a Service (IaaS) – servers or storage available over
Internet (i.e. storage available for backup use)
Computing Environments – Cloud
Computing
• Cloud compute environments
composed of traditional OSes,
plus VMMs, plus cloud
management tools
– Internet connectivity requires
security like firewalls
– Load balancers spread traffic across
multiple applications
Kernel Data Structures
• Many similar to standard programming data
structures
• Singly linked list
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
System Calls for File Management (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
System Calls for File Management (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Miscellaneous System Calls
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Examples of Windows and
Unix System Calls
Standard C Library Example
• C program invoking printf() library call, which
calls write() system call
Memory Layout
• Processes have three segments:
text, data, and stack.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Shell
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
fork
• pid=fork()
• Duplicates parent process completely
Everything duplicated -data,registers,fd’s
• Fork returns a value (pid)
• Zero in child
• Child’s PID in parent
• Used to differentiate child from parent
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
fork and other calls
fork example code
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
excve (example)
• cp f1 f2 is located by execve and parameters
are passed to it by execve
• main(argc, argv, envp) is main prog in cp
• argc is #items on command line (=3 in cp)
• argv points to array (arg[0] points to cp, arg[1] points to f1,
• envp points to environment, an array of name=value with info like
terminal type
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
fork with wait (more deterministic)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int argc, char *argv[]) {
printf("hello world (pid:%d)\n", (int) getpid());
int rc = fork();
if (rc < 0) { // fork failed; exit
fprintf(stderr, "fork failed\n");
exit(1);
} else if (rc == 0) { // child (new process)
printf("hello, I am child (pid:%d)\n", (int) getpid());
} else { // parent goes down this path (main)
int rc_wait = wait(NULL);
printf("hello, I am parent of %d (rc_wait:%d) (pid:%d)\n",
rc, rc_wait, (int) getpid());
}
return 0; }
fork with exec (p3.c)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/wait.h>
int main(int argc, char *argv[]) {
printf("hello world (pid:%d)\n", (int) getpid());
int rc = fork();
if (rc < 0) { // fork failed; exit
fprintf(stderr, "fork failed\n");
exit(1);
} else if (rc == 0) { // child (new process)
printf("hello, I am child (pid:%d)\n", (int) getpid());
char *myargs[3];
myargs[0] = strdup("wc"); // program: "wc" (word count)
myargs[1] = strdup("p3.c"); // argument: file to count
myargs[2] = NULL; // marks end of array
execvp(myargs[0], myargs); // runs word count
printf("this shouldn’t print out");
} else { // parent goes down this path (main)
int rc_wait = wait(NULL);
printf("hello, I am parent of %d (rc_wait:%d) (pid:%d)\n",rc, rc_wait, (int) getpid());
}
return 0;
}
Redirection (wc p3.c > newfile.txt)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/wait.h>
• If no signal name or number is specified, the default is to send a SIGTERM signal to the
process, which normally causes its termination, and hence the name of the kill command.
• If SIGTERM fails, we can escalate to using the SIGKILL signal to stop the process:
• kill -9 4140
• Because SIGKILL cannot be handled, stopping a process with SIGKILL is generally
considered a bad idea. Using SIGKILL prevents a process from cleaning up after itself and
exiting gracefully.
• fg On most shells, using the 'fg' command will resume execution of the process (that
was suspended with Ctrl-Z), by sending it a CONT signal.
Catchable And Non-Catchable
Signals
• SIGKILL signal (kill -9 command in Unix) is such a
signal. This is use to shut down using this signal if it
gets "wild".
• One process that uses this signal is a system shutdown
process. It first sends a TERM signal to all processes, waits a
while, and after allowing them a "grace period" to shut down
cleanly, it kills whichever are left using the KILL signal.
• SIGSTOP is also a signal that a process cannot
catch, and forces the process's suspension
immediately.
• This is useful when debugging programs whose
behavior depends on timing.
More on Kill
• For a 'polite' stop to the process, send SIGTSTP:
• kill -TSTP [pid]
https://www.gnu.org/software/libc/manual/html_node/Job-Control-Signals.html
Important
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Example: MS-DOS
• Single-tasking
• Shell invoked when
system booted
• Simple method to run
program
– No process created
• Single memory space
• Loads program into
memory, overwriting
all but the kernel
• Program exit -> shell
reloaded (a) At system startup (b) running a program
Example: FreeBSD
• Unix variant
• Multitasking
• User login -> invoke user’s
choice of shell
• Shell executes fork() system call
to create process
– Executes exec() to load program
into process
– Shell waits for process to
terminate or continues with user
commands
• Process exits with code of 0 – no
error or > 0 – error code
System Programs
• System programs provide a convenient
environment for program development and
execution.
System Programs
• Most users’ view of the operating system is defined by
system programs, not the actual system calls
• Status information
– Some ask the system for info - date, time, amount of available
memory, disk space, number of users
– Others provide detailed performance, logging, and debugging
information
– Typically, these programs format and print the output to the
terminal or other output devices
– Some systems implement a registry - used to store and retrieve
configuration information
System Programs (Cont.)
• File modification
– Text editors / commands to search contents of files or
perform transformations of the text
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Layered Approach
• The operating system is
divided into a number of
layers (levels), each built
on top of lower layers.
The bottom layer (layer
0), is the hardware; the
highest (layer N) is the
user interface.
• With modularity, layers
are selected such that
each uses functions
(operations) and
services of only
Microkernel System Structure
• Moves as much from the kernel into user space
• Mach example of microkernel.
– Mac OS X kernel (Darwin) partly based on Mach.
• Benefits:
– Easier to extend a microkernel
– Easier to port the operating system to new architectures
– More reliable (less code is running in kernel mode)
– More secure
• Detriments:
– Performance overhead of user space to kernel space
communication
Microkernel System Structure
Modules
• Most modern operating systems implement
loadable kernel modules.
– Uses object-oriented approach
– Each core component is separate
– Each talks to the others over known interfaces
– Each is loadable as needed within the kernel
• Overall, similar to layers but with more
flexible.
– Linux, Solaris, etc
Solaris Modular Approach
Hybrid Systems
• Most modern operating systems actually not one
pure model
– Hybrid combines multiple approaches to address
performance, security, usability needs
– Linux and Solaris kernels in kernel address space, so
monolithic, plus modular for dynamic loading of
functionality
– Windows mostly monolithic, plus microkernel for different
subsystem personalities
• Apple Mac OS X hybrid, layered, Aqua UI plus
Cocoa programming environment
– Kernel consists of Mach microkernel and BSD Unix parts,
plus I/O kit and dynamically loadable modules (called
kernel extensions)
Mac OS X Structure
iOS
• Apple mobile OS for iPhone, iPad
– Structured on Mac OS X, added
functionality
– Does not run OS X applications
natively
• Also runs on different CPU architecture
(ARM vs. Intel)
– Cocoa Touch Objective-C API for
developing apps
– Media services layer for graphics,
audio, video
– Core services provides cloud
computing, databases
– Core operating system, based on Mac
OS X kernel
Android
• Developed by Open Handset Alliance (mostly
Google): Purchased by Google in 2005
– AOSP
• Similar stack to IOS
• Based on Linux kernel but modified
– Provides process, memory, device-driver management
– Adds power management
• Runtime environment includes core set of libraries and
Dalvik virtual machine
– Apps developed in Java plus Android API
• Java class files compiled to Java bytecode then translated to
executable than runs in Dalvik VM
• Libraries include frameworks for web browser
(webkit), database (SQLite), multimedia, smaller libc
Android Architecture
Android Linux Kernel
• Android kernel lacks drivers not applicable in
mobile environments, making the kernel
smaller.
• In addition, Android enhances the Linux
kernel with features that are tailored to the
mobile environment, and generally not as
useful or applicable on a desktop or laptop
platform.
Android Runtime Concepts (ART)
• Current application runtime used by Android,
introduced with Android version 4.4 (KitKat).
– When Android was designed initially, it was designed for
single core (with minimal multithreading support in
hardware) and low-memory devices
• All Android applications written in Java are compiled
to dex bytecode.
– While Dalvik uses dex bytecode format for portability, it
has to be converted (compiled) to machine code to be
actually run by a processor.
– The Dalvik runtime did this conversion from dex bytecode
to native machine code when the application ran, and this
process was called JIT (just-in-time) compilation.
– Because JIT compiles only a part of the code, it has a
smaller memory footprint and uses less physical space on
the device
Dalvik vs ART
• Dalvik has to do JIT-compilation every time the
app is run, which consumes a considerable
amount of processor resources.
• ART also executes dex bytecode but instead of
compiling the bytecode at runtime, ART compiles
the bytecode to native machine code during
install time of the app.
• This is called aheadof-time (AOT) compilation.
• ART uses the “dex2oat” tool to do this
compilation at install time.
• The output of the tool is a file that is then
executed when the application runs.
Life cycle of an APK
•The cycle begins with
source code being
compiled into .dex format
and combined with any
appropriate support code to
form an APK.
•On the user side, the
received APK is unpacked.
• The resources and native
code are generally installed
directly into the application
directory.
•The output of the dex2oat
function is an Executable
and Linkable Format (ELF)
file, which runs directly
without an interpreter.
System Libraries
• The layer below the Application Framework
consists of two parts: System Libraries, and
Android Runtime.
• The System Libraries component is a collection
of useful system functions, written in C or C+ +
and used by various components of the Android
system.
• They are called from the application framework
and applications through a Java interface.
• These features are exposed to developers
through the Android application framework.
System Libraries
• Surface Manager: Android uses a compositing window
manager similar to Vista or Compiz, but it is much
simpler.
– Instead of drawing directly to the screen buffer, drawing
commands go into off-screen bitmaps that are then
combined with other bitmaps to form the screen content.
– Create interesting effects, such as see-through windows
• OpenGL: OpenGL (Open Graphics Library) is a
cross-language, multiplatform API for rendering 2D and
3D computer graphics.
– OpenGL/ES (OpenGL for embedded systems) is a subset
of OpenGL designed for embedded systems.
• Media Framework: The Media Framework supports
video recording and playing in many formats, including
AAC, AVC (H.264), H.263, MP3, and MPEG-4.
System Libraries
• SQL Database: Android includes a lightweight
SQLite database engine for storing persistent data.
• Browser Engine: For fast display of HTML
content, Android uses the WebKit library, which is
essentially the same library used in Safari and
iPhone.
– It was also the library used for the Google Chrome
browser until Google switched to Blink.
• Bionic LibC: This is a stripped-down version of
the standard C system library, tuned for embedded
Linux-based devices.
– The interface is the standard Java Native Interface (JNI).
Android System Architecture
Operating-System Debugging
• Debugging is finding and fixing errors, or bugs
• OSes generate log files containing error
information
– Failure of an application can generate core dump file
capturing memory of the process
– Operating system failure can generate crash dump file
containing kernel memory
• Beyond crashes, performance tuning can optimize
system performance
– Sometimes using trace listings of activities, recorded
for analysis
– Profiling is periodic sampling of instruction pointer to
look for statistical trends
OS Performance Tuning
• Improve performance
by removing
bottlenecks
• OS must provide
means of computing
and displaying
measures of system
behavior
– For example, “top”
program or Windows
Task Manager
Dtrace: Performance analysis and
Troubleshooting tool
● DTrace tool in Solaris,
FreeBSD, Mac OS X
allows live instrumentation
on production systems
● Probes fire when code is
executed within a
provider, capturing state
data and sending it to
consumers of those
probes
● Example of following
XEventsQueued system
call move from libc
library to kernel and back
DTrace
● DTrace code to record
amount of time each process
with UserID 101 is in running
mode (on CPU) in
nanoseconds
Operating System Generation
• Operating systems are designed to run on any of a
class of machines; the system must be configured
for each specific computer site
• SYSGEN program obtains information concerning
the specific configuration of the hardware system
– Used to build system-specific compiled kernel or
system-tuned
– Can general more efficient code than one general
kernel
– Combine user-specified options and parameters with
manufacturer-supplied general-purpose program code
to produce an operating system tailored for a particular
hardware and software environment.
System Boot
• When power initialized on system, execution starts
at a fixed memory location
– Firmware ROM used to hold initial boot code
• Operating system must be made available to
hardware so hardware can start it
– Small piece of code – bootstrap loader, stored in
ROM or EEPROM locates the kernel, loads it into
memory, and starts it
– Sometimes two-step process where boot block at
fixed location loaded by ROM code, which loads
bootstrap loader from disk
• Common bootstrap loader, GRUB, allows
selection of kernel from multiple disks, versions,
kernel options
• Kernel loads and system is then running
Boot up phases
• There are 4 phases to starting up the system:
• BIOS
• Boot loader
• Kernel
• Upstart (which manages system tasks and
services )
Core Boot Tasks Started by Upstart
• Plymouth - The graphical boot animation and
logger
• mountall - Mounts all filesystems defined on
/etc/fstab
• network* - Network related services
• Display Manager (GDM,KDM,XDM,...)
• (upstart tasks/services are configured at
/etc/init)
BIOS Phase
• When the computer begins execution, it starts
by executing this code, which is also called the
firmware, as it is normally stored in a permanent
form of memory, such as ROM, on the
computer's motherboard.
• On a Macintosh computer this is the
OpenFirmware.
• This code must initialize the hardware other than
the CPU, and obtain the code for the next step,
the boot loader.
• Modern computers provide several possibilities
for the boot loader and the choice is normally
set on the BIOS startup screen.
Boot Loader Phase
• There are several possible types of boot loaders
and ways for the BIOS to obtain them.
• A boot loader stored in the first sector of a hard
disk, the Master Boot Record, or MBR.
– This may be GRUB or LILO or yaboot or others.
• A boot loader stored on some other storage
device, such as a CDR or USB flash drive.
• A boot loader which uses the network, such as
the Pre-Execution Environment (PXE).
– This code is normally stored on a ROM on the
networking card itself.
• The job of the boot loader is to begin the next
phase, loading the kernel and an initial ram disk
filesystem.
Kernel Phase
• The bootloader starts the kernel running.
• To keep kernels to a reasonable size and
permit separate modules for separate
hardware, modern kernels also use a file
system which is present in memory, called an
'initrd' for 'initial ram disk'.
– Both the kernel file to load and the initial ram disk
are normally specified as options to the boot
loader.
• The kernel launches the init script inside the
initrd file system, which loads hardware
drivers and finds the root partition.
System startup
• After the kernel is running, the remainder of the
operating system is brought online.
• First the root partition and filesystem is located,
checked and mounted.
• Next the init process is started, which runs the
initialization scripts.
• These scripts involve different /etc/rc scripts and
upstart events that eventually gives you a
ready-to-use computer with a login screen.
– The root partition with the operating system can be
somewhere completely different than the kernel, for
instance on another drive or on a remote computer.