Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System...
Transcript of Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System...
![Page 1: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/1.jpg)
1
Operating System Overview
Chapter 1.5 – 1.9
![Page 2: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/2.jpg)
2
Operating System
• A program that controls execution of applications– The resource manager
• An interface between applications and hardware– The extended machine
![Page 3: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/3.jpg)
3
Structure of a Computer System
Hardware
Operating System
System Libraries
Application
System Libraries
Application
System Libraries
Application
Kernel Mode
User Mode
![Page 4: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/4.jpg)
4
Structure of a Computer System
Hardware
Operating System
System Libraries
Application
Kernel Mode
User Mode
Interacts via load and store instructions to CPU and device registers, and interrupts
![Page 5: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/5.jpg)
5
Structure of a Computer System
Hardware
Operating System
System Libraries
Application
Kernel Mode
User Mode Interaction via function calls to library procedures
![Page 6: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/6.jpg)
6
Structure of a Computer System
Hardware
Operating System
System Libraries
Application
Kernel Mode
User Mode Interaction via
System Calls
![Page 7: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/7.jpg)
7
A note on System Libraries
• System libraries are just that, libraries of support functions (procedures, subroutines)– Only a subset of library functions are
actually systems calls• strcmp(), memcpy(), are pure library functions• open(), close(), read(), write() are system calls
– System call functions are in the library for convenience
![Page 8: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/8.jpg)
8
Operating System Objectives• Convenience
– Make the computer more convenient to use• Abstraction
– Hardware-independent programming model• Efficiency
– Allows the computer system to be used in an efficient manner
• Ability to evolve– Permit effective development, testing, and
introduction of new system functions without interfering with existing services
• Protection
![Page 9: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/9.jpg)
9
Services Provided by the Operating System
• Program development– Editors, compilers, debuggers
• Not so much these days
• Program execution– Load a program and its data
• Access to I/O devices• Controlled access to files
– Access protection• System access
– User authentication
![Page 10: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/10.jpg)
10
Services Provided by the Operating System
• 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
![Page 11: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/11.jpg)
11
Services Provided by the Operating System
• Accounting– collect statistics– monitor performance– used to anticipate future enhancements– used for billing users
![Page 12: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/12.jpg)
12
Operating System Software
• Fundamentally, OS functions the same way as ordinary computer software– It is a program that is executed (just like apps)– It has more privileges
• Operating system relinquishes control of the processor to execute other programs– Reestablishes control after
• System calls• Interrupts (especially timer interrupts)
![Page 13: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/13.jpg)
13
Kernel
• Portion of the operating system that is running in privileged mode
• Usually resident in main memory• Contains fundamental functionality
– Whatever is required to implement other services
– Whatever is required to provide security• Contains most-frequently used functions• Also called the nucleus or supervisor
![Page 14: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/14.jpg)
14
Major OS Concepts
• Processes• Concurrency and deadlocks• Memory management• Files• Information Security and Protection• Scheduling and resource management
![Page 15: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/15.jpg)
15
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 resource ownership• A unit of activity characterized by a single sequential
thread of execution, a current state, and an associated set of system resources– Nowadays the execution abstraction is separated out:
Thread– Single process can contain many threads
![Page 16: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/16.jpg)
16
Process• Consist of three segments– Text
• contains the code (instructions)
– Data• Global variables
– Stack• Activation records of
procedure• Local variables
• Note:– data can dynamically grow
up– The stack can dynamically
grow down
Stack
Gap
Data
Text
Memory
![Page 17: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/17.jpg)
17
Process
• Consists of three components– An executable program
• text– Associated data needed by the program
• Data and stack– Execution context of the program
• All information the operating system needs to manage the process
– Registers, program counter, stack pointer, etc…• A multithread program has a stack and
execution context for each thread
![Page 18: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/18.jpg)
18
Multiple processes creates concurrency issues
(a) A potential deadlock. (b) an actual deadlock.
![Page 19: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/19.jpg)
19
Memory Management• The view from thirty thousand feet
– Process isolation• Prevent processes from accessing each others data
– Automatic allocation and management• Don’t want users to deal with physical memory directly
– Support for modular programming– Protection and access control
• Still want controlled sharing– Long-term storage– OS services
• Virtual memory• File system
![Page 20: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/20.jpg)
20
Virtual Memory
• Allows programmers to address memory from a logical point of view– Gives apps the illusion of having RAM to
themselves– Logical addresses are independent of
other processes– Provides isolation of processes from each
other• Can overlap execution of one process
while swapping in/out others.
![Page 21: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/21.jpg)
21
Virtual Memory Addressing
![Page 22: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/22.jpg)
22
Paging
• Allows process to be comprised of a number of fixed-size blocks, called pages
• Virtual address is a page number and an offset within the page
• Each page may be located any where in main memory
• A page may actually exist only on disk
![Page 23: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/23.jpg)
![Page 24: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/24.jpg)
24
File System
• Implements long-term store• Information stored in named objects
called files
![Page 25: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/25.jpg)
25
Example File System
![Page 26: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/26.jpg)
26
Information Protection and Security
• Access control– regulate user access to the system– Involves authentication
• Information flow control– regulate flow of data within the system and
its delivery to users
![Page 27: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/27.jpg)
27
Scheduling and Resource Management• Fairness
– give equal and fair access to all processes• Differential responsiveness
– discriminate between different classes of jobs• Efficiency
– maximize throughput, minimize response time, and accommodate as many uses as possible
![Page 28: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/28.jpg)
28
Operating System Structure
• The layered approach
a) Processor allocation and multiprogramming
b) Memory Management
c) Devicesd) File systeme) Users
– Each layer depends on the the inner layers
a b c d e
![Page 29: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/29.jpg)
29
Operating System Structure
• In practice, layering is only a guide– Operating Systems have many
interdependencies• Scheduling on virtual memory• Virtual memory on I/O to disk• VM on files (page to file)• Files on VM (memory mapped files)• And many more…
![Page 30: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/30.jpg)
30
The Monolithic Operating System Structure
• Also called the “spaghetti nest”approach– Everything is
tangled up with everything else.
• Linux, Windows, ….
![Page 31: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/31.jpg)
31
The Monolithic Operating System Structure
• However, some reasonable structure usually prevails
![Page 32: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/32.jpg)
32
OS Complexity is a major issue
• Approaches to tackling the problem– Safe kernel extensions
• SPIN - safe programming language• VINO – sandboxing (hardware protection)
– Microkernels– Exokernels
![Page 33: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/33.jpg)
33
Microkernel-based Systems• Assigns only a few essential functions to the kernel
– Address space– Interprocess Communication (IPC)– Basic scheduling– Minimal hardware abstraction
• Other services implemented by user-level servers• Traditional “system calls” become IPC requests to
servers• Extreme view of a microkernel
– A feature is only allowed in the kernel if required for security
![Page 34: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/34.jpg)
34HW
Bit Byte Word Register Instructions
Application
documentswindowssymbols
stacks & heapsarrays & structures
variables
threadscoroutinesmodules
proceduresstatements
File
Socket
PipeAddress SpacePageACLSegment
Process TaskThreadEvent
IPCSemaphore
MonitorMutex
Priority
Schedule
Monolithic Kernel
![Page 35: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/35.jpg)
35
HW
Bit Byte Word Register Instructions
µ-kernel
Address Space Thread
Application
documentswindowssymbols
stacks & heapsarrays & structures
variables
threadscoroutinesmodules
proceduresstatements
ServerFile
![Page 36: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/36.jpg)
HW
L4
classicOS
Security
RTMM
classic +
HW
L4
nativeJava
em-bedded
app
thin
HW
L4
highly-specializedcomponent
specialized
![Page 37: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/37.jpg)
37
Client/Server Model
• Simplifies the Executive– Possible to construct a variety of APIs
• Improves reliability– Each service runs as a separate process with its
own memory partition• Provides a uniform means for applications to
communicate via IPC• Provides a base for distributed computing
![Page 38: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/38.jpg)
38
The client/server model
The client-server model of microkernel make it easier to extend to a distributed system
![Page 39: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/39.jpg)
39
UNIX
• Provides a good hardware abstraction– Everything is a file (mostly)
• Runs on most hardware• Comes with a number of user services
and interfaces– shell– C compiler
![Page 40: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/40.jpg)
40
Traditional UNIX Structure
![Page 41: Operating System Overviewcgi.cse.unsw.edu.au/~cs3231/05s1/lectures/lect02.pdf · Operating System Software • Fundamentally, OS functions the same way as ordinary computer software](https://reader030.fdocuments.net/reader030/viewer/2022040202/5e832a3407bd17145979ab9d/html5/thumbnails/41.jpg)
41
TraditionalUNIX
Kernel