Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Operating Systems

Similar presentations


Presentation on theme: "Advanced Operating Systems"— Presentation transcript:

1 Advanced Operating Systems
Mehdi Naghavi Winter 1385

2 Course motivation and goals
Programming computer hardware directly is difficult Operating systems provide a layer between applications and computer hardware (VM) Understanding operating system concepts is essential to many advanced programming tasks

3 Class outline Introduction and Overview Processes and threads
Operating system structures Memory management Scheduling Input/Output File Systems Security

4 Textbook Andrew S. Tanenbaum. “Operating Systems design and implementation”, 3nd ed., Prentice Hall, 2006. Abraham Silberschatz, Galvin, and Gagne. “Operating Systems Concepts”, 7nd ed., John Wiley and Sons, 2005 William Stallings. “Operating Systems”, 4nd ed., Prentice Hall, 2001. Andrew S. Tanenbaum. “Modern Operating Systems”, 2nd ed., Prentice Hall, 2001. Andrew S. Tanenbaum. “Distributed Operating Systems”, Prentice Hall.

5 Mobile Phones, pagers and other similar devices OFF during class
Points Mobile Phones, pagers and other similar devices OFF during class Collegians must be Presence in classroom Contact

6 Mehdi Naghavi naghavi@aut.ac.ir Winter 1385
Operating Systems Introduction to Operating Systems Mehdi Naghavi Winter 1385

7 Overview: What is an operating system? Operating systems history
The zoo of modern operating systems Review of computer hardware Operating system concepts System calls Operating system structure User interface to the operating system Anatomy of a system call

8 Samples of Operating Systems
IBSYS (IBM 7090) OS/360 (IBM 360) TSS/360 (360 mod 67) Michigan Terminal System CP/CMS & VM 370 MULTICS (GE 645) Alto (Xerox PARC) Pilot (Xerox STAR) CP/M IRIX Solaris MVS VxWorks MACH Apollo DOMAIN Unix (System V & BSD) Apple Mac (v. 1– v. 9) MS-DOS Windows NT, 2000, XP Novell Netware Linux FreeBSD PalmOS PocketPC VxWorks

9 Samples of Operating Systems (continue…)

10 What is an Operating System?
An Operating System is a program that acts as an intermediary/interface between a user of a computer and the computer hardware. It is an extended machine Hides the messy details which must be performed Presents user with a virtual machine, easier to use It is a resource manager Each program gets time with the resource Each program gets space on the resource

11 The Operating System controls the machine
Compiler Debugger User OS Kernel Video Game Hard ware Application App. Editor Operating System Terminal emulator  Hardware Browser

12 Static View of System Components
User 1 User 2 User 3 User 4 User n Compiler Editor Database Calculator WP Operating System Hardware

13 Dynamic View of System Components

14 Layers of a Computer System
End User Programmer Application Programs Utilities Operating- System Designer Operating-System Computer Hardware

15 History of Operating Systems
First generation: 1945 – 1955 Vacuum tubes, Plug boards Second generation: 1955 – 1965 Transistors, Batch systems Third generation: 1965 – 1980 Integrated circuits, Multiprogramming Fourth generation: 1980 – present Large scale integration, Personal computers Next generation: ??? Systems connected by high-speed networks? Wide area resource management?

16 First generation: direct input
Run one job at a time Enter it into the computer (might require rewiring!) Run it Record the results Problem: lots of wasted computer time! Computer was idle during first and last steps Computers were very expensive! Goal: make better use of an expensive commodity: computer time

17 Second generation: batch systems
Bring cards to 1401 Read cards onto input tape Put input tape on 7094 Perform the computation, writing results to output tape Put output tape on 1401, which prints output

18 Structure of a typical 2nd generation job
Data for program $END FORTRAN program $RUN $LOAD $FORTRAN $JOB, 10, , JANE DOE

19 Third generation: multiprogramming
Multiple jobs in memory Protected from one another Operating system protected from each job as well Resources (time, hardware) split between jobs Still not interactive User submits job Computer runs it User gets results minutes (hours, days) later Job 3 Job 2 Memory partitions Job 1 Operating system

20 Multi tasking Resource utilization
Operating System Main Memory Job 1 Task 1 Task 2 CPU Job 2 Job 3 Resource utilization Multiprogramming, multitasking, and multiple users. Time sharing. Response time.

21 Timesharing Multiprogramming allowed several jobs to be active at one time Initially used for batch systems Cheaper hardware terminals → interactive use Computer use got much cheaper and easier No more “priesthood” Quick turnaround meant quick fixes for problems

22 Types of modern operating systems
Mainframe operating systems: MVS Server operating systems: FreeBSD, Solaris Multiprocessor operating systems: Cellular IRIX Personal computer operating systems: XP, Linux PDA operating systems: PalmOS, PocketPC Real-time/embedded operating systems: VxWorks, QNX Smart card operating systems Some operating systems can fit into more than one category Got here on the first day of class.

