Review Yi Shi Fall Xi an Jiaotong University

Size: px
Start display at page:

Download "Review Yi Shi Fall Xi an Jiaotong University"

Transcription

1 Review Yi Shi Fall 2017 Xi an Jiaotong University

2 Operating System: Definition Definition An Operating System (OS) provides a virtual machine on top of the real hardware, whose interface is more convenient than the raw hardware interface. Applications OS interface Operating System Hardware Physical machine interface Advantages Easy to use, simpler to code, more reliable, more secure, You can say: I want to write XYZ into file ABC 2

3 Crossing Protection Boundaries User calls OS procedure for privileged operations Calling a kernel mode service from user mode program: Using System Calls System Calls switches execution to kernel mode User process System Call User Mode Mode bit = 1 Resume process Trap Mode bit = 0 Kernel Mode Mode bit = 0 Return Mode bit = 1 Save Caller s state Execute system call Restore state 3

4 What is a process? The unit of execution The unit of scheduling Thread of execution + address space Is a program in execution Sequential, instruction-at-a-time execution of a program. The same as job or task or sequential process 4

5 Process State Transitions interrupt New Ready dispatch Running Exit Waiting Processes hop across states as a result of: Actions they perform, e.g. system calls Actions performed by OS, e.g. rescheduling External actions, e.g. I/O 5

6 Context Switch For a running process All registers are loaded in CPU and modified E.g. Program Counter, Stack Pointer, General Purpose Registers When process relinquishes the CPU, the OS Saves register values to the PCB of that process To execute another process, the OS Loads register values from PCB of that process Context Switch Process of switching CPU from one process to another Very machine dependent for types of registers 6

7 Threads and Processes Most operating systems therefore support two entities: the process, which defines the address space and general process attributes the thread, which defines a sequential execution stream within a process A thread is bound to a single process. For each process, however, there may be many threads. Threads are the unit of scheduling Processes are containers in which threads execute 7

8 IPC Independent vs Cooperating processes Why let processes cooperate? Information sharing Computation speedup Modularity Convenience: a user may work on many tasks Cooperating processes need IPC Two fundamental models Message Passing: easier, smaller amounts of data, slower Shared Memory: harder, large amounts of data, maximum speed

9 Schedulers Process migrates among several queues Device queue, job queue, ready queue Scheduler selects a process to run from these queues Long-term scheduler: load a job in memory Runs infrequently Short-term scheduler: Select ready process to run on CPU Should be fast Middle-term scheduler Reduce multiprogramming or memory consumption 9

10 CPU Scheduling Algorithms FCFS SJF Priority Scheduling Round Robin Multi-level Queue Multi-level Feedback Queue 10

11 CPU Scheduling Metrics CPU utilization: percentage of time the CPU is not idle Throughput: completed processes per time unit Turnaround time: submission to completion Waiting time: time spent on the ready queue Response time: response latency 11

12 Race conditions Definition: timing dependent error involving shared state Whether it happens depends on how threads scheduled Hard to detect: All possible schedules have to be safe Number of possible schedule permutations is huge Some bad schedules? Some that will work sometimes? they are intermittent Timing dependent = small changes can hide bug

13 The Fundamental Issue: Atomicity Our atomic operation is not done atomically by machine E.g. incrementing a variable by one (i++) is three machine instructions (load, increment, store). Process can be interrupted between any machine instruction Atomic Unit: instruction sequence guaranteed to execute indivisibly Also called critical section (CS) When 2 processes want to execute their Critical Section, One process finishes its CS before other is allowed to enter 13

14 Critical Section Problem Problem: Design a protocol for processes to cooperate, such that only one process is in its critical section How to make multiple instructions seem like one? Process 1 CS 1 Process 2 CS 2 Time Processes progress with non-zero speed, no assumption on clock speed Used extensively in operating systems: Queues, shared variables, interrupt handlers, etc. 14

15 Shared vars: Initialization: Process: Solution Structure Entry Section Critical Section Added to solve the CS problem Exit Section 15

16 Solution Requirements Mutual Exclusion Only one process can be in the critical section at any time Progress Decision on who enters CS cannot be indefinitely postponed No deadlock Bounded Waiting Bound on #times others can enter CS, while I am waiting No livelock Also efficient (no extra resources), fair, simple, 16

17 Semaphores Non-negative integer with atomic increment and decrement Integer S that (besides init) can only be modified by: P(S) or S.wait(): decrement or block if already 0 V(S) or S.signal(): increment and wake up process if any These operations are atomic semaphore S; P(S) { while(s 0) ; S--; } V(S) { S++; } 17

18 Semaphore Types Counting Semaphores: Any integer Used for synchronization Binary Semaphores Value 0 or 1 Used for mutual exclusion (mutex) Process i Shared: semaphore S Init: S = 1; P(S); Critical Section V(S); 18

