Title: Operating Systems
1Operating Systems
- Amnon Meisels
- Office Hrs (314) Monday 1000-1200
- am_at_cs.bgu.ac.il os002/
2Operating Systems (OS) - Syllabus
- 1. Introduction - History Views Concepts
Structure - 2. Process Management - Processes State
Resources Threads Scheduling Unix
implementation of Processes - 3. Process Synchronization - Synchronization
primitives and their equivalence (1st
Assignment) Deadlocks - 4. Memory Management - Virtual memory Page
replacement algorithms Segmentation - 5. File Systems - Implementation Directory and
space management Unix file system Distributed
file systems (NFS) (2nd Assignment)
3OS - Syllabus (Contd.)
- 6. Security - General policies and mechanisms
examples of common problems protection models
authentication - 7. Input/Output - Interrupts Drivers Disks
- 8. Distributed Systems - Inter Process
Communication (RPCs) Synchronization - A. Tanenbaum Modern Operating Systems,
Prentice-Hall, 1992. - A. Silbetschatz et. al. Operating System
Concepts (5th ed.), Addison Wesley, 1997. - G. Nutt Operating Systems (a modern perspective)
(2nd ed.), Addison Wesley, 1999. - W. Stallings Operating Systems (3rd ed.),
Prentice-Hall, 1998.
4 Introduction
- Why do we need an operating system ?
- Basis for all software
- Simplifies access (for user processes) to
- Memory
- Permanent Data
- i/o extended machine
- Security and Protection
- of executing user programs
- of resources (devices)
5Layered Hardware-Software Machine Model
6 What is an Operating System ?
- The two Views of an Operating System
- Top-down View
- An Extended Machine
- Bottom-up View
- A Resource Manager
7Operating Systems - Extended Machines
- Problems
- Bare machine has a complex structure
- Processors
- Many Devices
- Primitive Instruction Set
- Different for Different Machines
- Solutions provided by the OS
- Simple, easier to use interface
(machine-independent) - Hiding of unnecessary details
8Operating Systems as Resource Managers
- Many Resources
- Processors Memory
- Disks Tapes Printers
- Network interfaces Terminals
- Controlled allocation of Resources among
- Users Programs Processors
9Operating Systems History
- Computer hardware evolved in 4 steps
- Vacuum tubes Plug boards (1945-1955)
- One user per machine --gt User as Operator
- Early Software - Assemblers, compilers,
Libraries of common subroutines, Device drivers - Secure
- Inefficient use -
- low CPU utilization
- Significant set-up time
- No concept of an Operating System
10B. Batch systems - Transistors (1955-1965)
- Cards into card readers
- Batch similar jobs (to save on set-up time)
- Transferring control automatically, from one
batch job to another --gt a rudimentary OS - Job Control Language (JCL)
- Program LOAD RUN Data EOF.
- Resident monitor (user ? operator)
- Initial control in monitor
- transfers control to job
- upon completion, control transfers back to
monitor
11C. Multiprogramming - Integrated Circuits
(1965-1980)
- Several programs reside on disk (and in memory)
at the same time
Memory Partitions
12C. Multiprogramming (Contnd.)
- I/o routines supplied by the system - device
allocation - Memory management - allocate memory among jobs
- Processes contend for CPU time - cpu scheduling
- Spooling (Simultaneous Peripheral Operations On
Line) - Timesharing i.e. Terminals - jobs kept in
memory and on disk control statements issued
by user (keyboard) - On-line file system is needed, for users access
to data - Examples CTSS Multics Unix.
13D. VLSI and personal computers (1980-
- Machine per user
- I/o devices - keyboards, displays, mice,
printers - Friendly operating software
- Examples Unix (here too ?) Windows-NT
- Parallel (multiprocessor) systems shared
memory symmetric processing - same OS (no
master) - Networks (distribution)
- Distributed file systems - shared among many
systems - Network operating systems - protection for
simple OSs - Distributed operating systems - distribute
computation among several machines/processors
14Operating system concepts - Protection
- An interface from privileged or system mode to
user mode (user programs) - System calls
- create, delete, use various objects
- Examples (Unix)
- fdopen(file_name, mode)
- close(fd) kill(pid,sig) fork()
15A word on System Calls
- Look like standard procedure calls
- put parameters in Registers and TRAP
- operation is performed in privileged mode
- some system calls can be accessed through the
command interpreter (Shell) - redirection gt
- pipe
- do/not wait for offspring process
16The Shell Commands Language
- sort lt file1 gt file2
- cat file1 sort lpr
- The Shell is a process which executes its
commands as offspring processes - Processes may call shell commands by using the
system system call
17User mode lt--gt Privileged mode (I/o)
- All I/o instructions are privileged instructions
- I/o devices and cpu can execute concurrently
- cpu moves data main memory --gt buffers of
device controllers - I/o itself is from device to controllers buffer
- Device controllers interrupt upon completion
- Interrupts or Traps enable mode switching..
- control to interrupt service routine (interrupt
vector) - Architecture saves address of interrupted
instruction - Operating systems are interrupt-driven
18Memory Protection
- Minimal protection must include the interrupt
vector and service routines - General memory protection can use two registers
- - base register - smallest legal address
- limit register - size
- memory outside the range is protected
- Hardware performs these checks in all user-mode
memory references - The load instructiones for the two registers are
privileged - In supervisor mode the OS has unrestricted
access to all memory
19Memory Protection
20CPU Protection
- Timer - interrupts computer after specified
period, to ensure OS maintains control - timer is decremented every clock tick
- when timer reaches zero, an interrupt occurs
- timer is set whenever control is transferred to
user processes (or any process..) - timer is mainly used to implement time-sharing or
multiprocessing - load-timer is a privileged instruction
21Processes - a central concept
- Programs in Execution
- Timesharing -
- Process Suspension
- Process Table
- Core image
- Process Tree
- Signals
- Uids - Protection...
22 and in the 1st Assignment ..
- Processes are simulated by threads
- No process tree, but, the special thread - the
Shell - creates all other threads - The process table is very simplistic, the
Scheduler keeps track on whos ready - Inter process communication is enabled for all
threads - performed by the Mailer - Threads have Ids, essential for the routing
23Files non volatile data
- File types and operations on files
- Directories - hierarchical structure
- Working directories
24Files non volatile data (contnd.)
- Protection and Security
- Unix - user group other (rwx bits)
- File descriptors (handles)
- i/o as a special file
- Block Character special files
- Standard input output error
- Pipes
25OS - Main Components
- Process management
- process creation deletion suspension
- process synchronization communication
- Main-memory management
- Manage used parts and their current users
- Select processes to load
- Allocate memory to running processes
- Secondary storage management
- Free-space management
- Storage allocation
26OS - Main Components (contnd.)
- File system management
- File directory creation deletion
- File manipulation primitives
- Mapping files onto secondary storage
- I/o system management
- general device-driver interface
- Drivers for specific hardware devices
- Protection system
- Distinguish between authorized and unauthorized
usage - Provide means of enforcement
27OS - Main Components (contnd.)
- Networking
- A distributed system is a collection of
processors that do not share memory or a clock - The processors are connected through a
communication network - Provides user access to various system resources
- Command-interpreter System
- control statements that deal with process
creation and management I/o handling
file-system access protection networking - The program that reads and interprets - shell (in
Unix)
28Operating system structure
- Monolithic systems have little structure
Service Routines
Utility procedures
29Layered Systems
- Layers of detail hiding, protection
- passing parameters through layers - inefficient..
30Virtual Machines
- The extreme layered approach
- Provide an interface identical to the underlying
bare machine - OS creates multiple processes, each executing on
its own processor and own (virtual) memory - Virtual machines provide complete protection of
system resources - even separate resources - Difficult to implement, due to the effort
required to provide an exact duplicate of the
underlying machine
31Virtual Machines
32Virtual Machines
- Virtual machine monitors for operating systems
System call
System call
CMS
Trapped
CMS
CMS
VM/370
Trapped
370 Bare Hardware
33Client-Server Model
Memory Server
File Server
Client Process
. . . . . .
Client Process
Kernel
Machine4
Machine3
Machine1
Machine2
Client
File Server
Process Server
. . . .
. . .
Kernel
Kernel
Kernel
Kernel
Network
Distributed System
34 and in the 1st Assignment ..
- The Mailer is a Server
- All threads are Clients
- There are only two modules in the System
- the Scheduler
- the Mailer
- The Mailer requests services from the Scheduler
thread_status --gt suspended
35 and in the 1st Assignment ..
- System calls are simulated by
- send(), receive()
- But, there are all the real system calls
- suspend(), block(), release()
- So, the best policy is to let these
extra-functions be called from the system
module - Remember, the (global) function called is part
of the thread of control...
36Mechanism vs. Policy
- Simple Kernel - modularity minimal privileged
operation - Servers for files, memory, etc. - distribution
user mode operation - good for distributed systems
- Mechanism in kernel - how to do things..
- Policy outside - decide what to do can be
changed later.. - Another solution Critical servers in kernel