Chap 2 Lectures
Chap 2 Lectures
Stallings - 9th Ed
Application programs
Application
programming interface
Application Libraries/utilities Software
binary interface
Operating system
Instruction Set
Architecture
Execution hardware
Memory
System interconnect
translation Hardware
(bus)
I/O devices
Main
and
memory
networking
Sequence 2 CS240 6
Services Provided by the
Operating System (3)
• Accounting
– Collect usage statistics
– Monitor performance
– Used to anticipate future enhancements
– Used for billing purposes
– check out the log files of a unix system
• where do you find this information?
Sequence 2 CS240 7
Operating System
• Responsible for managing resources
• An OS is just a program (or set of
programs) that is executed
Sequence 2 CS240 8
Interrupt
Processing
Device
Drivers
Monitor
Job
Sequencing
Control Language
Interpreter
Boundary
User
Program
Area
Sequence 3 CS240 2
Job Control Language (JCL)
• Special type of programming language
• Provides instruction to the monitor, e.g.
– What compiler to use
– What data to use
Sequence 3 CS240 3
Hardware Features of Interest
in Operating Systems
• User/Supervisor Mode
• Interrupts/Traps/Exceptions
• Real-time Clock (Timer) Operation
• Support for Virtual Memory and Memory Protection
Hardware Features
• Memory protection
– Do not allow the memory area containing
the monitor to be altered
• Timer
– Prevents a job from monopolizing the
system
Sequence 3 CS240 4
Hardware Features
• Privileged instructions
– Certain machine level instructions can only
be executed by the monitor
• Interrupts
– Early computer models did not have this
capability
Sequence 3 CS240 5
Memory Protection
• User program executes in user mode
– Certain instructions may not be executed
• Monitor executes in system mode
– Kernel mode
– Privileged instructions are executed
– Protected areas of memory may be accessed
Sequence 3 CS240 6
Traps and Interrupts and Exceptions (Oh My!)
• Trap - Caused by executing a “trap” instruction. Used to request an operation
from the operating system. Also called a “syscall” or “synchronous trap.”
1
Percent CPU Utilization = = 0.032 = 3.2%
31
Sequence 3 CS240 9
Multiprogramming
• When one job needs to wait for I/O, the
processor can switch to the other job
Sequence 3 CS240 10
Multiprogramming
Sequence 3 CS240 11
Time Sharing
• Using multiprogramming to handle
multiple interactive jobs
• Processor s time is shared among
multiple users
• Multiple users simultaneously access the
system through terminals
Sequence 3 CS240 14
0 0 0
Monitor Monitor Monitor
5000 5000 5000
JOB 3
10000
JOB 1
JOB 2
(JOB 2)
20000
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)
Sequence 3 CS240 16
Processes
• A program in execution
• An instance of a program running on a
computer
• The entity that can be assigned to and
executed on a processor
• A unit of activity characterized by a
single sequential thread of execution, a
current state, and an associated set of
system resources
Sequence 3 CS240 17
Memory Management
• Process isolation
– non-interference between independent procs.
• Automatic allocation and management
– should be transparent to programmer
• Support of modular programming
• Protection and access control
• Long-term storage
– after computer has been powered down
Sequence 3 CS240 21
Virtual Memory
• Allows programmers to address memory
from a logical point of view
• No hiatus between the execution of
successive processes while one process
was written out to secondary store and
the successor process was read in
Sequence 3 CS240 22
Virtual Memory and File System
• Implements long-term store
• Information stored in named objects
called files
Sequence 3 CS240 23
Real
Memory Address
Processor Management
Virtual Unit
Address Main
Memory
Disk
Address
Secondary
Memory
Sequence 3 CS240 27
Information Protection and
Security
• Data integrity
– Protection of data from unauthorized
modification
• Authenticity
– Concerned with the proper verification of
the identity of users and the validity of
messages or data
Sequence 3 CS240 28
Scheduling and Resource
Management
• Fairness
– Give equal and fair access to resources
• Differential responsiveness
– ...but, OS also needs to discriminate among
different classes of jobs
• Efficiency
– Maximize throughput, minimize response
time, and accommodate as many uses as
possible
Sequence 3 CS240 29
Operating System
Service Call Service
from Process Call
Handler (code)
Pass Control
to Process
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)
Lsass = local security authentication server Colored area indicates Executive
POSIX = portable operating system interface
GDI = graphics device interface
DLL = dynamic link libraries
Figure 2.14 Windows Architecture
User Programs
Trap
Libraries
User Level
System Call Interface
Inter-process
communication
File Subsystem
Process
Control Scheduler
Subsystem
Memory
Buffer Cache
management
character block
Device Drivers Kernel Level
Hardware Control
Hardware Level
Figure 2.15 Traditional UNIX Kernel
coff
a.out elf
exec
switch
NFS
file mappings
FFS
virtual
device memory vnode/vfs
mappings framework interface
s5fs
anonymous
RFS
mappings
Common
Facilities
disk driver time-sharing
block processes
device scheduler
switch framework
tape driver system
processes
STREAMS
network tty
driver driver
Figure 2.16 Modern UNIX Kernel
FreeBSD 11.0
BSD NetBSD 7.0
Family
OpenBSD 6.0
BSD (Berkeley Software Distribution) 4.4
SunOS 4.1.4
NextStep 3.3 OS X (now macOS) 10.12
Xenix OS
GNU
Linux 4.7
Research Unix (Bell Labs) 10.5
Commercial Unix (AT&T) UnixWare (Univel/SCO)
Solaris (Sun/Oracle) 11.3
System V HP-UX 11iv3
Family
AIX (IBM) 7.2
1970 1980 1990 2000 2010 2016
Figure 2.17 Unix Family Tree
module module
*next *next
*name *name
version version
srcversion srcversion
num_gpl_syms num_gpl_syms
num_syms num_syms
num_exentries num_exentries VFAT
FAT
*syms *syms
state state
extable extable
kernel_symbol symbol_table
value value
*name *name
value value
*name *name
value value
*name *name
Figure 2.18 Example List of Linux Kernel Modules
user level
processes
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
Telephony
Package Manager Manager Resource Manager Location Manager XMPP Service
Linux Kernel
Display Driver Camera Driver Bluetooth Driver Flash Memory Binder (IPC)
Driver Driver
Implementation:
Applications, Application Framework: Java
Linux Kernel: C
package
zip
Source Dex File APK
install
Resources &
Native Code
Dex File