19 Mutexes and Synchronization semaphore S; Init: S = 0; 1; Deadlock P(S) { while(s 0) ; S--; } V(S) { S++; } Process i P(S); Code XYZ V(S); Process j P(S); Code ABC V(S); 19

20 Deadlocks Definition: Deadlock exists among a set of processes if Every process is waiting for an event This event can be caused only by another process in the set Event is the acquire of release of another resource One-lane bridge 20

21 Four Conditions for Deadlock Coffman et. al Necessary conditions for deadlock to exist: Mutual Exclusion At least one resource must be held is in non-sharable mode Hold and wait There exists a process holding a resource, and waiting for another No preemption Resources cannot be preempted Circular wait There exists a set of processes {P 1, P 2, P N }, such that P 1 is waiting for P 2, P 2 for P 3,. and P N for P 1 All four conditions must hold for deadlock to occur 21

22 Dealing with Deadlocks Proactive Approaches: Deadlock Prevention Negate one of 4 necessary conditions Prevent deadlock from occurring Deadlock Avoidance Carefully allocate resources based on future knowledge Deadlocks are prevented Reactive Approach: Deadlock detection and recovery Let deadlock happen, then detect and recover from it Ignore the problem Pretend deadlocks will never occur Ostrich approach 22

23 Safe State A state is said to be safe, if it has a process sequence {P 1, P 2,, P n }, such that for each P i, the resources that P i can still request can be satisfied by the currently available resources plus the resources held by all P j, where j < i State is safe because OS can definitely avoid deadlock by blocking any new requests until safe order is executed This avoids circular wait condition Process waits until safe state is guaranteed 23

24 Banker s Algorithm Decides whether to grant a resource request. Data structures: n: integer # of processes m: integer # of resources available[1..m] available[i] is # of avail resources of type i max[1..n,1..m] max demand of each Pi for each Ri allocation[1..n,1..m] current allocation of resource Rj to Pi need[1..n,1..m] max # resource Rj that Pi may still request let request[i] be vector of # of resource Rj Process Pi wants 24

25 Basic Algorithm 1. If request[i] > need[i] then error (asked for too much) 2. If request[i] > available then wait (can t supply it now) 3. Resources are available to satisfy the request Let s assume that we satisfy the request. Then we would have: available = available - request[i] allocation[i] = allocation [i] + request[i] need[i] = need [i] - request [i] Now, check if this would leave us in a safe state: if yes, grant the request, if no, then leave the state as is and cause process to wait. 25

26 Memory Management Issues Protection: Errors in process should not affect others Transparency: Should run despite memory size/location gcc Load Store CPU Translation box (MMU) virtual address data fault legal addr? Illegal? Physical address Physical memory How to do this mapping? 26

27 Scheme 1: Load-time Linking Link as usual, but keep list of references At load time: determine the new base address Accordingly adjust all references (addition) static a.out 0x3000 OS 0x6000 jump 0x2000 0x1000 jump 0x5000 0x4000 Issues: unused routine is linked and loaded, moving in memory 27

28 Scheme 2: Execution-time Linking Use hardware (base + limit reg) to solve the problem Done for every memory access Relocation: physical address = logical (virtual) address + base Protection: is virtual address < limit? a.out jump 0x2000 0x3000 0x1000 MMU Base: 0x3000 Limit: 0x2000 OS a.out jump 0x2000 0x6000 0x4000 When process runs, base register = 0x3000, bounds register = 0x2000. Jump addr = 0x x3000 = 0x

29 Segmentation Processes have multiple base + limit registers Processes address space has multiple segments Each segment has its own base + limit registers Add protection bits to every segment 0x1000 0x3000 gcc Text seg r/o Real memory 0x2000 0x5000 0x6000 Stack seg r/w Base&Limit? 0x8000 0x6000 How to do the mapping? 29

30 Mapping Segments Segment Table An entry for each segment Is a tuple <base, limit, protection> Each memory reference indicates segment and offset fault Virtual addr no 3 128? yes Seg# offset Seg table Prot base len + 0x1000 seg mem 128 r 0x

31 Fragmentation The inability to use free memory External Fragmentation: Variable sized pieces many small holes over time Internal Fragmentation: Fixed sized pieces internal waste if entire piece is not used Word?? gcc emacs External fragmentation allocated stack doom Unused ( internal fragmentation ) 31

32 Paging Divide memory into fixed size pieces Called frames or pages Pros: easy, no external fragmentation Pages typical: 4k-8k gcc emacs internal frag 32

33 Mapping Pages If 2 m virtual address space, 2 n page size (m - n) bits to denote page number, n for offset within page Translation done using a Page Table Virtual addr (12bits) ((1<<12) 128) 0x1000 mem VPN page offsetpage table Prot VPN PPN? PPN seg 128 invalid r

34 Paging Hardware With TLB 页表寄存器 页表始址页表长度 页号 块号 页表 越界中断 > = 输入寄存逻辑地址寄存器 页号 页内地址 快表 块号 块内地址 物理地址寄存器

