Download operating system

Document related concepts

Library (computing) wikipedia , lookup

Copland (operating system) wikipedia , lookup

RSTS/E wikipedia , lookup

Burroughs MCP wikipedia , lookup

OS 2200 wikipedia , lookup

Spring (operating system) wikipedia , lookup

Unix security wikipedia , lookup

Process management (computing) wikipedia , lookup

Distributed operating system wikipedia , lookup

VS/9 wikipedia , lookup

CP/M wikipedia , lookup

Paging wikipedia , lookup

Transcript
Operating Systems
(10B11CI511 )
Introduction to OS-related Hardware and
Software
1
Grading
T1
20 Marks
T2
20 Marks
T3
35 Marks
TA Marks
25 Marks
Total
100 Marks
2
Text books
1. Charles Crowley “Operating System A Design Approach” TMH.
2. “Operating Systems Concepts: Essentials” by Silberschatz, Galvin, Gagne
3. Andrew S. Tanenbaum “Operating Systems Design and Implementation”,
Third Edition, Prentice Hall Publications 2006
4. A.S. Tanenbaum, “Modern Operating Systems”, 2nd edition, Prentice Hall
India.
5. D. M. Dhamdhere, “ Systems Programming and Operating systems” TMH, 2nd
revised edition.2006
3
Overview
• What is an Operating System?
• A review of OS-related hardware
4
What is an operating system?
• “A program that controls the execution of
application programs and implements an
interface between the user of a computer and the
computer hardware”
– Narrow view of a computer and OS
• Traditional computer with applications running on it (e.g.
PCs, Workstations, Servers)
– Broad view of a computer and OS
• Anything that needs to manage resources (e.g. router OS,
embedded system, cell phone OS ...)
5
Levels in a computer system
User
6
Abstract View of System
Components
Two key OS functions
• Abstract Machine
– Hides complex details of the underlying hardware
– Provides common API to applications and services
– Simplifies application writing
• Resource Manager
– Controls (scheduling, multiplexing, transforming etc.) accesses to
shared resources
• CPU, memory, disks, network, ...
– Allows for global policies to be implemented
– Better utilization of computer hardware
8
OS as a resource manager
• Allocating resources to applications across space
and time
– time sharing a resource (scheduling)
– space sharing a resource (allocation)
• Making efficient use of limited resources
– improving utilization
– minimizing overhead
– improving throughput/good put
• Enforcement of boundaries
– protecting applications from each other
9
Operating System Definitions
• Resource allocator – manages and allocates resources
• Control program – controls the execution of user programs
and operations of I/O devices
• Kernel – lies between software and hardware. The one
program running at all times (all else being application
programs)
Hardware resources
Providing abstraction via system calls
Application
System Calls: read(), open(), write(), mkdir(), kill() ...
Device
Mgmt
Operating
System
Protection
File System
Video Card
Monitor
CPU
Network
Comm.
Memory
Disk
Process
Mgmt
Security
Network
Printer
12
Types of multiplexing
• Time multiplexing
– time-sharing
– scheduling a serially-reusable resource among several users
• Space multiplexing
– space-sharing
– dividing a multiple-use resource up among several users
Time-multiplexing the processor
14
Space-multiplexing memory
15
Time-multiplexing I/O devices
16
Space-multiplexing the disk
17
O.S. Components
•
•
•
•
•
•
•
•
Process management
Main memory management
File management
I/O system management
Secondary storage management
Networking
Protection system
Command interpreter system
Process Management
• A process is a program in execution.
• Needs (CPU time, memory, files, and I/O devices).
• The OS is responsible for the following
activities in connection with process
management.
– Process creation and deletion.
– process suspension and resumption.
– Provision of mechanisms for:
• process synchronization
• process communication
Main-Memory Management
• Memory is a large array of words or bytes,
each with its own address. It is a repository of
quickly accessible data
– shared by the CPU and I/O devices.
• Main memory is a volatile storage device.
– It loses its contents in the case of system failure.
• The operating system is responsible for the
following activities in connections with
memory management:
– Keep track of which parts of memory are currently being used and by whom.
– Decide which processes to load when memory space becomes available.
– Allocate and de-allocate memory space as needed.
File Management
• A file is a collection of related information
defined by its creator. Commonly, files represent
programs (both source and object forms) and
data.
• The operating system is responsible for the
following activities in connections with file
management:
–
–
–
–
–
File creation and deletion.
Directory creation and deletion.
Support of primitives for manipulating files and directories.
Mapping files onto secondary storage.
File backup on stable (nonvolatile) storage media.
I/O System Management
• The I/O system consists of:
– A buffer-caching system
– A general device-driver interface
– Drivers for specific hardware devices
Secondary-Storage Management
• Main memory (primary storage) is volatile
and small.
• The operating system is responsible for the
following activities in connection with disk
management:
– Free space management
– Storage allocation
– Disk scheduling
Networking (Distributed Systems)
• A distributed system is a collection of processors
that do not share memory or a clock. Each
processor has its own local memory.
• The processors in the system are connected
through a communication network.
• Communication takes place using a protocol.
• Access to a shared resource allows:
– Computation speed-up
– Increased data availability
– Enhanced reliability
Protection System
• Protection refers to a mechanism for
controlling access by programs, processes, or
users to both system and user resources.
• The protection mechanism must:
– distinguish between authorized and unauthorized usage.
– specify the controls to be imposed.
– provide a means of enforcement.
Command-Interpreter System
• Many commands are given to the operating
system by control statements which deal with:
–
–
–
–
–
–
–
process creation and management
I/O handling
secondary-storage management
main-memory management
file-system access
protection
Networking
• The program that reads and interprets control
statements is called variously:
– command-line interpreter
– shell (in UNIX)
Modes of execution
• User mode.
• Supervisory (or Kernel) mode.
•
•
Some instructions (e.g. controlling the system hardware) are not offered to
everyone for use.
These instructions are called privileged instructions and allowed to only privileged
users for use.
27
Problems an OS must solve
• Time sharing the CPU among applications
• Space sharing the memory among
applications
• Space sharing the disk among users
• Time sharing access to the disk
• Time sharing access to the network
28
More problems an OS must solve
• Protection
–
–
–
–
of applications from each other
of user data from other users
of hardware/devices
of the OS itself!
29
Operating System Services
•
•
•
•
•
Program execution
I/O operations
File-system manipulation
Communications
Error detection
Mainframe Systems
First Computer used to tackle many commercial and scientific
applications
Batch Systems
Multiprogrammed Systems
Time-Sharing Systems–Interactive
Memory Layout for a Simple Batch System
Multiprogrammed Batch Systems
•
Several jobs are kept in main memory at the same time, and
the CPU is multiplexed among them.
OS Features Needed for Multiprogramming
• Job scheduling: jobs (disk -> memory).
• Memory management – memory allocation to several jobs
• CPU scheduling – jobs (ready to run)
• Allocation of devices
Time-Sharing Systems–Interactive Computing
• Batch and Multiprogrammed system do not provide
interaction with user during program execution.
• The CPU is multiplexed among several jobs that are kept in
memory and on disk (the CPU is allocated to a job only if the
job is in memory).
• A job swapped in and out of memory to the disk.
Time-Sharing Systems–Interactive Computing
• Multitasking systems
• Multiuser
• Interactive computer system
Computer system architecture
• Single processor systems
– one general-purpose CPU
• Multiprocessor (Parallel/tightly coupled) system
–
–
–
–
high throughput
more reliable/fault tolerant
less costly
Asymmetric and symmetric multiprocessing (SMP)
• Clustered systems
– Multiple systems connected (e.g. LAN)
– Shared storage
37
Distributed Systems
• Distribute the computation among several physical processors
• Advantages of distributed systems
–
–
–
–
Resources Sharing
Computation speed up – load sharing
Reliability
Communications
Other types of systems
• Real-Time Systems
– Hard real-time systems
• Ex. Satellite launch system
– Soft real-time systems
• Ex. Multimedia presentation system
• Handheld Systems
– RTOS running on a mobile device
Overview
• What is an Operating System?
• A review of OS-related hardware
40
Instruction sets
• A CPU’s instruction set defines what it can do
– CPU architecture dependent
– load and store are used by all
• Load a word located at an address in memory into a register (M->R)
• Store the contents of a register to a word located at an address in memory
– many instructions for comparing and combining
values in registers and putting result into a register
41
Basic anatomy on a CPU
• Program Counter (PC)
– Holds the memory address of the next instruction
• Instruction Register (IR)
– holds the instruction currently being executed
• General Registers (Reg. 1..n)
– hold variables and temporary results
• Arithmetic and Logic Unit (ALU)
– performs arithmetic functions and logic operations
42
Basic anatomy on a CPU
• Stack Pointer (SP)
– holds memory address of a stack with a frame for each active
procedure’s parameters & local variables
• Processor Status Word (PSW)
– execution mode of CPU
– processor responds to disk and timer interrupts.
• Memory Address Register (MAR)
– contains address of memory to be loaded from/stored to
• Memory Data Register (MDR)
– contains memory data loaded or to be stored
43
Program execution
• The Fetch/Decode/Execute cycle
–
–
–
–
fetch next instruction pointed to by PC
decode it to find its type and operands
execute it
repeat
• At a fundamental level, fetch/decode/execute
is all a CPU does, regardless of which program
it is executing
44
The OS is just a program!
• The OS is a sequence of instructions that the CPU
will fetch/decode/execute
– How can the OS cause application programs to run?
– How can the OS switch the CPU to run a different
application and later resume the first one?
– How can the OS maintain control?
– In what ways can application code try to seize control
indefinitely (ie. cheat)?
– And how can the OS prevent such cheating?
– How can applications programs cause the OS to run?
45
How can OS guarantee to regain
control?
• What if a running application doesn’t make a
system call and hence halt the CPU?
– OS needs interrupts from a timer device!
46
What if the application tries to cheat?
• What stops the running application from disabling the future timer
interrupt so that the OS can not take control back from it?
– Disabling interrupts must be a privileged instruction which is not
executable by applications
47
What other ways are there to cheat?
• What stops the running application from
modifying the OS?
– Memory protection!
• Why must the OS clear the mode bit before it
hands control to an application?
48
OS Structure
• Monolithic Systems
• Micro kernel architecture
• Layered Systems
• Virtual Machine
Monolithic Systems
• OS is written as collection of procedures. Each of which can call
any of the other ones whenever it needs to.
• To construct the OS one first compiles all the individual
procedures and then binds them all together into a single object
file using the system linker.
• This organization suggests a basic structure for the OS
1. A main program that invoke a basic structure for OS
2. A set of service procedures that carry out the system calls
3. A set of utility procedures that help the service procedures
Microkernel System Structure
• Moves as much from the kernel into “user” space.
• Communication takes place between user modules using
message passing.
• 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
Layered Approach
• Advantages : modularity, Simplifies
debugging and system verification
• Difficulty: Careful definition of layers since a
layer can use only those layers below it.
• Disadvantages: Less efficient (Each layer adds
overhead)
System Calls
• System calls provide the interface between a
running program and the operating system.
– assembly-language instructions.
Types of System Calls
• Process control : end, abort, create, terminate,
execute, wait event, signal event
• File management : create file, delete file, open,
close, read, write, reposition
• Device management: request device, release
device, read, write, reposition
• Information maintenance: get time or date, set
time or date
get process file or device attributes, set process file
or device attributes
System programs
• System calls provide a convenient environment
for program development and execution. The
system calls can be divided into:
–
–
–
–
–
–
File management : create, delete, copy, rename, print, dump, list
Status information : date, time, available memory, users
File modification: text editors
Programming language support: compilers, assemblers, interpreters
Program loading and execution: linkers, loaders
Communications sockets, pipes
• Most users’ view of the operation system is
defined by system programs, not the actual
system calls.
Virtualization
• Virtualization is the creation of a virtual (rather than actual)
version of something, such as an operating system, a server, a
storage device or network resources.
• Para Virtualization
• Native virtualization
System Models
Non-virtual Machine
Virtual Machine