Top Banner
1 Operating Systems (202-1-3031) Lecturers Lecturers : : Michael Elhadad, Meni Adler Michael Elhadad, Meni Adler and and Amnon Meisels Amnon Meisels TA TA s: Vadim Levit, Gal Lipetz, Etai s: Vadim Levit, Gal Lipetz, Etai Hazan, Ehud Barnea, Ilan Smoli and Hazan, Ehud Barnea, Ilan Smoli and Dan Braunshtein Dan Braunshtein Course site Course site: Meni Adler Meni Adler Office: Alon, Office: Alon, 211 211 [email protected] [email protected] c.il c.il Office hours: Office hours: Wed., 11-13 Wed., 11-13 Michael Elhadad Michael Elhadad Office: Alon, Office: Alon, 107 107 [email protected] [email protected] c.il c.il Office hours: Office hours: Amnon Meisels Amnon Meisels Office: Alon, 206 Office: Alon, 206 [email protected] [email protected] Office hours: Office hours: Mon. 10-12 Mon. 10-12
53

Operating Systems (202-1-3031)

Jan 16, 2016

Download

Documents

keiki

Operating Systems (202-1-3031). Meni Adler Office: Alon , 211 [email protected] Office hours: Wed., 11-13. Michael Elhadad Office: Alon , 107 [email protected] Office hours:. Amnon Meisels Office: Alon , 206 [email protected] Office hours: Mon. 10-12. - PowerPoint PPT Presentation
Welcome message from author
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
Page 1: Operating Systems  (202-1-3031)

1

Operating Systems (202-1-3031)

LecturersLecturers: : Michael Elhadad, Meni Adler Michael Elhadad, Meni Adler and and Amnon Amnon MeiselsMeisels

TATAs: Vadim Levit, Gal Lipetz, Etai Hazan, Ehud Barnea, s: Vadim Levit, Gal Lipetz, Etai Hazan, Ehud Barnea, Ilan Smoli and Dan BraunshteinIlan Smoli and Dan Braunshtein

Course siteCourse site: http://www.cs.bgu.ac.il/~os132/Main

Meni AdlerMeni Adler

Office: Alon, 211Office: Alon, 211 [email protected]@cs.bgu.ac.il Office hours:Office hours:

Wed., 11-13Wed., 11-13

Michael ElhadadMichael ElhadadOffice: Alon, 107Office: Alon, 107

[email protected]@cs.bgu.ac.il Office hours: Office hours:

Amnon MeiselsAmnon Meisels

Office: Alon, 206Office: Alon, 206 [email protected]@cs.bgu.ac.il Office hours: Mon. 10-12Office hours: Mon. 10-12

Page 2: Operating Systems  (202-1-3031)

2

Assignments and grade structureAssignments and grade structure

AssignmentSubjectWeightProgramming 1 + 2Scheduling +

Synchronization 15%

Programming 3 + 4Memory Management + Files

15%

MidtermProcesses, scheduling, synchronization,memory (TBD)

15%

FinalAll55%

Assignments and exams are mandatory Must pass final exam

Page 3: Operating Systems  (202-1-3031)

TextbooksTextbooks A. Tanenbaum: Modern Operating Systems, Prentice-Hall, 3rd

Edition, 2008

A. Silbetschatz et al.: Operating System Concepts (8th ed.), Addison Wesley, 2009

G. Nutt: Operating Systems (a modern perspective) (3rd ed.), Addison Wesley, 2003

W. Stallings: Operating Systems (6th ed.), Prentice-Hall, 2009

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 3

Page 4: Operating Systems  (202-1-3031)

SyllabusSyllabus1. Introduction - History; Views; Concepts; Structure2. Process Management - Processes; State + Resources; Threads;

Unix implementation of Processes3. Scheduling – Paradigms; Unix; Modeling4. Synchronization - Synchronization primitives and their

equivalence; Deadlocks5. Memory Management - Virtual memory; Page replacement

algorithms; Segmentation 6. File Systems - Implementation; Directory and space

management; Unix file system; Distributed file systems (NFS)7. Security – General policies and mechanisms; protection models;

