290 likes | 443 Views
CS 414 Operating Systems. Chapter 1 (PART 2) Operating System Concepts. Department of Computer Science Southern Illinois University Edwardsville Summer, 2004 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu. Chapter_One_2/001. Operating System Concepts.
E N D
CS 414 Operating Systems Chapter 1 (PART 2) Operating System Concepts Department of Computer Science Southern Illinois University Edwardsville Summer, 2004 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu Chapter_One_2/001
Operating System Concepts This PPT presentation covers Section 1.5 of the textbook. CS 414 Operating Systems (1) Process (2) Deadlock avoidance in I/O resource management (3) Files and file descriptor (4) Special Files Chapter_One/002
Subjects covered about “process” Q: What is “process”? “program” is an executable file stored in a disk program HDD Solutions Stored as a file CS 414 Operating Systems • What is “process”? • How is it different from “program”? • What we can do by “processes”? A: “Process” is a program in execution. Chapter_One/003
Then how a “program” can become “process”? A program becomes a process Stored as a file CPU Load program Memory HDD CS 414 Operating Systems when one is loaded into the memory for execution by CPU Chapter_One/004
Things needed for a program to be executed in memory PCB is a data structure for the CPU to keep track of each process CPU PCB-X PCB-A PCB-Z Address Space Program X Program Z HDD PCB = Process Control Block Process Memory CS 414 Operating Systems Stack Memory Program Code Heap Memory Program Chapter_One/005
Example of “program” and “process” • Program Static object, usually exists as an executable file • Process This is a program Program in execution This is a process (program in execution) CS 414 Operating Systems Chapter_One/006
Intermediate summary of “process” Collection of assembly instructions CPU runs Stack data structure for sub-routine calls Other data structure (local/global variables) Questions Where are PCBs located? What information does PCB hold? CS 414 Operating Systems • It is a program in execution • A process consists of the contents in process address space and PCB • Process address space consists of: Program Code Stack Memory Space Heap Memory Space Chapter_One/007
Things needed for a program to be executed in memory CPU In the operating system PCB-X PCB-A PCB-Z Program X Program Z Program Y OS Memory CS 414 Operating Systems Where are PCBs located? Chapter_One/008
Deadlock avoidance in I/O resource management More than one process wait for resource for each other for forever HDD Example Process B Process A Deadlock wait Printer Assigned Assigned Resources wait CS 414 Operating Systems What is “deadlock”? • Assume that there are two processes • Each of the two processes requires printer and HDD at the same time • Without the printer and HDD, neither can finish its tasks (Circular-wait) Chapter_One/009
Concept of files and file descriptor use close What is a file? load Logical data storages in computer systems What is “file descriptor”? Logical identification for each file being used in a computer system. open read HDD user OS CS 414 Operating Systems file Chapter_One/010
Concept of files and file descriptor (continued) Open “A.txt” Find/Access File Descriptor OS User File Allocation Table “A.txt” File Names Sector Locations Location on disk Load • Sectors • Track • Platters HDD File Names Y X B A CS 414 Operating Systems 1E23CD A.txt • Read (FD) • Write (FD) • Append (FD) Chapter_One/011
Network Concept of Special Files Request Request Request (1) Special Files OS OS Internet Internet Users can I/O to many devices as if they were a file Response (4) HDD Ordinary File Can not be seen by human user HDD file user user Keyboard Modem Special Files printer CS 414 Operating Systems Chapter_One/012
A concept in OS where a user can handle many I/O devices using the same interface (APIs) that is used for actual files. Special Files Read/Write Read-Only Write-Only CS 414 Operating Systems • When you open (reserve) a resource, OS gives you “descriptor” • Some special files are read-only and some others may be write-only - Printer - Keyboard - Disks - CRT Monitor - Mouse - Network - CD-ROM • CRT Monitor • (with touch-pen support) Chapter_One/013
This PPT presentation covers Section 1.7 of the textbook. Monolithic Structure Layered Structure Windows uses these concepts Operating System Structure VM (Virtual Machine) Micro-Kernel CS 414 Operating Systems Chapter_One/014
No structure in a collection of procedures Program OS Procedures Disk I/O Printer Spooler Monolithic Structure OS Process Mgmt. Memory Mgmt. user IPC KB I/O CS 414 Operating Systems • Operating systems are essentially a collection of procedures. Monolithic Structure OS (Any procedure or a user application can call any other procedure) • Big mess • But fast • (no overhead) Chapter_One/015
Operating system as an executable program Printer Spooler KB I/O OS How is a Monolithic-Structured OS implemented? Concatenate into one source code file OS Procedures Compile IPC Memory Mgmt. Process Mgmt. Disk I/O Printer Spooler Disk I/O Source code modules Process Mgmt. Memory Mgmt. IPC KB I/O CS 414 Operating Systems Chapter_One/016
External Commands Printer Spooler KB I/O “OS” in a broader definition OS How is a Monolithic-Structured OS implemented? IPC Memory Mgmt. exec (); System calls awk Process Mgmt. Disk I/O sort execute Program grep “OS Kernel” user CS 414 Operating Systems Operating system as an executable program Chapter_One/017
Layers of priorities Process Management Memory Management I/O Management Layered Structure Operating Systems User Programs Process Communication CS 414 Operating Systems “Layers” Chapter_One/017-B
user App1 Without VM App N Application programs Hardware With VM A virtual machine Virtual Machine (VM) Extra layer on top of hardware OS2 OS1 OS3 Operating System Hardware Virtual Machine Support Windows 2000 UNIX MS-DOS CS 414 Operating Systems Chapter_One/018
For each application program, it looks like they are being executed by thededicated hardware Concept of VM Hardware2 Hardware1 Hardware3 OS2 OS2 OS1 OS1 OS3 OS3 Hardware Virtual Machine Support CS 414 Operating Systems Chapter_One/019
Implementation of of VM OS1 OS3 OS2 VM1 Process Manage Without VM Process X Process Y Process Z VM2 Process X Process Y Process M Process A Process B Process N Process Manage With VM VM3 Process Manage VMS OS VM Manage Process Manage Memory Memory CS 414 Operating Systems Chapter_One/020
MS-DOS VM Win32 MS-DOS MS-DOS Windows-9x VM Hardware Virtual Machine Support CS 414 Operating Systems • All Win-32 applications are execute in Win-32 kernel • Each MS-DOS application will be executed within its VM Chapter_One/021
A virtual computer where computer hardware is software-emulated by VMS (Virtual Machine Support) VM Summary of Virtual Machine (VM) - For flexibility Multiple operating systems (and its applications) at once - For robustness One VM crashes, others still survive CS 414 Operating Systems • Provide virtual dedicated machine (= hardware) to each OS (Q: What’s the difference from “multiple boot”?) (EG: Windows-NT) Chapter_One/022
External Commands KB I/O Printer Spooler “OS” in a broader definition OS IPC Memory Mgmt. awk Process Mgmt. Micro-Kernel Architecture Disk I/O sort grep “OS Kernel” CS 414 Operating Systems Chapter_One/023
Micro-Kernel Architecture (continued) External Commands Printer Spooler Printer Spooler KB I/O “OS” in a broader definition IPC Memory Mgmt. Memory Mgmt. awk Process Mgmt. Process Mgmt. Disk I/O sort OS grep “OS Kernel” CS 414 Operating Systems Chapter_One/024
Micro-Kernel Architecture (continued) Kernel-Mode In ordinary OS (not Micro-Kernel OS), OS has to provide all the user services in Kernel-mode services User-Mode User Program System Call Operating System Computer Hardware OS Procedure (in the OS kernel) OS kernel tends to be huge CS 414 Operating Systems Chapter_One/025
Micro-Kernel Architecture (continued) Kernel-Mode Server Make the OS kernel as small as possible Spooler User-Mode User Program Client Operating System Computer Hardware Micro-Kernel Architecture is based on Client-Server Model Operating System becomes a service broker CS 414 Operating Systems Micro-kernel Architecture Chapter_One/026
Micro-Kernel Architecture (continued) A bug in OS can be fixed by replacing a module MS Windows uses micro-kernel architecture for this reason What is it good for? OS functions may be executed in user-mode CS 414 Operating Systems (1) Each OS function becomes a module (what we should do if “monolithic structure kernel”?) (2) Better robustness (a bug in a module will not crash the kernel) Chapter_One/027