0% found this document useful (0 votes)
22 views

Chap 2 Lectures

Uploaded by

Tharun Sv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Chap 2 Lectures

Uploaded by

Tharun Sv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Chapter 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

Figure 2.1 Computer Hardware and Software Structure


Operating System
• A program that controls the execution of
application programs
• An interface between applications and
hardware
Operating System Objectives
• Convenience
– Makes the computer more convenient to use
• Efficiency
– Allows computer system resources to be
used in an efficient manner
• Ability to evolve
– Permit effective development, testing, and
introduction of new system functions
without interfering with service
Sequence 2 CS240 3
Services Provided by the
Operating System
• Program development
– Editors and debuggers
• Program execution
• Access to I/O devices
• Controlled access to files
• Memory management
• System access
• Network support

Sequence 2
... CS240 5
Services Provided by the
Operating System (2)
• Error detection and response
– Internal and external hardware errors
• Memory error
• Device failure
– Software errors
• Arithmetic overflow
• Access forbidden memory locations
– Operating system cannot grant request of
application

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

Figure 2.3 Memory Layout for a Resident Monitor


Evolution of Operating
Systems
• Serial Processing
– No operating system
• Machines run from a console with
display lights, toggle switches, input
device, and printer
• Schedule time, e.g. sign up
• Setup included loading the compiler and
source program, saving compiled
program, loading and linking
Sequence 3 CS240 1
Evolution of Operating
Systems
• Simple Batch Systems
– Monitor
• Software that controls the sequence of events
• Batch jobs together
• Program branches back to monitor when
finished

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.”

• Interrupt - caused by a hardware device when it needs service. Also called an


“asynchronous trap.”

• Exception - caused when an illegal operation (eg, divide by zero or memory


reference out of bounds) is attempted.

With all three, the processor response is the same - an “indirect


subroutine call” through the vector table, along with a change
from user to kernel mode.
Read one record from file 15 µs
Execute 100 instructions 1 µs
Write one record to file 15 µs
TOTAL 31 µs

1
Percent CPU Utilization = = 0.032 = 3.2%
31

Figure 2.4 System Utilization Example


Program A Run Wait Run Wait
Time
(a) Uniprogramming
Program A Run Wait Run Wait
Program B Wait Run Wait Run Wait
Run Run Run Run
Combined Wait Wait
A B A B
Time
(b) Multiprogramming with two programs
Program A Run Wait Run Wait
Program B Wait Run Wait Run Wait
Program C Wait Run Wait Run Wait
Run Run Run Run Run Run
Combined Wait Wait
A B C A B C
Time
(c) Multiprogramming with three programs
Figure 2.5 Multiprogramming Example
Uniprogramming
• Processor must wait for I/O instruction to
complete before preceding

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

Free 25000 25000


Free Free
32000 32000 32000
(a) (b) (c)

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)

Figure 2.7 CTSS Operation


Main Processor
Memory Registers
Process index i
PC
i
Process Base b
list Limit h
j
Other
registers
Context
Process Data
A
Program
(code)
b
Context
Process Data
B h
Program
(code)
Figure 2.8 Typical Process Implementation
Major Achievements
• Denning et.al. [DENN80a] point out 5
major OS advances:
– Processes
– Memory Management
– Information protection and security
– Scheduling and resource management
– System structure
• Let s look at each one...

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

Figure 2.10 Virtual Memory Addressing


A.1
A.0 A.2
0 0
A.5
1 1
2 2
B.0 B.1 B.2 B.3
3 3
4 4
5 5
6 6
A.7
7 User
A.9
8 program
B
9
A.8
10
User
program
A
B.5 B.6
Main Memory Disk
Main memory consists of a Secondary memory (disk) can
number of fixed-length frames, hold many fixed-length pages. A
each equal to the size of a page. user program consists of some
For a program to execute, some number of pages. Pages of all
or all of its pages must be in programs plus the operating system
main memory. are on disk, as are files.
Figure 2.9 Virtual Memory Concepts
Information Protection and
Information Protection and Security
Security
• Availability • Availability
– Concerned with protecting the system
against interruption – Concerned with protecting the system
• Confidentiality against interruption
– Assuring that users cannot read data for
• Confidentiality
which access is unauthorized

– Assuring that users cannot read data for


which access is unauthorized
Sequence 3 CS240 27

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)

Long- Short- I/O


Interrupt
Term Term Queues
from Process Interrupt
Queue Queue
Interrupt Handler (code)
from I/O
Short-Term
Scheduler
(code)

Pass Control
to Process

Figure 2.11 Key Elements of an Operating System for Multiprogramming


Service processes
System support Applications
processes
Service control
SVChost.exe Environment
manager
Task manager subsystems
Lsass Winmgmt.exe Windows
Winlogon Spooler Explorer POSIX
User
Session Services.exe application
manager Win32
Subsytem DLLs
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)
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

signals system calls

processes
& scheduler
file network
systems protocols

kernel
virtual
memory
char device block device network de-
drivers drivers vice drivers

traps & physical


interrupts
faults memory

hardware
system network inter-
CPU terminal disk
memory face controller

Figure 2.19 Linux Kernel Components


Applications
Home Dialer SMS/MMS IM Browser Camera Alarm Calculator

Contacts Voice Dial Email Calendar Media Albums Clock


Player

Application Framework
Activity Manager Windows Content Providers View System Notification
Manager Manager
Telephony
Package Manager Manager Resource Manager Location Manager XMPP Service

System Libraries Android Runtime


Surface Manager Media Framework SQLite Core Libraries

OpenGL/ES FreeType LibWebCore Dalvik Virtual Machine

SGL SSL Libc

Linux Kernel
Display Driver Camera Driver Bluetooth Driver Flash Memory Binder (IPC)
Driver Driver

USB Driver Keypad Driver WiFi Driver Audio Drivers Power


Management

Implementation:
Applications, Application Framework: Java

System Libraries, Android Runtime: C and C++

Linux Kernel: C

Figure 2.20 Android Software Architecture


Resources &
Native Code

package
zip
Source Dex File APK

install
Resources &
Native Code
Dex File

dexopt dex2oat dex & native code


quickened dex
Odex install
ELF File
Dalvik File ART
Libraries

Dalvik Native ART Native

Figure 2.21 The Life Cycle of an APK


Applications and Framework
Binder IPC
Android System Services
Media Server System Server
Power
AudioFlinger MediaPlayer Window
Manager
Service Manager
Service
Camera Activity
Other Media
Service Manager Other Services
Services
Android Runtime/Dalvik
Hardware Abstraction Layer (HAL)
Camera HAL Audio HAL Graphics HAL
Other HALs
Linux Kernel
Audio Driver
Camera Driver Display Drivers
(ALSA, OSS, etc) Other Drivers
Figure 2.22 Android System Architecture

You might also like