Title: Operating Systems
1Operating Systems
- Amnon Meisels Ehud Gudes
- Office Hrs (314) (303)
- Tuesday 1000-1200 Thursday
- am_at_cs.bgu.ac.il os032/ ehud_at_cs.bg
u.ac.il
2Operating Systems (OS) - Syllabus
- 1. Introduction - History Views Concepts
Structure - 2. Process Management - Processes State
Resources Threads Unix implementation of
Processes - 3. Process Scheduling Paradigms Unix
Modelling - 4. Process Synchronization - Synchronization
primitives and their equivalence Deadlocks - 5. File Systems - Implementation Directory and
space management Unix file system Distributed
file systems (NFS) - 6. Memory Management - Virtual memory Page
replacement algorithms Segmentation
3OS - Syllabus (Contd.)
- 7. Security - General policies and mechanisms
examples of common problems protection models
authentication - 8. Distributed Systems a few comments
- Books
- A. Tanenbaum Modern Operating Systems,
Prentice-Hall, 2nd Edition, 2001 - A. Silbetschatz et. al. Operating System
Concepts (6th ed.), Addison Wesley,2001. - G. Nutt Operating Systems (a modern perspective)
(2nd ed.), Addison Wesley, 1999. - W. Stallings Operating Systems (3rd ed.),
Prentice-Hall, 1998.
4 Assignments and Grades
Date due Weight Subject Assignment
Week 4 5 A Toy Shell Practical 1
Week 8 15 Processes, Scheduling Practical 2
Week 12 10 Memory Management Practical 3
Week 9 15 up to Files Midterm
? 60 All Final
5 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)
6Layered Hardware-Software Machine Model
7 What is an Operating System ?
- The two Views of an Operating System
- Top-down View
- An Extended Machine
- Bottom-up View
- A Resource Manager
8Operating 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
9Operating Systems as Resource Managers
- Many Resources
- Processors Memory
- Disks Tapes Printers
- Network interfaces Terminals
- Controlled allocation of Resources among
- Users Programs Processors
- Control means sharing/multiplexing, monitoring,
protection, report/payment
10Multiprogramming Why how its possible?
- CPU much faster than I/O
- Memory large enough (512K!)
- requires protection!
- Scheduler which manages flow of jobs in and out
- and shares CPU between jobs requires
Timer - Spooler which takes care of slow I/O (e.g.
printing). -
11Some relevant Hardware aspects
(a)
(b)
- (a) Steps in starting an I/O device and getting
interrupt - (b) How the CPU is interrupted
12Memory 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 instructions for the two registers are
privileged - In supervisor mode the OS has unrestricted
access to all memory
13Memory Protection
14Memory protection (Cont.)
- One base-limit pair and two base-limit pairs
15User 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
16Interrupts part of fetch-and-execute
- While (halt flag not set during execution) /
every fetch-and-execute/ IR
memoryPCexecute(IR)PCIf(Interrupt_Reques
t) memory0 PC PC memory1 - Interrupt handlers loop over all device numbers
and call the device_handler for which a flag done
is raised - The interrupt handling routine uses a
disable_interrupts instruction to avoid losing
data while processing an interrupt request - Hardware may lose queuing interrupts, when the
Interrupt_Disabled flag is raised and an
interrupt occurs
17(No Transcript)
18Processes - a central concept
- Programs in Execution
- Timesharing -
- Process Suspension
- Process Table
- Core image
- Process Tree
- Signals
- Uids - Protection...
19Operating System Concepts
- A process tree
- A created two child processes, B and C
- B created three child processes, D, E, and F
20Operating System Concepts
- Two processes connected by a pipe
21Files non volatile data
- File types and operations on files
- Directories - hierarchical structure
- Working directories
22Files non volatile data (cont.)
- 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 the idea of Late
binding - Pipes
23Operating system concepts System calls
- 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()
24A 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
25Steps in Making a System Call
- There are 11 steps in making the system call
- read (fd, buffer, nbytes)
26Some System Calls For Process Management
27Some System Calls For File Management
28Some System Calls For Directory Management
29Some System Calls For Miscellaneous Tasks
30System Calls
31The 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
32Shell structureParent child
- A stripped down shell
- while (TRUE) / repeat forever /
- type_prompt( ) / display prompt /
- read_command (command, parameters) / input
from terminal / -
- if (fork() ! 0) / fork off child process
/ - / Parent code /
- waitpid( -1, status, 0) / wait for
child to exit / - else
- / Child code /
- execve (command, parameters, 0) / execute
command / -
-
33Initializing a (user) shell
- The init program runs getty on all ports
- Detecting a terminal getty runs login
- Typing in a user name and a password login
checks the passwd file and if correct runs a
shell the one specified in the UID entry - The shell is run with that user ID environment
parameters - The user process runs the shell
34Running user commands
- User types grep some_word file_name
- Shell parses the command, inserts the strings
grep, some_word, file_name into argv and argc - Next, the shell uses fork() to create a process
(same user ID) - Now, it takes the executable name grep and the
arguments, all from argv, and uses execve() or
similar system calls to run the grep executable - Normally the shell uses the wait() system call to
be rerun after grep exits one user process
running
35Small-Shell smash
- Your assignment is to build a program smash'
that will implement the following shell services
- Run programs in foreground and background
- List all processes that currently run in the
background. - Kill a process running in the background.
- Kill or suspend programs running in foreground
mode using signals. - Move programs that run in foreground mode to
background mode and vice versa.
36OS - 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
37OS - Main Components (cont.)
- 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
38OS - Main Components (cont.)
- 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)
39Operating system structure
- Monolithic systems have little structure
Service Routines
Utility procedures
40Virtual 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 - Recent use run MS-DOS on top of Windows
41Virtual Machines
42Virtual Machines
- Virtual machine monitors for operating systems
System call
System call
CMS
Trapped
CMS
CMS
VM/370
Trapped
370 Bare Hardware
43Client-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
44Mechanism 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
45- Fig. 9-7. A Distributed System consisting of
workstations on a LAN. - Fig 9-1. Advantages of distributed systems over
centralized ones.
46UNIX
47UNIX Utility Programs
- A few of the more common UNIX utility programs
required by POSIX
48UNIX Kernel
- Approximate structure of generic UNIX kernel
49Case Study 2 Windows 2000
11.1 History of windows 2000 11.2 Programming
windows 2000 11.3 System structure 11.4
Processes and threads in windows 2000 11.5
Memory management 11.6 Input/output in windows
2000 11.7 The windows 2000 file system 11.8
Security in windows 2000 11.9 Caching in windows
2000
50Windows NT
- Some differences between Windows 98 and Windows NT
51Windows 2000 (1)
- Different versions of Windows 2000
52Windows 2000 (2)
- Comparison of some operating system sizes
53(No Transcript)