Professional Documents
Culture Documents
Systems:
Internals Chapter 2
and Design
Principles Operating System
Overview
Ninth Edition, Global Edition
By William Stallings
• Convenience
• Efficiency
• Ability to evolve
Memory
System interconnect
translation Hardware
(bus)
I/O devices
Main
and
memory
networking
n Program development
n Program execution
n Access I/O devices
n Controlled access to files
n System access
n Error detection and response
n Accounting
Programs
and Data
I/O Controller
Processor Processor
Storage
OS
Programs
Data
Hardware upgrades
New services
Fixes
Time
Sharing
Multiprogrammed Systems
Batch Systems
Simple Batch
Systems
Serial
Processing
n Monitor
n User no longer has direct access to processor
n Job is submitted to computer operator who batches
them together and places them on an input device
n Program branches back to the monitor when finished
• While the user program is executing, it must not alter the memory area
containing the monitor
Timer
Privileged instructions
Interrupts
I/O devices
are slow
compared
to processor
Even with
automatic
job
sequencing
Processor is often
idle
1
Percent CPU Utilization = = 0.032 = 3.2%
31
Time
(a) Uniprogramming
Multiprogramming Time
(a) Uniprogramming
n There must be enough memory to hold the OS (resident monitor) and one user
Program A
program Run Wait Run Wait
n When one job needs to wait for I/O, the processor can switch to the other job, which is
likely not waiting
Program B for I/ORun
Wait Wait Run Wait
Copyright © 2018 Pearson Education, Ltd. All Rights Reserved.
Program B Wait Run Wait Run Wait
Multiprogramming
Combined Wait Wait
A B A B
Time
(b) Multiprogramming with two programs
CPU CPU
0% 0%
100% 100%
Memory Memory
0% 0%
100% 100%
Disk Disk
0% 0%
100% 100%
Terminal Terminal
0% 0%
100% 100%
Printer Printer
0% 0%
time 0 5 10 15
minutes
time
(a) Uniprogramming (b) Multiprogramming
0 0 0
Monitor Monitor Monitor
5000 5000 5000
JOB 4
JOB 1
15000 JOB 2
(JOB 1)
20000 20000
(JOB 2) (JOB 2)
25000 25000 25000
Free Free Free
32000 32000 32000
(d) (e) (f)
A program in execution
PC
Process
i
Process Base b
list Limit h
j
Management Other
registers
Context
Process
§ The entire state of the A
Data
Program
process at any instant is (code)
contained in its context
b
Data
designed and incorporated B h
Program
into the OS by expanding (code)
the context to include any
new information needed to
support the feature
Figure 2.8 Typical Process Implementation
Copyright © 2018 Pearson Education, Ltd. All Rights Reserved.
Memory Management
n The OS has five principal storage
management responsibilities:
Automatic
Support of Protection
Process allocation Long-term
and modular and access
isolation programming control storage
management
User
program
A
B.5 B.6
Disk
Address
Secondary
Memory
n Resource allocation
policies must Differential
consider: responsiveness
Pass Control
to Process
• Microkernel architecture
• Multithreading
• Symmetric multiprocessing
• Distributed operating systems
• Object-oriented design
n The approach:
Well suited to a
Simplifies Provides distributed
implementation flexibility
environment
divided into
threads that can By breaking a single
run concurrently
application into multiple
Includes a processor context threads, a programmer has
and its own data area for a greater control over the
stack modularity of the
application and the timing
of application-related events
Process 1
Process 2
Process 3
Process 1
Process 2
Process 3
Blocked Running
Down
A1 A2 A3
B1 B2 B3 A1 A2 A3
MTTF MTTR
3 3
n Permanent
• A fault that, after it occurs, is always present
• The fault persists until the faulty component is replaced or repaired
n Temporary
• A fault that is not present all the time for all operating conditions
• Can be classified as
n Transient – a fault that occurs only once
n Intermittent – a fault that occurs at multiple, unpredictable times
Ntdll.dll
System
threads User mode
Kernel mode
System service dispatcher
(Kernel-mode callable interfaces)
Win32 USER,
I/O manager
manager (registry)
GDI
Security reference
File system cache
Local procedure
Object manager
Virtual memory
Power manager
Configuration
Processes and
Plug and play
manager
monitor
threads
call
Device
and file Graphics
system drivers
drivers
Kernel
Hardware abstraction layer (HAL)
n Kernel
n Controls execution of the processors. The Kernel manages thread scheduling, process switching,
exception and interrupt handling, and multiprocessor synchronization
n Device Drivers
n Dynamic libraries that extend the functionality of the Executive. These include hardware device
drivers that translate user I/O function calls into specific hardware device I/O requests and
software components for implementing file systems, network protocols, and any other system
extensions that need to run in kernel mode
n Server processes may use multiple threads to process requests from more
than one client simultaneously
n The first notable milestone was porting the UNIX system from the PDP-7 to the
PDP-11
n First showed that UNIX would be an OS for all computers
n First widely available version outside Bell Labs was Version 6 in 1976
n Most important of the non-AT&T systems was UNIX BSD (Berkeley Software
Distribution), running first on PDP and then on VAX computers
Trap
Libraries
User Level
Inter-process
communication
File Subsystem
Process
Control Scheduler
Subsystem
Memory
Buffer Cache
management
character block
Device Drivers Kernel Level
Hardware Control
Hardware Level
exec
switch
NFS
file mappings
FFS
virtual
device memory vnode/vfs
mappings framework interface
s5fs
anonymous RFS
mappings
Common
Facilities
network tty
driver driver
FigureFigure
2.17 2.16 Modern
Modern UNIXUNIX Kernel
Kernel [VAHA96]
Copyright © 2018 Pearson Education, Ltd. All Rights Reserved.
FreeBSD 11.0
BSD NetBSD 7.0
Family
OpenBSD 6.0
BSD (Berkeley Software Distribution) 4.4
SunOS 4.1.4
Xenix OS
GNU
Linux 4.7
n 4.xBSD is widely used in academic installations and has served as the basis of a
number of commercial UNIX products
value value
*name *name
processes
& scheduler
file network
systems protocols
kernel
virtual
memory
char device block device network de-
drivers drivers vice drivers
hardware
system network inter-
CPU terminal disk
memory face controller
Application Framework
Activity Manager Windows Content Providers View System Notification
Manager Manager
Linux Kernel
Display Driver Camera Driver Bluetooth Driver Flash Memory Binder (IPC)
Driver Driver
Implementation:
Applications, Application Framework: Java
Linux Kernel: C
n Key components:
These Allows
functions developers to
encapsulate Manages tap into
application application Provides the location- Provides
user interface Manages standardized
data that resources, based events, such
need to be such as (UI) services, messaging
primitives as as arriving functions
shared localized whether by messages and
between strings and well as UI GPS, cell between
Events appointments applications
applications bitmaps tower IDs, or
such as local Wi-Fi
contacts databases
package
zip
Source Dex File APK
install
Resources &
Native Code
Dex File
n Improves battery life because n On the first fresh boot or first boot after
processor usage for JIT is avoided factory reset, all applications installed
on a device are compiled to native code
n Lesser RAM footprint is required using dex2opt, therefore the first boot
for the application to run as there can take significantly longer to reach
is no storage required for JIT Home Screen compared to Dalvik
cache
n The native code thus generated is
n There are a number of Garbage stored on internal storage that requires
Collection optimizations and a significant amount of additional
debug enhancements that went internal storage space
into ART
Binder IPC
Camera Activity
Other Media
Service Manager Other Services
Services
Android Runtime/Dalvik
Linux Kernel
Audio Driver
Camera Driver Display Drivers
(ALSA, OSS, etc) Other Drivers