35 Paging + Segmentation Paged segmentation Handles very long segments The segments are paged Segmented Paging When the page table is very big Segment the page table Let s consider System 370 (24-bit address space) Seg #page # (8 bits) (4 bits) page offset (12 bits) 35

36 What is virtual memory? Each process has illusion of large address space 2 32 for 32-bit addressing However, physical memory is much smaller How do we give this illusion to multiple processes? Virtual Memory: some addresses reside in disk page table disk Physical memory 36

37 Virtual Memory Load entire process in memory (swapping), run it, exit Is slow (for big processes) Wasteful (might not require everything) Solutions: partial residency Paging: only bring in pages, not all pages of process Demand paging: bring only pages that are required Where to fetch page from? Have a contiguous space in disk: swap file (pagefile.sys) 37

38 Page Faults On a page fault: OS finds a free frame, or evicts one from memory (which one?) Want knowledge of the future? Issues disk request to fetch data for page (what to fetch?) Just the requested page, or more? Block current process, context switch to new process (how?) Process might be executing an instruction When disk completes, set present bit to 1, and current process in ready queue 38

39 Page Replacement Algorithms Random: Pick any page to eject at random Used mainly for comparison FIFO: The page brought in earliest is evicted Ignores usage Suffers from Belady s Anomaly Fault rate could increase on increasing number of pages E.g with frame sizes 3 and 4 OPT: Belady s algorithm Select page not used for longest time LRU: Evict page that hasn t been used the longest Past could be a good predictor of the future 39

40 Thrashing Processes in system require more memory than is there Keep throwing out page that will be referenced soon So, they keep accessing memory that is not there Why does it occur? No good reuse, past!= future There is reuse, but process does not fit Too many processes in the system 40

41 File System File System: Layer of OS that transforms block interface of disks (or other block devices) into Files, Directories, etc. File System Components Disk Management: collecting disk blocks into files Naming: Interface to find files by name, not by blocks Protection: Layers to keep data secure Reliability/Durability: Keeping of files durable despite crashes, media failures, attacks, etc User vs. System View of a File User s view: Durable Data Structures System s view (system call interface): Collection of Bytes (UNIX) 41

42 File Operations File is an Abstract Data Type Some basic file operations: Create: find space in FS, add directory entry Write (e.g. write at current position) Read/write pointer can be stored as per-process file pointer Increase the size attribute Read (e.g. read from current position, store in buffer) Seek: move current position somewhere in a file Delete: Remove file from directory entry, mark 42

43 Implementing Files Contiguous Allocation: allocate files contiguously on disk 43

44 Linked List Allocation Each file is stored as linked list of blocks First word of each block points to next block Rest of disk block is file data 44

45 Using an in-memory table Implement a linked list allocation using a table Called File Allocation Table (FAT) Take pointer away from blocks, store in this table 45

46 I-nodes Index-node (I-node) is a per-file data structure Lists attributes and disk addresses of file s blocks Pros: Space (max open files * size per I-node) Cons: what if file expands beyond I-node address space? 46

47 Implementing Directories When a file is opened, OS uses path name to find dir Directory has information about the file s disk blocks Whole file (contiguous), first block (linked-list) or I-node Directory also has attributes of each file Directory: map ASCII file name to file attributes & location 2 options: entries have all attributes, or point to file I-node 47

48 Implementing Directories What if files have large, variable-length names? Solution: Limit file name length, say 255 chars, and use previous scheme Pros: Simple Cons: wastes space Directory entry comprises fixed and variable portion Fixed part starts with entry size, followed by attributes Variable part has the file name Pros: saves space Cons: holes on removal, page fault on file read, word boundaries Directory entries are fixed in length, pointer to file name in heap Pros: easy removal, no space wasted for word boundaries Cons: manage heap, page faults on file names 48

49 Managing Free Disk Space 2 approaches to keep track of free disk blocks Linked list and bitmap approach 49

50 Disk overheads To read from disk, we must specify: cylinder #, surface #, sector #, transfer size, memory address Transfer time includes: Seek time: to get to the track Latency time: to get to the sector and Transfer time: get bits off the disk Track Sector Seek Time Rotation Delay 50

51 Disk Scheduling FCFS SSTF SCAN C-SCAN LOOK C-LOOK 51

52 RAID Levels 0: Striping 1: Mirroring 2: Hamming Codes 3: Parity Bit 4: Block Striping 5: Spread parity blocks across all disks 0+1 and

53 That s it! Good luck and have a good break! 53

How to create a process? What does process look like?

How to create a process? What does process look like? How to create a process? On Unix systems, executable read by loader Compile time runtime Ken Birman ld loader Cache Compiler: generates one object file per source file Linker: combines all object files

More information

Main Memory Yi Shi Fall 2017 Xi an Jiaotong University

Main Memory Yi Shi Fall 2017 Xi an Jiaotong University Main Memory Yi Shi Fall 2017 Xi an Jiaotong University Goals Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Background Program must be brought (from disk)