23 Computer Hardware Review
Computer block diagram Components of a simple personal computer CPU internals Memory Storage pyramid Disk drive structure Anatomy of a device request Structure of a large Pentium system

24 Memory Computer Input Unit CPU Output Unit Control Unit ALU
Keyboard Mouse Scanner Modem Input Unit CPU Monitor Printer Modem Output Unit Control Unit ALU Registers Bank Cache Memory Memory Main Memory RAM ROM Secondary Memory HD FD CD Flash Tertiary Memory Tape

25 Computer Components: Top-Level View
MAR - Memory Address Register address for next read or write MBR - Memory Buffer Register data to be written into memory receives data read from memory I/OAR - I/O Address specifies a particular I/O device I/OBR - I/O Buffer exchange of data between an I/O module and the processor

26 Components of a simple personal computer
Outside world Video controller Hard drive controller USB controller Network controller CPU Computer internals (inside the “box”) Memory

27 (a) A three-stage Pipelined CPU
CPU internals Execute unit Fetch unit Decode unit Holding buffer Fetch unit Decode unit Execute unit Execute unit Fetch unit Decode unit Execute unit (a) A three-stage Pipelined CPU (b) A Superscalar CPU

28 Memory Single base/limit pair: set for each process
Address Address 0x0002ffff 0x0002ffff User 2 program and data User 2 data 0x0002d000 0x0002b000 0x0002bfff Limit2 User 1 data 0x Base2 0x00027fff Limit User 1 program and data 0x00024fff Limit1 User program 0x Base 0x Base1 0x0001dfff 0x0001dfff Operating system Operating system 0x 0x Single base/limit pair: set for each process Two base/limit registers: one for program, one for data

29 Storage pyramid Goal: really large memory with very low latency
Capacity Access latency < 1 KB Registers Cache (SRAM) Main memory (DRAM) Magnetic disk Magnetic tape 1 ns Better 1 MB 2–5 ns 1 GB 50 ns 200 GB 5 ms > 1 TB Better 50 sec Goal: really large memory with very low latency Latencies are smaller at the top of the hierarchy Capacities are larger at the bottom of the hierarchy Solution: move data between levels to create illusion of large memory with low latency

30 Disk drive structure Data stored on surfaces Data in concentric tracks
head Data stored on surfaces Up to two surfaces per platter One or more platters per disk Data in concentric tracks Tracks broken into sectors 256B-1KB per sector Cylinder: corresponding tracks on all surfaces Data read and written by heads Actuator moves heads Heads move in unison sector platter track cylinder surfaces spindle actuator

31 Anatomy of a device request
Instructionn 3 2 Instructionn+1 1: Interrupt CPU 5 Interrupt controller Disk controller Operating system 1 6 4 3: Return Interrupt handler Left: sequence as seen by hardware Request sent to controller, then to disk Disk responds, signals disk controller which tells interrupt controller Interrupt controller notifies CPU Right: interrupt handling (software point of view) 2: Process interrupt

32 Structure of a large Pentium system

33 Operating system Components
Process Management Memory Management File Management I/O Management Process Scheduler Inter Process Communication Network Unit Command Interpreter Security Management

34 Modern Operating System Structure
Application Application Application Shared Runtime Libraries user-mode supervisor-mode System Call Interface memory manager task manager file manager network manager Device Driver Components OS Kernel Hardware

35 Processes A B C D E F G Process: program in execution
Address space (memory) the program can use State (registers, including program counter & stack pointer) OS keeps track of all processes in a process table Processes can create other processes Process tree tracks these relationships A is the root of the tree A created three child processes: B, C, and D C created two child processes: E and F D created one child process: G A B C D E F G

36 Memory image of a Unix process
Processes have three segments Text: program code Data: program data Statically declared variables Areas allocated by malloc() or new (heap) Stack Automatic variables Procedure call information Address space growth Text: doesn’t grow Data: grows “up” Stack: grows “down” 0x7fffffff Stack Data Data Text 0x

37 Synchronization and deadlock
(b) An Actual deadlock (a) A Potential deadlock

38 Hierarchical file systems
File system for a university department

39 Mounting Before mounting, After mounting floppy on b,
files on floppy are inaccessible After mounting floppy on b, files on floppy are part of file hierarchy

40 Inter-process communication
Processes may want to exchange information with each other Many ways to do this, including Network Pipe (special file): A writes into pipe, and B reads from it Process Process A B Pipe Two processes connected by a pipe

41 Types of OS structures Monolithic system Layered system
Virtual machine Exokernel Client/Server

42 Monolithic system Simple structuring model for a monolithic system
Main procedure Service Procedures Utility Procedures Simple structuring model for a monolithic system

43 Monolithic system… System call interface … Applications MM PS IPC FS
Net Kernel User space Kernel space MM = Memory Manager PS = Processor Scheduler IPC = Inter Process Communication FS = File System I/O = Input/Output manager Net = Network manager

