410 likes | 422 Views
CSCI 4334 Operating Systems Review: Exam 1. Review. Chapters 1 ~ 6 in your textbook Lecture slides In-class exercises (on the course website) Review slides. Review. 5 questions (100 points) + 1 bonus question (20 points) Question types Q/A. Time & Place & Event.
E N D
Review • Chapters 1 ~ 6 in your textbook • Lecture slides • In-class exercises (on the course website) • Review slides
Review • 5 questions (100 points) + 1 bonus question (20 points) • Question types • Q/A
Time & Place & Event • 2:35pm ~ 3:50am, Feb. 23, Thursday • ENGR 1.272 • Closed-book exam
Chapter 1: Introduction and Overview of Operating Systems • Computer system • Hardware • Software • Application software • System software • Operating system • Operating system • resource abstraction: software & hardware abstraction • resource sharing: time & space multiplexing • Operating Systems Strategies
Application Programmer Software API Command Line Interpreter Loader Window System Libraries Libraries Libraries Compiler System Software OS Database Management System Hardware Chapter 1: Software Classification
Chapter 1: Purpose of an OS(What is Resource Management?) • “An OS creates resource abstractions” • “An OS manages resource sharing”
Chapter 1: Operating System Functions • Resource manager • manage hardware and software resources • Resource abstraction and sharing • A nicer environment • implement a virtual machine for processes to run in • A program in execution is called a process • a nicer environment than the bare hardware
Chapter 1: Abstract Resources User Interface Application Abstract Resources (API) Middleware OS Resources (OS Interface) OS Hardware Resources
Chapter 1: Resource Management Functions • Transform physical resources to logical resources • Resource abstraction • Make the hardware resources easier to use • Multiplex one physical resource to several logical resources • Create multiple, logical copies of resources • Schedule physical and logical resources • Decide who gets to use the resources
Chapter 1: Resource Sharing • Two types of sharing • Time multiplexed sharing • time-sharing • schedule a serially-reusable resource among several users • Space multiplexed sharing • space-sharing • divide a multiple-use resource up among several users
Chapter 1: Operating Systems Strategies • Several different strategies have been used • Earliest computers were dedicated to a single program and there was no multiprogramming and no OS • Batch systems • Timesharing systems • There are a few other recent strategies • Personal computers and workstations • Embedded systems • Small, communicating computers • Network technology
Chapter 2: Using the Operating System • Operating systems provide a virtual computing environment for application programmers • Functions provided by O.S. • Abstract resources by O.S. • Files • Processes and threads • Objects • Programmers can develop applications more efficiently
Chapter 2: Using the Operating System (cont'd) • Process • an infrastructure in which execution takes place • address space + resources • Thread • a program in execution within a process context • each thread has its own stack • Components • program counter • register set • stack space
Chapter 2: Using the Operating System (cont'd) • UNIX fork() creates a process • Creates a new address space • Copies text, data, & stack into new address space • Provides child with access to open files • UNIX wait()allows a parent to wait for a child to terminate • UNIX execve()allows a child to run a new program • UNIX sleep() allows a process to suspend itself for some time • Windows CreateProcess() and CreateThread() • Examples of using functions above (see lecture slides)
Chapter 2: Processes vs. Threads • Benefits of multithreading • Improve application responsiveness • Netscape uses multithreaded programming • Use multiprocessors efficiently • Improve program structure • Use fewer system resources • Faster to switch between threads than processes
Idea Execution Engine Files Files Files Algorithm Stack Status Source Program Binary Program Data Other Resources Process Chapter 2: Algorithms, Programs, and Processes
Chapter 2: Process Abstraction Data Process Stack Program Operating System Processor Hardware Executable Memory
Files Files Files Stack Stack Stack Status Status Status Chapter 2: A Process with Multiple Threads Thread (Execution Engine) Data Other Resources Binary Program Process
Chapter 2: The File Abstraction Data File Process Stack Program Operating System File Descriptor Processor Storage Device Hardware Executable Memory
Chapter 3: OS Organization • Basic OS Responsibilities • Basic OS Functions • Three basic implementation mechanisms • Processor modes • What are Supervisor & user modes? How to switch between them? • What are privileged instructions? • I/O instructions, and instructions to change the mode or set the halt flag • Kernels • What is trap instruction for? How to use it? • Method of invoking system service • How to perform a system call or message passing?
File Manager Process, Thread & Resource Manager Memory Manager Device Manager Processor(s) Main Memory Devices Chapter 3: Basic OS Organization
Chapter 3: Device Management • OS uses policies chosen by designer or system administrator to manage • Allocation • Isolation • Sharing • Device manager in two parts • Device independent – provides unified interface • Device dependent – device driver: handles those aspects unique to a device
Chapter 3: Process Management Process Description Process Mgr Protection Deadlock Synchronization Resource Manager Resource Manager Resource Manager Scheduler CPU Other H/W
Isolation & Sharing Virtual Memory Block Allocation Process Manager Primary Memory Storage Devices Chapter 3: Memory Management
Chapter 3: Processor Modes • Mode bit: Supervisor or User mode • Some processors may have more than one mode • Supervisor mode (privileged, protected) • Can execute all machine instructions • Can reference all memory locations • User mode • Can only execute a subset of instructions • Can only reference a subset of memory locations
… fork(); … Trap Table Kernel fork() { … trap N_SYS_FORK() … } sys_fork() sys_fork() { /* system function */ … return; } Chapter 3: Trap Instruction
Chapter 3: How to Make a System Call • For the system • through a trap instruction which causes an interrupt • Hardware saves PC and current status information • Hardware changes mode to system mode • Hardware loads PC from system call interrupt vector location. • Execute the system call interrupt handler • return from the handler, restores PC and other saved status information • User process continues.
send(…, A, …); receive(…, B, …); send/receive receive(…A, …); … send(…, B, …); Chapter 3: Message Passing
Chapter 4: Device Management • Abstract all devices (and files) to a few interfaces • Device management strategies • Direct I/O with polling • Direct I/O with interrupts • DMA I/O with interrupts • How to use the above strategies to perform I/O? • Buffering & Spooling • Access time of disk device* • FCFS, SSTF, Scan/Look, Circular Scan/Look • See examples in Exercise (2)
Application Process System Interface File Manager Device-Independent Device-Dependent Hardware Interface Command Status Data Device Controller Chapter 4: Device Management Organization
Chapter 5: Implementing Processes,Threads, and Resources • Modern process • Address space • Context switching • State diagram
Chapter 5: Classic Processes • New abstraction divides aspects of classic process into two parts • Modern process: the part that defines a customized computational framework in which a program executes • Thread: the part that keeps track of code executions within this framework • Classic process = modern process with 1 thread
Executable Memory Address Space Address Binding Process Files Other objects Chapter 5: The Address Space
Chapter 5: Modern Process Composed of: • Address space • Program to define behavior of process • Data used by process • Resources needed for thread execution • Process created with a minimal set of resources • Additional resources allocated as needed
Old Thread Descriptor CPU New Thread Descriptor Chapter 5: Context Switching
Request Done Running Request Schedule Start Allocate Ready Blocked Chapter 5: Simple State Diagram
Process Process Process Chapter 5: A Generic Resource Manager Resource Manager Blocked Processes Policy request() Process release() Resource Pool
Good Luck! Q/A