authentication8. Distributed Synchronization (if there's time)

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 4

Page 5: Operating Systems  (202-1-3031)

Introduction: outlineIntroduction: outline

What is an operating system?

Some history

OS concepts

OS structure

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 5

Page 6: Operating Systems  (202-1-3031)

Layered Hardware-Software Layered Hardware-Software Machine ModelMachine Model

Operating System

Compilers Editors ShellSystemPrograms

Banking System Airline reservation Web browserApplications

Hardware

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 6

Page 7: Operating Systems  (202-1-3031)

Computer-System ArchitectureComputer-System Architecture

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 7

Page 8: Operating Systems  (202-1-3031)

What is an Operating System ?What is an Operating System ?

An operating system is:

1. An Extended Machine

2. A Resource manager

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 8

Page 9: Operating Systems  (202-1-3031)

Operating Systems as extended MachinesOperating Systems as extended Machines

The problems:Bare machine has complex structure

o Processorso Many difficult-to-program devices

Primitive Instruction SetDifferent for Different Machines

OS provides: Abstraction!

– Simple, easier to use interface (machine-independent)– Hiding of unnecessary details

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 9

Page 10: Operating Systems  (202-1-3031)

OS abstraction example: read from diskOS abstraction example: read from disk

Read file data from disk (simplified)… Read linear sector 17,403 from disk 2 Convert linear sector number to: cylinder, sector, head

(may be complicated – outer cylinders have more sectors, bad sectors remapped, etc.)

Move disk arm to requested cylinder Wait for proper sector to appear

OS abstractionreturn-code = read(fd, buff, nbytes)

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 10

Page 11: Operating Systems  (202-1-3031)

UNIX high-level architectureUNIX high-level architecture

UserInterface

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 11

Page 12: Operating Systems  (202-1-3031)

Operating Systems as Resource ManagersOperating Systems as Resource Managers Multiple resources

o Processors; Memoryo Disks; Tapes; Printerso Network interfaces; Terminals

Controlled allocation of Resources among:o Groups, Users; Processes, Threads,…

Means of control: sharing/multiplexing/scheduling, monitoring, protection, report/payment

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 12

Page 13: Operating Systems  (202-1-3031)

Introduction: outlineIntroduction: outline

What is an operating system?

Some history

OS concepts

OS structure

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 13

Page 14: Operating Systems  (202-1-3031)

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels

History of Operating SystemsHistory of Operating Systems First generation 1945 - 1955

o vacuum tubes, plug boards – user plugs-in programuser plugs-in program

14

Page 15: Operating Systems  (202-1-3031)

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels

The first computersThe first computers

15

Electronic Numerical Integrator And Computer (ENIAC)

Mathematical Analyzer, Numeric Integrator And Computer(MANIAC)

Page 16: Operating Systems  (202-1-3031)

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels

Second generation 1955 - 1965o transistors, batch systems – multiple programs on multiple programs on DiskDisk

Third generation 1965 – 1980o ICs and multiprogramming - user interaction (user interaction (time-sharingtime-sharing))

Fourth generation 1980 – presento personal computers – graphic user-interfacegraphic user-interfaceo Networks – file & computing file & computing servicesserviceso Web-computing, Handheld devices , Cellular phones, Cloud computing…Handheld devices , Cellular phones, Cloud computing…

History of Operating Systems History of Operating Systems (cont’d)(cont’d)

16

Page 17: Operating Systems  (202-1-3031)

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels

How Bill Gates became rich…How Bill Gates became rich…

1974: Intel releases the 8080 processor, needs an OS

Gary Kildall

Please! develop an OS

CP/M OS

17

Page 18: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 18

Page 19: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 19

Page 20: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 20

Page 21: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 21

Page 22: Operating Systems  (202-1-3031)

How Bill Gates became rich…How Bill Gates became rich…(cont’d)(cont’d)

Well, this is 20:20 hind vision…

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 22

Page 23: Operating Systems  (202-1-3031)

Introduction: outlineIntroduction: outline

What is an operating system?

Some history

OS concepts

OS structure

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 23

Page 24: Operating Systems  (202-1-3031)

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

Secondary storage managemento Free-space managemento Storage allocation

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 24

Page 25: Operating Systems  (202-1-3031)

File system managemento File + directory - creation; deletiono File manipulation primitiveso Mapping files onto secondary storage

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 25

Page 26: Operating Systems  (202-1-3031)

Processes - a key conceptProcesses - a key concept

Resource container for “program in execution” Timesharing, process suspension/preemption Process Table Process Groups Signals

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 26

Page 27: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 27

Page 28: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 28

Page 29: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 29

Page 30: Operating Systems  (202-1-3031)

Inter-Process Communication (IPC)Inter-Process Communication (IPC)

Two processes communicating via a pipe

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 30

Page 31: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 31

Page 32: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 32

Page 33: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 33

Page 34: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 34

Page 35: Operating Systems  (202-1-3031)

Synchronous vs. Asynchronous I/O Synchronous vs. Asynchronous I/O

execute

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 35

Page 36: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 36

Page 37: Operating Systems  (202-1-3031)

System CallsSystem Calls

processes

files

directories

miscellaneous

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 37

Page 38: Operating Systems  (202-1-3031)

The Shell Command LanguageThe Shell Command Language

sort < file1 > file2sort < file1 > file2 cat file1 | sort | lprcat file1 | sort | lpr

• The Shell is a process which executes its commands as offspringoffspring processesprocesses

• Processes may call shell commands by using the “system” system call

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 38

Page 39: Operating Systems  (202-1-3031)

Shell structure – Parent & childShell structure – Parent & childA 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 */ wait(); /* wait for child to exit */ } else { /* Child code */ execvp (command, parameters); /* execute command */ }}

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 39

Page 40: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 40

Page 41: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 41

Page 42: Operating Systems  (202-1-3031)

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels

UNIX Utility Programs

A few of the more common UNIX utility programs required by POSIX

42

Page 43: Operating Systems  (202-1-3031)

Introduction: outlineIntroduction: outline

What is an operating system?

Some history

OS concepts

OS structure

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 43

Page 44: Operating Systems  (202-1-3031)

Operating system structureOperating system structure

1. Monolithic systems

2. Virtual machines

3. Client-server model

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 44

Page 45: Operating Systems  (202-1-3031)

Monolithic systems Monolithic systems

Monolithic systems have little structure

ServiceRoutines

Utilityprocedures

Main procedure forinvoking OS service

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 45

Page 46: Operating Systems  (202-1-3031)

Monolithic systems Monolithic systems

Service routines are system calls

Utility procedures serve multiple service routines

All compiled into a single system

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 46

Page 47: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 47

Page 48: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 48

Page 49: Operating Systems  (202-1-3031)

Virtual Machines Virtual Machines (cont’d)(cont’d)

Operating Systems, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 49

Page 50: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 50

Page 51: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 51

Page 52: Operating Systems  (202-1-3031)

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 52

Page 53: Operating Systems  (202-1-3031)

Client/server architecture:Client/server architecture:Mechanism vs. PolicyMechanism vs. Policy

Simple Kernel - modularity; minimal “privileged” operation

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, 2013, Meni Adler, Michael Elhadad & Amnon Meisels 53