Скачать презентацию Operating Systems 202 -1 -3031 Meni Adler ü Скачать презентацию Operating Systems 202 -1 -3031 Meni Adler ü

7f2f3971c65176596d85432feaae5dd6.ppt

  • Количество слайдов: 53

Operating Systems (202 -1 -3031) Meni Adler ü Office: Alon, 109 ü meni. adler@gmail. Operating Systems (202 -1 -3031) Meni Adler ü Office: Alon, 109 ü meni. adler@gmail. com ü Office hours: Tuesdays, 08: 00 -10: 00 Danny Hendler ü Office: Alon, 218 ü hendlerd@cs. bgu. ac. il ü Office hours: Tuesdays, 11: 00 -13: 00 Roie Zivan ü Office: 16 build. , 261 ü zivan. roie@gmail. com ü Office hours: Sundays, 09: 00 -11: 00 Lecturers: Meni Adler, Danny Hendler and Roie Zivan TAs: Dan Brownstein, Zohar Komarovsky, Matan Drory, Omer Litov, Vadim Levit Course site: http: //www. cs. bgu. ac. il/~os 152/Main site

Assignments and grade structure Assignment Subject Weight Programming 1 + 2 Scheduling + Synchronization Assignments and grade structure Assignment Subject Weight Programming 1 + 2 Scheduling + Synchronization 15% Programming 3 + 4 Memory Management + Files 15% Midterm Processes, scheduling, synchronization, memory (TBD) 15% Final All 55% q Assignments and exams are mandatory q Must pass final exam

Textbooks q A. Tanenbaum: Modern Operating Systems, Prentice-Hall, 3 rd Edition, 2008 q A. Textbooks q A. Tanenbaum: Modern Operating Systems, Prentice-Hall, 3 rd Edition, 2008 q A. Silbetschatz et al. : Operating System Concepts (9 th ed. ), Addison Wesley, 2012 q G. Nutt: Operating Systems (a modern perspective) (3 rd ed. ), Addison Wesley, 2003 q W. Stallings: Operating Systems (6 th ed. ), Prentice-Hall, 2009 Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 3

