MIDTERM REVIEW CSCC69 Winter 2016 Kanwar Gill. What is an OS? What are processes and threads? Process states? Diagram showing the state changes What data.

Slides:



Advertisements
Similar presentations
Virtual Memory: Page Replacement
Advertisements

CAS3SH3 Midterm Review. The midterm 50 min, Friday, Feb 27 th Materials through CPU scheduling closed book, closed note Types of questions: True & False,
Operating Systems Review.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Operating Systems ECE344 Ding Yuan Final Review Lecture 13: Final Review.
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
Virtual Memory Introduction to Operating Systems: Module 9.
CAS3SH3 Final Review. The Final Tue 28 th, 7pm, IWC3 closed book, closed note Non-comprehensive: memory management, storage & file system Types of questions:
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Operating Systems Review. Questions What are two functions of an OS? What “layer” is above the OS? What “layer” is below the OS?
Chapter 10 Operating Systems. 2 Chapter Goals Describe the two main responsibilities of an operating system Define memory and process management Explain.
CMPT 300: Operating Systems Review THIS REIVEW SHOULD NOT BE USED AS PREDICTORS OF THE ACTUAL QUESTIONS APPEARING ON THE FINAL EXAM.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Operating Systems Review. Questions What are two functions of an OS? What “layer” is above the OS? What “layer” is below the OS?
Computer Organization and Architecture
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Operating Systems Review. Questions What are two functions of an OS? What “layer” is above the OS? What “layer” is below the OS?
Operating Systems Review. Questions What are two functions of an OS? What “layer” is above the OS? What “layer” is below the OS?
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Memory Management Ch.8.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
Chapter 10 Operating Systems *. 2 Chapter Goals Describe the main responsibilities of an operating system Define memory and process management Explain.
Review of Memory Management, Virtual Memory CS448.
CS 153 Design of Operating Systems Spring 2015 Final Review.
Chapter 10 Operating Systems.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
1 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.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
Operating Systems ECE344 Ding Yuan Final Review Lecture 13: Final Review.
Memory Management. Why memory management? n Processes need to be loaded in memory to execute n Multiprogramming n The task of subdividing the user area.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo 1 Memory management & paging.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program.
1 Lecture 8: Virtual Memory Operating System Fall 2006.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Memory and Addressing It all starts.
Virtual Memory. 2 Last Week Memory Management Increase degree of multiprogramming –Entire process needs to fit into memory Dynamic Linking and Loading.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
Test 2 Preparation. General Information Close book, close notes Review online course notes and read the book. You may work on some exercise problems at.
Chapters 3 and 5 Possible questions
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Section 10: Last section! Final review.
Process management Information maintained by OS for process management
Operating Systems Review.
Chapter 15 – Part 1 The Internal Operating System
Andy Wang Operating Systems COP 4610 / CGS 5675
CPSC 457 Operating Systems
Sarah Diesburg Operating Systems CS 3430
Exam Review Mark Stanovich Operating Systems COP
CSE451 - Section 10.
CSE 451: Operating Systems Autumn 2005 Memory Management
Andy Wang Operating Systems COP 4610 / CGS 5675
Major Topics in Operating Systems
February 5, 2004 Adrienne Noble
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Winter 2006 Module 24 Course Review
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Last section! Project 4 + EC due tomorrow Today: Project 4 questions
CSE451 - Section 10.
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
CSE 153 Design of Operating Systems Winter 2019
Sarah Diesburg Operating Systems COP 4610
Virtual Memory.
Andy Wang Operating Systems COP 4610 / CGS 5675
CSE 542: Operating Systems
Presentation transcript:

MIDTERM REVIEW CSCC69 Winter 2016 Kanwar Gill

What is an OS? What are processes and threads? Process states? Diagram showing the state changes What data structure is used to represent a process in the kernel? What does it contain? What information do threads share? What is a context switch? Example? What is a system call? Examples? You should be able to walk through with the example rather than just giving it. Basics 2

SYNCHRONIZATION

Shared resources, critical sections, race conditions etc. What are the critical section requirements? Be sure to know the motivation behind each Locks, Semaphores, Monitors, Messages etc. Peterson’s algorithm Does this work when scheduling is pre-emptive? Non pre- emptive? Producer-Consumer problem Monitors Semaphores Types? Dining philosophers problem Synchronization 4