44 MS-DOS Layer Structure

45 Layered Operating System

46 Structure of the THE operating system
Layered system User Process Scheduling Memory Management Message Interpreter Hardware I/O Management User Application User space Kernel space Layer 0 Layer 3 Layer 2 Layer 1 Layer 4 Layer 5 Structure of the THE operating system

47 UNIX System Structure

48 Virtual machine App1 App2 App3 System calls Linux Windows NT FreeBSD I/O instructions CMS (VMW) CMS (VMW) CMS (VMW) Calls to simulate I/O VM/370 “Real” I/O instructions Bare hardware First widely used in VM/370 with CMS (Conversational Monitor System) Available today in VMware Allows users to run any x86-based OS on top of Linux or NT “Guest” OS can crash without harming underlying OS Only virtual machine fails—rest of underlying OS is fine “Guest” OS can even use raw hardware Virtual machine keeps things separated

49 VMware Architecture

50 The Java Virtual Machine

51 Exokernel Same as Virtual machine
Assign one virtual computer to any user Allocate sub set of resource to any virtual machine

52 Client/Server … Processes (clients and OS servers) don’t share memory
Client process Client process Process server Terminal server File server Memory server User mode Microkernel Kernel mode The client-server model Client obtains service by sending messages to server processes Processes (clients and OS servers) don’t share memory Communication via message-passing Separation reduces risk of “byzantine” failures Examples include Mach, QNX, early versions of Windows NT

53 Client/Server… … Applications System call interface Micro Kernel
User space Kernel space Process Scheduler File System Device manager IPC Memory Management Synchronization

54 Mac OS X Structure

55 Client/Server… The client-server model in a distributed system

56 System calls Programs want the OS to perform a service
Access a file Create a process Others… Accomplished by system call Program passes relevant information to OS OS performs the service if The OS is able to do so The service is permitted for this program at this time OS checks information passed to make sure it’s OK Don’t want programs reading data into other programs’ memory!

57 System calls… Applications System call interface … MM PS IPC FS I/O
Net User space Kernel space OS Component Applications

58 Making a system call System call: read(fd,buffer,length)
Program pushes arguments, calls library Library sets up trap, calls OS OS handles system call Control returns to library Library returns to user program There are 9 steps in making the system call 0xffffffff Library (read call) Return to caller 8 7 Trap to kernel 4 Trap code in register 3 User space 2 Increment SP 9 Call read 1 Push arguments User code Kernel space (OS) Dispatch 5 6 Sys call handler

59 System calls for files & directories
Description fd = open(name,how) Open a file for reading and/or writing s = close(fd) Close an open file n = read(fd,buffer,size) Read data from a file into a buffer n = write(fd,buffer,size) Write data from a buffer into a file s = lseek(fd,offset,whence) Move the “current” pointer for a file s = stat(name,&buffer) Get a file’s status information (in buffer) MINIX System calls

60 More system calls Call Description pid = fork()
Create a child process identical to the parent pid=waitpid(pid,&statloc,options) Wait for a child to terminate s = execve(name,argv,environp) Replace a process’ core image exit(status) Terminate process execution and return status s = chdir(dirname) Change the working directory s = chmod(name,mode) Change a file’s protection bits s = kill(pid,signal) Send a signal to a process seconds = time(&seconds) Get the elapsed time since 1 Jan 1970 MINIX System calls

61 A simple 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 */ }

62 System Calls Some UNIX and Win32 API calls

63 Metric units Exp. Prefix 10-3 milli 103 Kilo 10-6 micro 106 Mega 10-9
Number Prefix 10-3 0.001 milli 103 1,000 Kilo 10-6 micro 106 1,000,000 Mega 10-9 nano 109 1,000,000,000 Giga 10-12 pico 1012 1,000,000,000,000 Tera 10-15 femto 1015 1,000,000,000,000,000 Peta 10-18 atto 1018 1,000,000,000,000,000,000 Exa

64 Review How does a batch operating system differ from a multiprogrammed operating system? Why is multiprogramming useful? Why are multiprogrammed systems much more difficult to implement than are batch systems? What is timesharing? How does it differ from multiprogramming? What is an online system? What is a real-time system? Which systems try to maximize throughput? Which ones try to minimize response time?

65 What type of operating system would you use
For editing a letter? For controlling a chemical reaction? For processing payroll? In a cellphone? In a toy? For surfing the web? For air traffic control? For a scientific simulation? To play MP3?

66 Computer architecture
What connects the processor to memory? What are the components of the storage hierarchy? What is between the processor and I/O devices? What are the components of a disk? What is an interrupt? Why are interrupts useful? What happens to program execution when an interrupt occurs?

67 OS interaction Does it differ if the operating system is monolithic or a microkernel? What are the steps involved when the operating system is monolithic? What additional steps happen in case of a microkernel?


Download ppt "Advanced Operating Systems"

Similar presentations


Ads by Google