More information

SHANDONG UNIVERSITY 1

SHANDONG UNIVERSITY 1 Chapter 8 Main Memory SHANDONG UNIVERSITY 1 Contents Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium SHANDONG UNIVERSITY 2 Objectives

More information

Main Points of the Computer Organization and System Software Module

Main Points of the Computer Organization and System Software Module Main Points of the Computer Organization and System Software Module You can find below the topics we have covered during the COSS module. Reading the relevant parts of the textbooks is essential for a

More information

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions:

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions: Techno India Batanagar Department of Computer Science & Engineering Model Questions Subject Name: Operating System Multiple Choice Questions: Subject Code: CS603 1) Shell is the exclusive feature of a)

More information

Design of Operating System

Design of Operating System Design of Operating System Architecture OS protection, modes/privileges User Mode, Kernel Mode https://blog.codinghorror.com/understanding-user-and-kernel-mode/ a register of flag to record what mode the

More information

System Model. Deadlocks. Deadlocks. For example: Semaphores. Four Conditions for Deadlock. Resource Allocation Graph

System Model. Deadlocks. Deadlocks. For example: Semaphores. Four Conditions for Deadlock. Resource Allocation Graph System Model Deadlocks There are non-shared computer resources Maybe more than one instance Printers, Semaphores, Tape drives, CPU Processes need access to these resources Acquire resource If resource

More information

CSI3131 Final Exam Review

CSI3131 Final Exam Review CSI3131 Final Exam Review Final Exam: When: April 24, 2015 2:00 PM Where: SMD 425 File Systems I/O Hard Drive Virtual Memory Swap Memory Storage and I/O Introduction CSI3131 Topics Process Computing Systems

More information

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006 Operating Systems Comprehensive Exam Spring 2006 Student ID # 3/16/2006 You must complete all of part I (60%) You must complete two of the three sections in part II (20% each) In Part I, circle or select

More information

Fall COMP3511 Review

Fall COMP3511 Review Outline Fall 2015 - COMP3511 Review Monitor Deadlock and Banker Algorithm Paging and Segmentation Page Replacement Algorithms and Working-set Model File Allocation Disk Scheduling Review.2 Monitors Condition

More information

UNIT:2. Process Management

UNIT:2. Process Management 1 UNIT:2 Process Management SYLLABUS 2.1 Process and Process management i. Process model overview ii. Programmers view of process iii. Process states 2.2 Process and Processor Scheduling i Scheduling Criteria

More information

MC7204 OPERATING SYSTEMS

MC7204 OPERATING SYSTEMS MC7204 OPERATING SYSTEMS QUESTION BANK UNIT I INTRODUCTION 9 Introduction Types of operating systems operating systems structures Systems components operating systems services System calls Systems programs

More information

COMP 3361: Operating Systems 1 Final Exam Winter 2009

COMP 3361: Operating Systems 1 Final Exam Winter 2009 COMP 3361: Operating Systems 1 Final Exam Winter 2009 Name: Instructions This is an open book exam. The exam is worth 100 points, and each question indicates how many points it is worth. Read the exam

More information

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU BCA-3 rd Semester 030010304-Fundamentals Of Operating Systems Unit: 1 Introduction Short Answer Questions : 1. State two ways of process communication. 2. State any two uses of operating system according

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 L20 Virtual Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 Questions from last time Page

More information

2 nd Half. Memory management Disk management Network and Security Virtual machine

2 nd Half. Memory management Disk management Network and Security Virtual machine Final Review 1 2 nd Half Memory management Disk management Network and Security Virtual machine 2 Abstraction Virtual Memory (VM) 4GB (32bit) linear address space for each process Reality 1GB of actual

More information

Deadlocks: Part I Prevention and Avoidance Yi Shi Fall 2017 Xi an Jiaotong University

Deadlocks: Part I Prevention and Avoidance Yi Shi Fall 2017 Xi an Jiaotong University Deadlocks: Part I Prevention and Avoidance Yi Shi Fall 2017 Xi an Jiaotong University Review: Motivation for Monitors and Condition Variables Semaphores are a huge step up, but: They are confusing because

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory Chapter 9: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 23 Virtual memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Is a page replaces when

More information

Exam Guide COMPSCI 386

Exam Guide COMPSCI 386 FOUNDATIONS We discussed in broad terms the three primary responsibilities of an operating system. Describe each. What is a process? What is a thread? What parts of a process are shared by threads? What

More information

Unit-03 Deadlock and Memory Management Unit-03/Lecture-01

Unit-03 Deadlock and Memory Management Unit-03/Lecture-01 1 Unit-03 Deadlock and Memory Management Unit-03/Lecture-01 The Deadlock Problem 1. A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.

More information

Address spaces and memory management

Address spaces and memory management Address spaces and memory management Review of processes Process = one or more threads in an address space Thread = stream of executing instructions Address space = memory space used by threads Address