Question Using locks and condition variables I attempted to implement the following function: do_exchange(void *arg), which allows pairs of threads to exchange values. After two processes have called do_exchange, they swap the values of the arguments. The function should continue to operate correctly with successive pairs of callers. The following code is my attempt at implementing the this function. Assume that the lock and condition variable are initialized correctly before do_exchange is called. 5 struct lock *entry; struct cv *got_first; /* first and second hold the values to exchange */ int first = -1; int second = -1; int got_one = 0; void *do_exchange(void *arg) { int value = *(int *)arg; lock_acquire(entry); if (!got_one) { got_one = 1; first = value; cv_wait(got_first, &entry); *(int *)arg = second; } else { got_one = 0; second = value; cv_signal(got_first); *(int *)arg = first; } lock_release(entry); fprintf(stderr,"%d -> %d\n", value, *(int *)arg); return NULL; } If I set up a program that creates 6 threads that all call exchange, then I expect the following output: 1  0 0  1 3  2 2  3 5  4 4  5 but I get 1  0 3  2 0  3 2  3 5  4 4  5

1. Explain what happens 2. Does this behavior follow Hoare or Mesa semantic? Explain 3. Describe how you would fix the problem. You don’t have to implement any changes. Assume that the behavior of the locks and condition variables is the same as shown in the output of the above program. 6

SCHEDULING

Scheduling Goals? Fairness, no starvation, policy enforcement, balance Batch vs. Interactive vs. Real-Time systems Types? Preemptive vs. non preemptive Scheduling algorithms FCFS; problems? SJF Round-Robin; problems? Priority scheduling Multi-level scheduling Feedback scheduling 8

Questions: 1. You are given 3 batch jobs X, Y, Z with arrival times 1s, 4s and 7.5s respectively and corresponding service times as 5s, 7s, and 10s. Their priorities are 1,5,2 respectively. Schedule the threads using: a. Round Robin with time quantum = 2s b. Priority Scheduling c. Calculate the avg. waiting time for the above 2. RR scheduling doesn’t give preference to processes with higher priority. Propose and describe two different schemes to extend it to handle priorities. 3. Describe two factors you would use to determine the length of quantum for RR scheduling algorithm. 9

VIRTUAL MEMORY

Virtual Memory Requirements for memory management: 1. Relocation 2. Logical organization 3. Protection 4. Sharing 5. Physical organization When to translate addresses? Execution time Ques: What part of the CPU is responsible for these translations? Allocating memory to processes: Fixed partitioning; cons? Dynamic partitioning; cons? Address translation uses base and limit registers 11

Virtual Memory Tracking memory allocation Bitmaps Free lists Implicit lists Placement algorithms First-fit, best-fit, worst-fit, quick-fit, etc. Paging Pages vs. Frames (size of each is the same) Is there any fragmentation in paging? Example Address translation uses page tables 12

Virtual Memory Page lookups How many references needed for a lookup? Use TLB to reduce the lookup 13

Virtual Memory TLB How many references needed now? TLB maps virtual address to PTE Exploit locality Can be managed by hardware or software 14

Virtual Memory Managing page tables Hierarchical page tables, hashed page tables, inverted page tables Example: Two-level page table 15

Virtual Memory Policies for VM management: Fetch: prepaging, demand paging Placement Replacement Belady aka OPT, LRU, LFU, MFU, FIFO, CLOCK Example Working set size Page fault frequency Thrashing 16

Questions 1. A memory system has 22 bit virtual addresses with 2 16 byte pages. How many entries are in a process’s page table i.e. PTEs? If a PTE takes 8 bytes, how many entries can be stored in one page? 2. What physical address does 0x03BEEF map to? What virtual address does physical address 0x6BF070 map to? 17 Page numberFrame number 10x3F 20x4D 30x6B 40x5D ……

Questions 3. Suppose we have a dynamic partitioning system with 10 units of memory. Sketch the memory space after the sequence of events. Assume best-fit placement is being used. Allocate 3 units for P1 Allocate 5 units for P2 Free P1’s allocation Allocate 4 units for P3 4. We have four page frames and the following reference string: 4,1,3,4,4,5,6,5,1,2,3,7. Demonstrate the page replacements with the following algorithms: a. MRU b. FIFO c. OPT d. CLOCK 18

GOOD LUCK! 19