Syllabus 1. Introduction - History; Views; Concepts; Structure 2. Process Management - Processes; State Syllabus 1. Introduction - History; Views; Concepts; Structure 2. Process Management - Processes; State + Resources; Threads; Unix implementation of Processes 3. Scheduling – Paradigms; Unix; Modeling 4. Synchronization - Synchronization primitives and their equivalence; Deadlocks 5. Memory Management - Virtual memory; Page replacement algorithms; Segmentation 6. File Systems - Implementation; Directory and space management; Unix file system; Distributed file systems (NFS) 7. Distributed Synchronization (if there's time) Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 4

Introduction: outline q. What is an operating system? q. Some history q. OS concepts Introduction: outline q. What is an operating system? q. Some history q. OS concepts q. OS structure Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 5

Layered Hardware-Software Machine Model Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan Layered Hardware-Software Machine Model Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 6

Computer-System Architecture Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 7 Computer-System Architecture Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 7

What is an Operating System ? An operating system is: 1. An Extended Machine What is an Operating System ? An operating system is: 1. An Extended Machine 2. A Resource manager Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 8

Operating Systems as extended Machines The problems: q. Bare machine has complex structure o Operating Systems as extended Machines The problems: q. Bare machine has complex structure o Processors o Many difficult-to-program devices q. Primitive Instruction Set q. Different for Different Machines OS provides: Abstraction! – Simple, easier to use interface (machine-independent) – Hiding of unnecessary details Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 9

OS abstraction example: read from disk Read file data from disk (simplified) … q OS abstraction example: read from disk Read file data from disk (simplified) … q q 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 abstraction return-code = read(fd, buff, nbytes) Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 10

UNIX high-level architecture User Interface Operating Systems, 2015, Meni Adler, Danny Hendler & Roie UNIX high-level architecture User Interface Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 11

Operating Systems as Resource Managers q Multiple resources o Processors; Memory o Disks; Tapes; Operating Systems as Resource Managers q Multiple resources o Processors; Memory o Disks; Tapes; Printers o Network interfaces; Terminals q Controlled allocation of Resources among: o Groups, Users; Processes, Threads, … q Means of control: sharing/multiplexing/scheduling, monitoring, protection, report/payment Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 12

Introduction: outline q. What is an operating system? q. Some history q. OS concepts Introduction: outline q. What is an operating system? q. Some history q. OS concepts q. OS structure Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 13

History of Operating Systems q First generation 1945 - 1955 o vacuum tubes, plug History of Operating Systems q First generation 1945 - 1955 o vacuum tubes, plug boards – user plugs-in program Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 14

The first computers Electronic Numerical Integrator And Computer (ENIAC) Mathematical Analyzer, Numeric Integrator And The first computers Electronic Numerical Integrator And Computer (ENIAC) Mathematical Analyzer, Numeric Integrator And Computer(MANIAC) Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 15

History of Operating Systems (cont’d) q Second generation 1955 - 1965 o transistors, batch History of Operating Systems (cont’d) q Second generation 1955 - 1965 o transistors, batch systems – multiple programs on Disk q Third generation 1965 – 1980 o ICs and multiprogramming - user interaction (time-sharing) q Fourth generation 1980 – present o personal computers – graphic user-interface o Networks – file & computing services o Web-computing, Handheld devices , Cellular phones, Cloud computing… Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 16

How Bill Gates became rich… 1974: Intel releases the 8080 processor, needs an OS How Bill Gates became rich… 1974: Intel releases the 8080 processor, needs an OS Please! develop an OS CP/M OS Gary Kildall Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 17

How Bill Gates became rich…(cont’d) 1974: Intel releases the 8080 processor, needs an OS How Bill Gates became rich…(cont’d) 1974: Intel releases the 8080 processor, needs an OS CP/M OS Sure! Can you grant me CP/M rights? Gary Kildall Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 18

How Bill Gates became rich…(cont’d) 1980: IBM designs IMB PC, needs an OS Can How Bill Gates became rich…(cont’d) 1980: IBM designs IMB PC, needs an OS Can you find an OS for our PC? So rry , t oo bu sy !!! !! Please meet IBM, they need an OS Gary Kildall Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 19

How Bill Gates became rich…(cont’d) 1980: IBM designs IMB PC, needs an OS Kildall How Bill Gates became rich…(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, 2015, Meni Adler, Danny Hendler & Roie Zivan 20

How Bill Gates became rich…(cont’d) 1980: IBM designs IMB PC, needs an OS May How Bill Gates became rich…(cont’d) 1980: IBM designs IMB PC, needs an OS May I retain the rights for MSDOS? Sure, why not!! Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 21

How Bill Gates became rich…(cont’d) Well, this is 20: 20 hind vision… Operating Systems, How Bill Gates became rich…(cont’d) Well, this is 20: 20 hind vision… Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 22

Introduction: outline q. What is an operating system? q. Some history q. OS concepts Introduction: outline q. What is an operating system? q. Some history q. OS concepts q. OS structure Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 23

OS – Key Functions q Process management o process creation; deletion; suspension/preemption o process OS – Key Functions q Process management o process creation; deletion; suspension/preemption o process synchronization; communication; scheduling q Main-memory management o Manage used parts and their current users o Select processes to load from secondary storage o Allocate memory to running processes q Secondary storage management o Free-space management o Storage allocation Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 24

OS – Key Functions (cont’d) q File system management o File + directory - OS – Key Functions (cont’d) q File system management o File + directory - creation; deletion o File manipulation primitives o Mapping files onto secondary storage q I/O system management o General device-driver interface o Drivers for specific hardware devices q Protection system o Distinguish between authorized and unauthorized usage o Provide means of enforcement Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 25

Processes - a key concept q Resource container for “program in execution” q Timesharing, Processes - a key concept q Resource container for “program in execution” q Timesharing, process suspension/preemption q Process Table q Process Groups q Signals Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 26

Why do we need multiple processes? • Single application: We want things to happen 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, 2015, Meni Adler, Danny Hendler & Roie Zivan 27

Multiprogramming: how is it done? q CPU much faster than I/O o Computation/communication overlap Multiprogramming: how is it done? q CPU much faster than I/O o Computation/communication overlap q Memory large enough – requires memory protection! q Scheduler which manages flow of jobs in and out and shares CPU between jobs – requires Timer Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 28

Process trees • A process tree q A created two child processes, B and Process trees • A process tree q A created two child processes, B and C q B created three child processes, D, E, and F Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 29

Inter-Process Communication (IPC) Two processes communicating via a pipe Operating Systems, 2015, Meni Adler, Inter-Process Communication (IPC) Two processes communicating via a pipe Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 30

Files: non volatile data q File types and operations on files q Directories - Files: non volatile data q File types and operations on files q Directories - hierarchical structure q Working directories Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 31

Files: non volatile data (cont’d) q Protection and Security Unix - user; group; other Files: non volatile data (cont’d) q Protection and Security Unix - user; group; other (rwx bits) q File descriptors (handles) q I/O as a special file q Block & Character special files q Standard input; output; error q Pipes q Links Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 32

I/O is performed in kernel mode q All I/O instructions are privileged instructions q I/O is performed in kernel mode q All I/O instructions are privileged instructions q I/O devices and CPU can execute concurrently q CPU moves data between main memory and device controllers' buffers (done by device drivers) q Device controllers interrupt upon completion q Interrupts or Traps enable mode switching q Operating systems are interrupt-driven q Traps/signals: software interrupts Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 33

Interrupts and the fetch-decode-execute loop Do forever{ IR = memory[PC]; execute(IR); PC++; ic! If(Interrupt_Request) Interrupts and the fetch-decode-execute loop Do forever{ IR = memory[PC]; execute(IR); PC++; ic! If(Interrupt_Request) { list imp memory[0] = PC; S PC = memory[1] } } q An interrupt is an asynchronous event q The kernel interrupt handling routine may use a disable_interrupts instruction to avoid losing data while processing an interrupt request q Interrupt handler is typically called indirectly via the interrupt vector Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 34

Synchronous vs. Asynchronous I/O execute Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Synchronous vs. Asynchronous I/O execute Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 35

Steps in Making a System Call There are 11 steps in making the system 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, 2015, Meni Adler, Danny Hendler & Roie Zivan 36

System Calls processes files directories miscellaneous Operating Systems, 2015, Meni Adler, Danny Hendler & System Calls processes files directories miscellaneous Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 37

The Shell Command Language q sort < file 1 > file 2 q cat The Shell Command Language q sort < file 1 > file 2 q cat file 1 | 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 Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 38

Shell structure – Parent & child A stripped-down shell: while (TRUE) { type_prompt( ); Shell structure – Parent & child A stripped-down shell: while (TRUE) { type_prompt( ); read_command (command, parameters) if (fork() > 0) { /* Parent code */ wait(); } else { /* Child code */ execvp (command, parameters); } /* repeat forever */ /* display prompt */ /* input from terminal */ /* fork off child process */ /* wait for child to exit */ /* execute command */ } Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 39

Linux Shell initialization q The init program (process 1) runs getty on all ports Linux Shell initialization q The init program (process 1) runs getty on all ports q Upon detecting a terminal, getty runs login q 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 q The shell is run with that user ID environment parameters Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 40

Running user commands q User types: ‘grep some_word file_name’ q Shell parses the command, Running user commands q User types: ‘grep some_word file_name’ q Shell parses the command, inserts the strings grep, some_word, file_name into argv and their number to argc q Next, the shell uses fork() to create a process (same user ID) q 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 q On foreground execution, the shell would use the wait() system call and continue its session only after the child process terminates Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 41

UNIX Utility Programs A few of the more common UNIX utility programs required by UNIX Utility Programs A few of the more common UNIX utility programs required by POSIX Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 42

Introduction: outline q. What is an operating system? q. Some history q. OS concepts Introduction: outline q. What is an operating system? q. Some history q. OS concepts q. OS structure ( )חומר העשרה Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 43

Operating system structure 1. Monolithic systems 2. Virtual machines 3. Client-server model … Operating Operating system structure 1. Monolithic systems 2. Virtual machines 3. Client-server model … Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 44

Monolithic systems have little structure Main procedure for invoking OS service Service Routines Utility Monolithic systems have little structure Main procedure for invoking OS service Service Routines Utility procedures Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 45

Monolithic systems q Service routines are system calls q Utility procedures serve multiple service Monolithic systems q Service routines are system calls q Utility procedures serve multiple service routines q All compiled into a single system Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 46

Virtual Machines q Provide an interface identical to the underlying bare machine q VM Virtual Machines q Provide an interface identical to the underlying bare machine q VM monitor creates multiple VMs, each executing on its own (virtual) processor and its own (virtual) memory q Virtual machines provide complete protection of system resources - even separate resources q Difficult to implement, due to the effort required to provide an exact duplicate of the underlying machine q Well-known examples: o MS-DOS on top of Windows o JVM o VMWare Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 47

Virtual Machines: IBM 370 user CMS CMS kernel VM/370 bare hardware CMS: Conversational Monitor Virtual Machines: IBM 370 user CMS CMS kernel VM/370 bare hardware CMS: Conversational Monitor System, a single user OS Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 48

Virtual Machines (cont’d) Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 49 Virtual Machines (cont’d) Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 49

Modern virtual machines q Different legacy servers run on different OS q Host sharing Modern virtual machines q Different legacy servers run on different OS q Host sharing for web servers q Use multiple operating systems on a single machine q Security through isolation Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 50

Microkernels q Small number of lines of code mostly in C q Catching interrupts Microkernels q Small number of lines of code mostly in C q Catching interrupts and switching processes in Assembly q C code manages and schedules processes, interprocess communication, i/o interaction q Offers few (~40) system calls for the rest of OS q Device drivers (Disk, Network, …) in user mode q Upper level contains Servers – File, Process. . Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 51

Client-Server Model Client Process . . . File Server Memory Server (Micro)Kernel Machine 1 Client-Server Model Client Process . . . File Server Memory Server (Micro)Kernel Machine 1 . . Machine 2 Client File Server Kernel Network Machine 4 Machine 3 Process Server Kernel . . . Distributed System Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 52

Client/server architecture: Mechanism vs. Policy q Simple Kernel - modularity; minimal “privileged” operation q Client/server architecture: Mechanism vs. Policy q Simple Kernel - modularity; minimal “privileged” operation q Servers for files, memory, etc. - distribution; user mode operation q good for distributed systems q Mechanism in kernel - how to do things. . q Policy outside - decide what to do; can be changed later. . q Critical servers in kernel – i/o disk server & the Scheduler – who serves who…. Operating Systems, 2015, Meni Adler, Danny Hendler & Roie Zivan 53