More information

Operating Systems CMPSC 473 Midterm 2 Review April 15, Lecture 21 Instructor: Trent Jaeger

Operating Systems CMPSC 473 Midterm 2 Review April 15, Lecture 21 Instructor: Trent Jaeger Operating Systems CMPSC 473 Midterm Review April 15, 8 - Lecture 1 Instructor: Trent Jaeger Scope Chapter 6 -- Synchronization Chapter 7 -- Deadlocks Chapter 8 -- Main Memory (Physical) Chapter 9 -- Virtual

More information

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses. 1 Memory Management Address Binding The normal procedures is to select one of the processes in the input queue and to load that process into memory. As the process executed, it accesses instructions and

More information

Operating System Concepts

Operating System Concepts Chapter 9: Virtual-Memory Management 9.1 Silberschatz, Galvin and Gagne 2005 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped

More information

Following are a few basic questions that cover the essentials of OS:

Following are a few basic questions that cover the essentials of OS: Operating Systems Following are a few basic questions that cover the essentials of OS: 1. Explain the concept of Reentrancy. It is a useful, memory-saving technique for multiprogrammed timesharing systems.

More information

ESE 333 Real-Time Operating Systems 163 Review Deadlocks (Cont.) ffl Methods for handling deadlocks 3. Deadlock prevention Negating one of four condit

ESE 333 Real-Time Operating Systems 163 Review Deadlocks (Cont.) ffl Methods for handling deadlocks 3. Deadlock prevention Negating one of four condit Review Deadlocks ffl Non-sharable resources ffl Necessary conditions for a deadlock to occur 1. Mutual exclusion 2. Hold and wait 3. No preemption 4. Circular wait ffl Resource graph ffl Use resource graph

More information

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013 Operating Systems Comprehensive Exam Spring 2013 Student ID # 3/20/2013 You must complete all of Section I You must complete two of the problems in Section II If you need more space to answer a question,

More information

CS6401- OPERATING SYSTEM

CS6401- OPERATING SYSTEM 1. What is an Operating system? CS6401- OPERATING SYSTEM QUESTION BANK UNIT-I An operating system is a program that manages the computer hardware. It also provides a basis for application programs and

More information

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization Requirements Relocation Memory management ability to change process image position Protection ability to avoid unwanted memory accesses Sharing ability to share memory portions among processes Logical

More information

Virtual Memory Outline

Virtual Memory Outline Virtual Memory Outline Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations Operating-System Examples

More information

Indian Institute of Technology, Kharagpur

Indian Institute of Technology, Kharagpur 1 Indian Institute of Technology, Kharagpur End-Spring Semester 2017-18 Date of Examination: 24-04-2018 Session: AN (2-5 pm) Duration: 3 hrs Subject No.: CS31702 Subject: COMPUTER ARCHITECTURE AND OPERATING

More information

CS450/550 Operating Systems

CS450/550 Operating Systems CS450/550 Operating Systems Lecture 4 memory Palden Lama Department of Computer Science CS450/550 Memory.1 Review: Summary of Chapter 3 Deadlocks and its modeling Deadlock detection Deadlock recovery Deadlock

More information

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011 Operating Systems Comprehensive Exam Spring 2011 Student ID # 2/17/2011 You must complete all of Section I You must complete two of the problems in Section II If you need more space to answer a question,

More information

Simple idea 1: load-time linking. Our main questions. Some terminology. Simple idea 2: base + bound register. Protection mechanics.

Simple idea 1: load-time linking. Our main questions. Some terminology. Simple idea 2: base + bound register. Protection mechanics. Our main questions! How is protection enforced?! How are processes relocated?! How is ory partitioned? Simple idea 1: load-time linking! Link as usual, but keep the list of references! At load time, determine

More information

Final Exam Preparation Questions

Final Exam Preparation Questions EECS 678 Spring 2013 Final Exam Preparation Questions 1 Chapter 6 1. What is a critical section? What are the three conditions to be ensured by any solution to the critical section problem? 2. The following

More information

QUESTION BANK UNIT I

QUESTION BANK UNIT I QUESTION BANK Subject Name: Operating Systems UNIT I 1) Differentiate between tightly coupled systems and loosely coupled systems. 2) Define OS 3) What are the differences between Batch OS and Multiprogramming?

More information

MEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019

MEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019 MEMORY: SWAPPING Shivaram Venkataraman CS 537, Spring 2019 ADMINISTRIVIA - Project 2b is out. Due Feb 27 th, 11:59 - Project 1b grades are out Lessons from p2a? 1. Start early! 2. Sketch out a design?

More information

OPERATING SYSTEM. Chapter 9: Virtual Memory

OPERATING SYSTEM. Chapter 9: Virtual Memory OPERATING SYSTEM Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory

More information

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition Chapter 9: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating

