CSCICMPE 4334 Operating Systems Review Exam 1 1

  • Slides: 41
Download presentation
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1

CSCI/CMPE 4334 Operating Systems Review: Exam 1 1

Review • • Chapters 1 ~ 6 in your textbook Lecture slides In-class exercises

Review • • Chapters 1 ~ 6 in your textbook Lecture slides In-class exercises (on the course website) Review slides 2

Review • 5 questions (100 points) + 1 bonus question (20 points) • Question

Review • 5 questions (100 points) + 1 bonus question (20 points) • Question types – Q/A 3

Time & Place & Event • 9: 25 am ~ 10: 40 am, Feb.

Time & Place & Event • 9: 25 am ~ 10: 40 am, Feb. 18, Thursday • ENGR 1. 272 • Closed-book exam 4

Chapter 1: Introduction and Overview of Operating Systems • Computer system – Hardware –

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 5

Chapter 1: Software Classification Application Programmer System Software API Command Line Interpreter Compiler Loader

Chapter 1: Software Classification Application Programmer System Software API Command Line Interpreter Compiler Loader Libraries Database Management System Window System OS Hardware 6

Chapter 1: Purpose of an OS (What is Resource Management? ) • “An OS

Chapter 1: Purpose of an OS (What is Resource Management? ) • “An OS creates resource abstractions” • “An OS manages resource sharing” 7

Chapter 1: Operating System Functions • Resource manager – manage hardware and software resources

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 8

Chapter 1: Abstract Resources User Interface Application Abstract Resources (API) Middleware OS Resources (OS

Chapter 1: Abstract Resources User Interface Application Abstract Resources (API) Middleware OS Resources (OS Interface) OS Hardware Resources 9

Chapter 1: Resource Management Functions • Transform physical resources to logical resources – Resource

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 10

Chapter 1: Resource Sharing • Two types of sharing – Time multiplexed sharing •

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 11

Chapter 1: Operating Systems Strategies • Several different strategies have been used – Earliest

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 a few other recent strategies • • Personal computers and workstations Embedded systems Small, communicating computers Network technology 12

Chapter 2: Using the Operating System • Operating systems provide a virtual computing environment

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 13

Chapter 2: Using the Operating System (cont'd) • Process – an infrastructure in which

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 14

Chapter 2: Using the Operating System (cont'd) • UNIX fork() creates a process –

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 Create. Process() and Create. Thread() • Examples of using functions above (see lecture slides) 15

Chapter 2: Processes vs. Threads • Benefits of multithreading – Improve application responsiveness •

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 16

Chapter 2: Algorithms, Programs, and Processes Idea Execution Engine Algorithm Source Program Status Stack

Chapter 2: Algorithms, Programs, and Processes Idea Execution Engine Algorithm Source Program Status Stack Binary Program Data Files Other Resources Process 17

Chapter 2: Process Abstraction Stack Data Process Program Operating System Hardware Processor Executable Memory

Chapter 2: Process Abstraction Stack Data Process Program Operating System Hardware Processor Executable Memory 18

Chapter 2: A Process with Multiple Threads Thread (Execution Engine) Status Stack Files Data

Chapter 2: A Process with Multiple Threads Thread (Execution Engine) Status Stack Files Data Binary Program Other Resources Process 19

Chapter 2: The File Abstraction Data Stack File Process Program Operating System Hardware File

Chapter 2: The File Abstraction Data Stack File Process Program Operating System Hardware File Descriptor Processor Executable Memory Storage Device 20

Chapter 3: OS Organization • Basic OS Responsibilities • Basic OS Functions • Three

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? 21

Chapter 3: Basic OS Organization File Manager Process, Thread & Resource Manager Processor(s) Memory

Chapter 3: Basic OS Organization File Manager Process, Thread & Resource Manager Processor(s) Memory Manager Device Manager Main Memory Devices 22

Chapter 3: Device Management • OS uses policies chosen by designer or system administrator

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 23

Chapter 3: Process Management Process Mgr Deadlock Scheduler Protection Process Description Synchronization Resource Manager

Chapter 3: Process Management Process Mgr Deadlock Scheduler Protection Process Description Synchronization Resource Manager CPU Other H/W 24

Chapter 3: Memory Management Isolation & Sharing Process Manager Block Allocation Primary Memory Virtual

Chapter 3: Memory Management Isolation & Sharing Process Manager Block Allocation Primary Memory Virtual Memory Storage Devices 25

Chapter 3: File System Management 26

Chapter 3: File System Management 26

Chapter 3: Processor Modes • Mode bit: Supervisor or User mode – Some processors

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 27

Chapter 3: Trap Instruction … fork(); … fork() { … trap N_SYS_FORK() … }

Chapter 3: Trap Instruction … fork(); … fork() { … trap N_SYS_FORK() … } Trap Table Kernel sys_fork() { /* system function */ … return; } 28

Chapter 3: How to Make a System Call • For the system – through

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. 29

Chapter 3: Message Passing send(…, A, …); receive(…, B, …); send/receive(…A, …); … send(…,

Chapter 3: Message Passing send(…, A, …); receive(…, B, …); send/receive(…A, …); … send(…, B, …); 30

Chapter 4: Device Management • Abstract all devices (and files) to a few interfaces

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) 31

Chapter 4: Device Management Organization Application Process System Interface File Manager Device-Independent Device-Dependent Hardware

Chapter 4: Device Management Organization Application Process System Interface File Manager Device-Independent Device-Dependent Hardware Interface Command Status Data Device Controller 32

Chapter 4: Direct-Memory Access 33

Chapter 4: Direct-Memory Access 33

Chapter 5: Implementing Processes, Threads, and Resources • • Modern process Address space Context

Chapter 5: Implementing Processes, Threads, and Resources • • Modern process Address space Context switching State diagram 34

Chapter 5: Classic Processes • New abstraction divides aspects of classic process into two

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 35

Chapter 5: The Address Space Address Binding Executable Memory Process Files Other objects 36

Chapter 5: The Address Space Address Binding Executable Memory Process Files Other objects 36

Chapter 5: Modern Process Composed of: • Address space • Program to define behavior

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 37

Chapter 5: Context Switching Old Thread Descriptor CPU New Thread Descriptor 38

Chapter 5: Context Switching Old Thread Descriptor CPU New Thread Descriptor 38

Chapter 5: Simple State Diagram Request Done Running Request Schedule Start Allocate Blocked Ready

Chapter 5: Simple State Diagram Request Done Running Request Schedule Start Allocate Blocked Ready 39

Chapter 5: A Generic Resource Manager Blocked Processes Policy Process request() release() Resource Pool

Chapter 5: A Generic Resource Manager Blocked Processes Policy Process request() release() Resource Pool 40

Good Luck! Q/A 41

Good Luck! Q/A 41