1 Operating Systems (202-1-3031) Lecturers Lecturers : : Danny Hendler Danny Hendler and and Roie Zivan Roie Zivan TA TA s: Alon Grubshtein, Amir Mentchel, s: Alon Grubshtein, Amir Mentchel, Ilya Misrky and Ilya Misrky and Dolev Pomerantz Dolev Pomerantz Course site Course site: http://www.cs.bgu.ac.il/~os122/Main Danny Hendler Danny Hendler Office: Alon, Office: Alon, 218 218 [email protected][email protected].ac.il .ac.il Office hours: Office hours: Wed., 11-13 Wed., 11-13 Amnon Meisels Amnon Meisels Office: Office: zivan.roie@gmail zivan.roie@gmail .com .com Office hours: Office hours: 1 Operating Systems, 2012, Danny Hendler & Roie Zivan
53
Embed
1 Operating Systems (202-1-3031) Lecturers : Danny Hendler and Roie Zivan TAs: Alon Grubshtein, Amir Mentchel, Ilya Misrky and Dolev Pomerantz Course site.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
Operating Systems (202-1-3031)
LecturersLecturers: : Danny Hendler Danny Hendler and and Roie ZivanRoie ZivanTATAs: Alon Grubshtein, Amir Mentchel, Ilya Misrky ands: Alon Grubshtein, Amir Mentchel, Ilya Misrky and
How Bill Gates became rich…How Bill Gates became rich…(cont’d)(cont’d)
1974: Intel releases the 8080 processor, needs an OS
Gary Kildall
CP/M OS
Can you grant me CP/M rights?
Sure!
Operating Systems, 2012, Danny Hendler & Roie Zivan 18
How Bill Gates became rich…How Bill Gates became rich…(cont’d)(cont’d)
1980: IBM designs IMB PC, needs an OS
Gary Kildall
Can you find an OS for our PC?
Please meet IBM, they need an OS
Sorry, too busy!!!!!
Operating Systems, 2012, Danny Hendler & Roie Zivan 19
How Bill Gates became rich…How Bill Gates became rich…(cont’d)(cont’d)
1980: IBM designs IMB PC, needs an OS
Kildall too busy. Please develop an
OS!
I’de like to buy the DOS OS
Sure, it’s yours for $75,000
Operating Systems, 2012, Danny Hendler & Roie Zivan 20
How Bill Gates became rich…How Bill Gates became rich…(cont’d)(cont’d)
1980: IBM designs IMB PC, needs an OS
May I retain the rights for MS-
DOS?
Sure, why not!!
Operating Systems, 2012, Danny Hendler & Roie Zivan 21
How Bill Gates became rich…How Bill Gates became rich…(cont’d)(cont’d)
Well, this is 20:20 hind vision…
Operating Systems, 2012, Danny Hendler & Roie Zivan 22
Introduction: outlineIntroduction: outline
What is an operating system?
Some history
OS concepts
OS structure
Operating Systems, 2012, Danny Hendler & Roie Zivan 23
OS – Key FunctionsOS – Key Functions Process management
o process creation; deletion; suspension/preemptiono process synchronization; communication; scheduling
Main-memory managemento Manage used parts and their current userso Select processes to load from secondary storageo Allocate memory to running processes
I/O system managemento general device-driver interfaceo Drivers for specific hardware devices
Protection systemo Distinguish between authorized and unauthorized usageo Provide means of enforcement
OS – Key Functions OS – Key Functions (cont’d)(cont’d)
Operating Systems, 2012, Danny Hendler & Roie Zivan 25
Processes - a key conceptProcesses - a key concept
Resource container for “program in execution” Timesharing, process suspension/preemption Process Table Process Groups Signals
Operating Systems, 2012, Danny Hendler & Roie Zivan 26
Why do we need multiple processes?Why do we need multiple processes?
• Single application: We want things to happen “concurrently” (E.g.: paging and typing in a text editor)
• Multiple applications: processes running in the background (e.g., Anti Virus)
• Multiple users: The departmental computer; all types of Servers
Operating Systems, 2012, Danny Hendler & Roie Zivan 27
CPU much faster than I/Oo Computation/communication overlap
Memory large enough – requires memory protection!
Scheduler which manages flow of jobs in and outand shares CPU between jobs – requires Timer
MultiprogrammingMultiprogramming: how is it done?: how is it done?
Operating Systems, 2012, Danny Hendler & Roie Zivan 28
Process treesProcess trees
• A process tree A created two child processes, B and C B created three child processes, D, E, and F
Operating Systems, 2012, Danny Hendler & Roie Zivan 29
Inter-Process Communication (IPC)Inter-Process Communication (IPC)
Two processes communicating via a pipe
Operating Systems, 2012, Danny Hendler & Roie Zivan 30
Files: non volatile dataFiles: non volatile data
File types and operations on filesDirectories - hierarchical structureWorking directories
Root directory
Students
Gil
Roni
Or
Faculty
Amnon
Papers Progs Grants
Operating Systems, 2012, Danny Hendler & Roie Zivan 31
Protection and SecurityUnix - user; group; other (rwx bits)
File descriptors (handles) I/O as a special file Block & Character special files Standard input; output; error Pipes Links
Files: non volatile data Files: non volatile data (cont’d)(cont’d)
Operating Systems, 2012, Danny Hendler & Roie Zivan 32
I/O is performed in kernel modeI/O is performed in kernel mode
All I/O instructions are privileged instructionsprivileged instructions I/O devices and CPU can execute concurrently CPU moves data between main memory and device
controllers' buffers (done by device drivers) Device controllers interruptinterrupt upon completion Interrupts or Traps enable mode switching
Operating systems are interrupt-driveninterrupt-driven Traps/signalsTraps/signals: software interrupts: software interrupts
Operating Systems, 2012, Danny Hendler & Roie Zivan 33
Interrupts and the Interrupts and the fetch-decode-execute loopfetch-decode-execute loop
While (halt flag not set during execution){IR = memory[PC];execute(IR);PC++;If(Interrupt_Request) {
memory[0] = PC;PC = memory[1] }
} An interrupt is an asynchronous event The kernel interrupt handling routine may use a
disable_interrupts instruction to avoid losing data while processing an interrupt request
Interrupt handler is typically called indirectly via the interrupt vector
Simplist
ic!
Operating Systems, 2012, Danny Hendler & Roie Zivan 34
Synchronous vs. Asynchronous I/O Synchronous vs. Asynchronous I/O
execute
Operating Systems, 2012, Danny Hendler & Roie Zivan 35
Steps in Making a System Call Steps in Making a System Call
There are 11 steps in making the system call: read (fd, buffer, nbytes)
Is this call Synchronous or Asynchronous?
Operating Systems, 2012, Danny Hendler & Roie Zivan 36
System CallsSystem Calls
processes
files
directories
miscellaneous
Operating Systems, 2012, Danny Hendler & Roie Zivan 37
The Shell Command LanguageThe Shell Command Language
while (TRUE) { /* repeat forever */ type_prompt( ); /* display prompt */ read_command (command, parameters)/* input from terminal */ if (fork() > 0) { /* fork off child process */ /* Parent code */ wait(); /* wait for child to exit */ } else { /* Child code */ execvp (command, parameters); /* execute command */ }}
Operating Systems, 2012, Danny Hendler & Roie Zivan 39
Shell initializationShell initialization
The init program runs getty on all ports Upon detecting a terminal, getty runs login Typing in a user name and a password – login
checks the passwdpasswd file and if correct runs a shell – the one specified in the UID entry
The shell is run with that user ID environment parameters
Operating Systems, 2012, Danny Hendler & Roie Zivan 40
Running user commandsRunning user commands User types: ‘grep some_word file_name’ Shell parses the command, inserts the strings grep, some_word,
file_name into argv and their number to 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 execvp() (or a similar system call) to run the grep executable
On foreground execution, the shell would use the wait() system call and continue its session only after the child process terminates
Operating Systems, 2012, Danny Hendler & Roie Zivan 41
Operating Systems, 2012, Danny Hendler & Roie Zivan
UNIX Utility Programs
A few of the more common UNIX utility programs required by POSIX
42
Introduction: outlineIntroduction: outline
What is an operating system?
Some history
OS concepts
OS structure
Operating Systems, 2012, Danny Hendler & Roie Zivan 43
Operating system structureOperating system structure
1. Monolithic systems
2. Virtual machines
3. Client-server model
…
Operating Systems, 2012, Danny Hendler & Roie Zivan 44
Monolithic systems Monolithic systems
Monolithic systems have little structure
ServiceRoutines
Utilityprocedures
Main procedure forinvoking OS service
Operating Systems, 2012, Danny Hendler & Roie Zivan 45
Monolithic systems Monolithic systems
Service routines are system calls
Utility procedures serve multiple service routines
All compiled into a single system
Operating Systems, 2012, Danny Hendler & Roie Zivan 46
Virtual MachinesVirtual Machines Provide an interface identicalidentical to the underlying bare machinebare machine VM monitor creates multiple VMs, each executing on its own
(virtual) processor and its own (virtual) memory Virtual machines provide complete protection of system
resources - even separate resourcesseparate resources Difficult to implement, due to the effort required to provide an
exactexact duplicate of the underlying machine Well-known examples:
o MS-DOS on top of Windowso JVMo VMWare
Operating Systems, 2012, Danny Hendler & Roie Zivan 47
Virtual Machines: IBM 370Virtual Machines: IBM 370
370 bare hardware
VM/370
CMS CMS CMSkernel
user
CMS: Conversational Monitor System, a single user OS
Operating Systems, 2012, Danny Hendler & Roie Zivan 48
Operating Systems, 2012, Danny Hendler & Roie Zivan 49
Modern virtual machinesModern virtual machines
Different legacy servers run on different OS
Host sharing Host sharing for web servers
Use multiple operating systems on a single machine
Security through isolation
Operating Systems, 2012, Danny Hendler & Roie Zivan 50
MicrokernelsMicrokernels
Small number of lines of code mostly in CCatching interrupts and switching processes in
AssemblyC code manages and schedules processes, inter-
process communication, i/o interaction Offers few (~40) system calls for the rest of OS Device drivers (Disk, Network,…) in user mode Upper level contains Servers – File, Process..
Operating Systems, 2012, Danny Hendler & Roie Zivan 51
Client-Server ModelClient-Server Model
(Micro)Kernel
Client Process
Client Process
. . . . . . FileServer
MemoryServer
Client File Server Process Server
Kernel Kernel Kernel Kernel
Machine1 Machine2 Machine3 Machine4
. . . . . . .
Network Distributed System
Operating Systems, 2012, Danny Hendler & Roie Zivan 52
Client/server architecture:Client/server architecture:Mechanism vs. PolicyMechanism vs. Policy
Servers for files, memory, etc. - distribution; user mode operation
good for distributed systems
Mechanism in kernel - howhow to do things..
Policy outside - decide whatwhat to do; can be changed later..changed later.. Critical servers in kernel – i/o disk server & the Scheduler – who i/o disk server & the Scheduler – who
serves who….serves who….
Operating Systems, 2012, Danny Hendler & Roie Zivan 53