More information

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008. CSC 4103 - Operating Systems Spring 2008 Lecture - XII Midterm Review Tevfik Ko!ar Louisiana State University March 4 th, 2008 1 I/O Structure After I/O starts, control returns to user program only upon

More information

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1 Memory Allocation Copyright : University of Illinois CS 241 Staff 1 Recap: Virtual Addresses A virtual address is a memory address that a process uses to access its own memory Virtual address actual physical

More information

Chapter 8: Virtual Memory. Operating System Concepts

Chapter 8: Virtual Memory. Operating System Concepts Chapter 8: Virtual Memory Silberschatz, Galvin and Gagne 2009 Chapter 8: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating

More information

Contents. Chapter 8 Deadlocks

Contents. Chapter 8 Deadlocks Contents * All rights reserved, Tei-Wei Kuo, National Taiwan University,.. Introduction. Computer-System Structures. Operating-System Structures 4. Processes 5. Threads 6. CPU Scheduling 7. Process Synchronization

More information

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition Chapter 8: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 8: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating

More information

Basic Memory Management

Basic Memory Management Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester 10/15/14 CSC 2/456 1 Basic Memory Management Program must be brought into memory and placed within a process for it

More information

Past: Making physical memory pretty

Past: Making physical memory pretty Past: Making physical memory pretty Physical memory: no protection limited size almost forces contiguous allocation sharing visible to program easy to share data gcc gcc emacs Virtual memory each program

More information

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT I

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT I DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year and Semester : II / IV Subject Code : CS6401 Subject Name : Operating System Degree and Branch : B.E CSE UNIT I 1. Define system process 2. What is an

More information

Chapter 9: Virtual-Memory

Chapter 9: Virtual-Memory Chapter 9: Virtual-Memory Management Chapter 9: Virtual-Memory Management Background Demand Paging Page Replacement Allocation of Frames Thrashing Other Considerations Silberschatz, Galvin and Gagne 2013

More information

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Operating System Third Year CSE( Sem:I) 2 marks Questions and Answers UNIT I

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Operating System Third Year CSE( Sem:I) 2 marks Questions and Answers UNIT I DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Operating System Third Year CSE( Sem:I) 2 marks Questions and Answers UNIT I 1. What is an Operating system? An operating system is a program that manages

More information

Course Description: This course includes the basic concepts of operating system

Course Description: This course includes the basic concepts of operating system Operating Systems Course Title: Operating Systems Full Marks:60+ 20+20 Course No: CSC259 Pass Marks: 24+8+8 Nature of the Course: Theory + Lab Credit Hrs: 3 Course Description: This course includes the

More information

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access) Virtual Memory - programmer views memory as large address space without concerns about the amount of physical memory or memory management. (What do the terms 3-bit (or 6-bit) operating system or overlays

More information

Chapters 9 & 10: Memory Management and Virtual Memory

Chapters 9 & 10: Memory Management and Virtual Memory Chapters 9 & 10: Memory Management and Virtual Memory Important concepts (for final, projects, papers) addressing: physical/absolute, logical/relative/virtual overlays swapping and paging memory protection

More information

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time Memory Management To provide a detailed description of various ways of organizing memory hardware To discuss various memory-management techniques, including paging and segmentation To provide a detailed

More information

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018 CSE 4/521 Introduction to Operating Systems Lecture 27 (Final Exam Review) Summer 2018 Overview Objective: Revise topics and questions for the final-exam. 1. Main Memory 2. Virtual Memory 3. Mass Storage

More information

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013 Operating Systems Comprehensive Exam Fall 2013 Student ID # 10/31/2013 You must complete all of Section I You must complete two of the problems in Section II If you need more space to answer a question,

More information

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

Operating Systems. Memory Management. Lecture 9 Michael O Boyle Operating Systems Memory Management Lecture 9 Michael O Boyle 1 Memory Management Background Logical/Virtual Address Space vs Physical Address Space Swapping Contiguous Memory Allocation Segmentation Goals

More information

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Chapter 8 & Chapter 9 Main Memory & Virtual Memory Chapter 8 & Chapter 9 Main Memory & Virtual Memory 1. Various ways of organizing memory hardware. 2. Memory-management techniques: 1. Paging 2. Segmentation. Introduction Memory consists of a large array

More information

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem? What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular

More information

CLASS: II YEAR / IV SEMESTER CSE SUBJECT CODE AND NAME: CS6401 OPERATING SYSTEMS UNIT I OPERATING SYSTEMS OVERVIEW

CLASS: II YEAR / IV SEMESTER CSE SUBJECT CODE AND NAME: CS6401 OPERATING SYSTEMS UNIT I OPERATING SYSTEMS OVERVIEW CLASS: II YEAR / IV SEMESTER CSE SUBJECT CODE AND NAME: CS6401 OPERATING SYSTEMS SYLLABUS UNIT I OPERATING SYSTEMS OVERVIEW Computer System Overview-Basic Elements, Instruction Execution, Interrupts, Memory

More information

Last Class: Deadlocks. Where we are in the course

Last Class: Deadlocks. Where we are in the course Last Class: Deadlocks Necessary conditions for deadlock: Mutual exclusion Hold and wait No preemption Circular wait Ways of handling deadlock Deadlock detection and recovery Deadlock prevention Deadlock

More information

Architectural Support. Processes. OS Structure. Threads. Scheduling. CSE 451: Operating Systems Spring Module 28 Course Review

Architectural Support. Processes. OS Structure. Threads. Scheduling. CSE 451: Operating Systems Spring Module 28 Course Review Architectural Support CSE 451: Operating Systems Spring 2012 Module 28 Course Review Ed Lazowska lazowska@cs.washington.edu Allen Center 570 Privileged instructions what are they? how does the CPU know

More information

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5) Announcements Reading Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) 1 Relationship between Kernel mod and User Mode User Process Kernel System Calls User Process

More information

CHAPTER NO - 1 : Introduction:

CHAPTER NO - 1 : Introduction: Sr. No L.J. Institute of Engineering & Technology Semester: IV (26) Subject Name: Operating System Subject Code:21402 Faculties: Prof. Saurin Dave CHAPTER NO - 1 : Introduction: TOPIC:1 Basics of Operating

More information

CSc33200: Operating Systems, CS-CCNY, Fall 2003 Jinzhong Niu December 10, Review

CSc33200: Operating Systems, CS-CCNY, Fall 2003 Jinzhong Niu December 10, Review CSc33200: Operating Systems, CS-CCNY, Fall 2003 Jinzhong Niu December 10, 2003 Review 1 Overview 1.1 The definition, objectives and evolution of operating system An operating system exploits and manages

More information

Department of Computer applications. [Part I: Medium Answer Type Questions]

Department of Computer applications. [Part I: Medium Answer Type Questions] Department of Computer applications BBDNITM, Lucknow MCA 311: OPERATING SYSTEM [Part I: Medium Answer Type Questions] UNIT 1 Q1. What do you mean by an Operating System? What are the main functions of

More information

VIRTUAL MEMORY READING: CHAPTER 9

VIRTUAL MEMORY READING: CHAPTER 9 VIRTUAL MEMORY READING: CHAPTER 9 9 MEMORY HIERARCHY Core! Processor! Core! Caching! Main! Memory! (DRAM)!! Caching!! Secondary Storage (SSD)!!!! Secondary Storage (Disk)! L cache exclusive to a single

More information

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science Virtual Memory CSCI 315 Operating Systems Design Department of Computer Science Notice: The slides for this lecture have been largely based on those from an earlier edition of the course text Operating

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2016 Lecture 33 Virtual Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ How does the virtual

More information

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1 Basic Memory Management Program must be brought into memory and placed within a process for it to be run Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester Mono-programming

More information

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is. Chapter 4 Memory Management Ideally programmers want memory that is Memory Management large fast non volatile 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 L17 Main Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Was Great Dijkstra a magician?

More information

Memory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels

Memory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels Memory management, part 2: outline 1 Page Replacement Algorithms Page fault forces choice o which page must be removed to make room for incoming page? Modified page must first be saved o unmodified just

More information

CSE 421/521 - Operating Systems Fall Lecture - XXV. Final Review. University at Buffalo

CSE 421/521 - Operating Systems Fall Lecture - XXV. Final Review. University at Buffalo CSE 421/521 - Operating Systems Fall 2014 Lecture - XXV Final Review Tevfik Koşar University at Buffalo December 2nd, 2014 1 Final Exam December 4th, Thursday 11:00am - 12:20pm Room: 110 Knox Chapters

More information

CSE380 - Operating Systems. Communicating with Devices

CSE380 - Operating Systems. Communicating with Devices CSE380 - Operating Systems Notes for Lecture 15-11/4/04 Matt Blaze (some examples by Insup Lee) Communicating with Devices Modern architectures support convenient communication with devices memory mapped

More information

CSC 539: Operating Systems Structure and Design. Spring 2005

CSC 539: Operating Systems Structure and Design. Spring 2005 CSC 539: Operating Systems Structure and Design Spring 2005 Process deadlock deadlock prevention deadlock avoidance deadlock detection recovery from deadlock 1 Process deadlock in general, can partition

More information

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems Course Outline Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems 1 Today: Memory Management Terminology Uniprogramming Multiprogramming Contiguous

More information

Module 1. Introduction:

Module 1. Introduction: Module 1 Introduction: Operating system is the most fundamental of all the system programs. It is a layer of software on top of the hardware which constitutes the system and manages all parts of the system.

More information

Virtual Memory Design and Implementation

Virtual Memory Design and Implementation Virtual Memory Design and Implementation To do q Page replacement algorithms q Design and implementation issues q Next: Last on virtualization VMMs Loading pages When should the OS load pages? On demand

More information

Chapter 4 Memory Management. Memory Management

Chapter 4 Memory Management. Memory Management Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms 4.6 Design issues for paging systems 4.7

More information

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced? Chapter 10: Virtual Memory Questions? CSCI [4 6] 730 Operating Systems Virtual Memory!! What is virtual memory and when is it useful?!! What is demand paging?!! When should pages in memory be replaced?!!

More information

Chapter 4 Memory Management

Chapter 4 Memory Management Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms 4.6 Design issues for paging systems 4.7

More information

Memory management, part 2: outline

Memory management, part 2: outline Memory management, part 2: outline Page replacement algorithms Modeling PR algorithms o Working-set model and algorithms Virtual memory implementation issues 1 Page Replacement Algorithms Page fault forces

More information

Chapter 9: Virtual Memory. Operating System Concepts 9th Edition

Chapter 9: Virtual Memory. Operating System Concepts 9th Edition Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations

More information

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition Chapter 9: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating

More information

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management CSE 120 July 18, 2006 Day 5 Memory Instructor: Neil Rhodes Translation Lookaside Buffer (TLB) Implemented in Hardware Cache to map virtual page numbers to page frame Associative memory: HW looks up in

More information

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University CS 571 Operating Systems Midterm Review Angelos Stavrou, George Mason University Class Midterm: Grading 2 Grading Midterm: 25% Theory Part 60% (1h 30m) Programming Part 40% (1h) Theory Part (Closed Books):

More information

CSE 120 PRACTICE FINAL EXAM, WINTER 2013

CSE 120 PRACTICE FINAL EXAM, WINTER 2013 CSE 120 PRACTICE FINAL EXAM, WINTER 2013 For each question, select the best choice. In the space provided below each question, justify your choice by providing a succinct (one sentence) explanation. 1.

More information

CS 143A - Principles of Operating Systems

CS 143A - Principles of Operating Systems CS 143A - Principles of Operating Systems Operating Systems - Review of content from midterm to final Prof. Nalini Venkatasubramanian nalini@ics.uci.edu Deadlocks System Model Resource allocation graph,

More information

UNIT I PROCESSES AND THREADS

UNIT I PROCESSES AND THREADS 2 MARKS QUESTIONS AND ANSWERS 16 MARKS QUESTION BANK 1.What is an operating system? UNIT I PROCESSES AND THREADS An operating system is a program that manages the computer hardware. it act as an intermediate

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory Chapter 9: Virtual Memory Multiprogramming Memory Management so far 1. Dynamic Loading The main Program gets loaded into memory Routines are stored in Relocatable Load format on disk As main program (or

More information

SYED AMMAL ENGINEERING COLLEGE CS6401- OPERATING SYSTEM

SYED AMMAL ENGINEERING COLLEGE CS6401- OPERATING SYSTEM Part-A SYED AMMAL ENGINEERING COLLEGE 1. What is an Operating system? CS6401- OPERATING SYSTEM QUESTION BANK UNIT-I 2. List the services provided by an Operating System? 3. What is the Kernel? 4. What

More information

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time. Memory Management To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time. Basic CPUs and Physical Memory CPU cache Physical memory

More information

CS307: Operating Systems

CS307: Operating Systems CS307: Operating Systems Chentao Wu 吴晨涛 Associate Professor Dept. of Computer Science and Engineering Shanghai Jiao Tong University SEIEE Building 3-513 wuct@cs.sjtu.edu.cn Download Lectures ftp://public.sjtu.edu.cn

More information

Chapter 10: Virtual Memory

Chapter 10: Virtual Memory Chapter 10: Virtual Memory Chapter 10: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations

More information

CS 537 Fall 2017 Review Session

CS 537 Fall 2017 Review Session CS 537 Fall 2017 Review Session Deadlock Conditions for deadlock: Hold and wait No preemption Circular wait Mutual exclusion QUESTION: Fix code List_insert(struct list * head, struc node * node List_move(struct

More information

Chapter 8 Memory Management

Chapter 8 Memory Management Chapter 8 Memory Management Da-Wei Chang CSIE.NCKU Source: Abraham Silberschatz, Peter B. Galvin, and Greg Gagne, "Operating System Concepts", 9th Edition, Wiley. 1 Outline Background Swapping Contiguous

More information

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to: F2007/Unit5/1 UNIT 5 OBJECTIVES General Objectives: To understand the process management in operating system Specific Objectives: At the end of the unit you should be able to: define program, process and

More information

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo PAGE REPLACEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics What if the physical memory becomes full? Page replacement algorithms How to manage memory among competing processes? Advanced

More information

Week 2: Tiina Niklander

Week 2: Tiina Niklander Virtual memory Operations and policies Chapters 3.4. 3.6 Week 2: 17.9.2009 Tiina Niklander 1 Policies and methods Fetch policy (Noutopolitiikka) When to load page to memory? Placement policy (Sijoituspolitiikka

More information