Operating Systems (1DT020 & 1TT802)

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

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

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

CSE 153 Design of Operating Systems

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

COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr.

Sample Questions. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

CPS 110 Midterm. Spring 2011

(b) External fragmentation can happen in a virtual memory paging system.

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

COMP 3361: Operating Systems 1 Final Exam Winter 2009

CS 318 Principles of Operating Systems

Lecture 9: Midterm Review

Midterm Exam. October 20th, Thursday NSC

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions).

Operating Systems: Quiz2 December 15, Class: No. Name:

CMPSCI 377: Operating Systems Exam 1: Processes, Threads, CPU Scheduling and Synchronization. October 9, 2002

CMPS 111 Spring 2003 Midterm Exam May 8, Name: ID:

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

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

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

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

( B ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Shared memory (C) Semaphore (D) Monitor

Midterm Exam Solutions Amy Murphy 28 February 2001

Midterm I October 11 th, 2006 CS162: Operating Systems and Systems Programming

INSTITUTE OF AERONAUTICAL ENGINEERING Dundigal, Hyderabad COMPUTER SCIENCE AND ENGINEERING QUESTION BANK OPERATING SYSTEMS

Operating System Review Part

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

May 19, Answer pieces in italics were not required to receive full points.

Suggested Solutions (Midterm Exam October 27, 2005)

COS 318: Midterm Exam (October 23, 2012) (80 Minutes)

Midterm I October 12 th, 2005 CS162: Operating Systems and Systems Programming

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

1995 Paper 10 Question 7

Chendu College of Engineering & Technology

(MCQZ-CS604 Operating Systems)

AC59/AT59/AC110/AT110 OPERATING SYSTEMS & SYSTEMS SOFTWARE DEC 2015

INSTITUTE OF AERONAUTICAL ENGINEERING

Chapter 2 Processes and Threads. Interprocess Communication Race Conditions

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

Problem Set: Processes

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ!

CSE 120 Principles of Operating Systems Spring 2017

* What are the different states for a task in an OS?

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

CS4411 Intro. to Operating Systems Exam 2 Fall 2009

Operating Systems (Classroom Practice Booklet Solutions)

Unit In a time - sharing operating system, when the time slot given to a process is completed, the process goes from the RUNNING state to the

CSE 120 Principles of Operating Systems

QUESTION BANK UNIT I

CPSC/ECE 3220 Summer 2017 Exam 2

FCM 710: Architecture of Secure Operating Systems

MC7204 OPERATING SYSTEMS

Final Exam Preparation Questions

Exam Guide COMPSCI 386

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far.

University of Waterloo Midterm Examination Model Solution CS350 Operating Systems

Chapter 5: CPU Scheduling

CSE 120. Fall Lecture 8: Scheduling and Deadlock. Keith Marzullo

Operating Systems. Lecture Process Scheduling. Golestan University. Hossein Momeni

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT I

SAMPLE MIDTERM QUESTIONS

Midterm Exam #2 Solutions October 25, 2016 CS162 Operating Systems

KEY CENG 334. Midterm. Question 1. Question 2. Question 3. Question 4. Question 5. Question 6. Total. Name, SURNAME and ID

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 3 Solution

Properties of Processes

CS350: Final Exam Review

CSC 716 Advanced Operating System Fall 2007 Exam 1. Answer all the questions. The maximum credit for each question is as shown.

CSI3131 Final Exam Review

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

CS450 OPERATING SYSTEMS FINAL EXAM ANSWER KEY

COMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE. Name: Student ID:

Chapter 6: CPU Scheduling

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

Lecture 7: CVs & Scheduling

Homework Assignment #5

CS604 - Operating System Solved Subjective Midterm Papers For Midterm Exam Preparation

Remaining Contemplation Questions

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

Last Class: Deadlocks. Today

Two hours. Question ONE is COMPULSORY UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 25th January 2013 Time: 14:00-16:00

8: Scheduling. Scheduling. Mark Handley

Midterm Exam Amy Murphy 6 March 2002

FCM 710: Architecture of Secure Operating Systems

Operating Systems EDA092, DIT 400 Exam

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

Main Points of the Computer Organization and System Software Module

Operating Systems Prof. Allan Gottlieb Practice Final Exam Page 1 Name

Stanford University Computer Science Department CS 140 Midterm Exam Dawson Engler Winter 1999

Last Class: Processes

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables

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

COMP 3361: Operating Systems 1 Midterm Winter 2009

CHAPTER NO - 1 : Introduction:

CPU Scheduling Algorithms

Midterm I October 18 th, 2010 CS162: Operating Systems and Systems Programming

OS Assignment II. The process of executing multiple threads simultaneously is known as multithreading.

STUDENT NAME: STUDENT ID: Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Total

Transcription:

Uppsala University Department of Information Technology Name: Perso. no: Operating Systems (1DT020 & 1TT802) 2009-05-27 This is a closed book exam. Calculators are not allowed. Answers should be written in English. Write your name on each sheet A mark of 50% is required to pass the exam. Make your answers as concise as possible. Write all your answers directly on this paper. Space for your answer has been left after each question. If you need more space you can use page 19 and 20 (do not forget to recall the number of the question). You should hand in all the 20 pages of the exam (even if you do not use page 19 and 20). The number in square brackets after the question s number indicates the number of points given to the question; there are 100 points in all. Problem no. Points possible Points scored 1 8 2 15 3 15 4 12 5 9 6 8 7 10 8 8 9 8 10 8 TOTAL 100 Page 1/20

A. Operating systems, processes and threads [23 points] 1) [8 pts] 1-a) [2 pts] Give a short definition of an operating system. 1-b) [3 pts] What is an operating system kernel? Give 4 examples of operating system activities that must be performed by the operating system kernel. 1-c) [3 pts] What is dual mode operation? Why is dual mode operation needed? What is a privileged instruction in a processor s instruction set architecture? Page 2/20

2) [15 pts] 2-a) [2 pts] What is the difference between a program and a process? 2-b) [3 pts] What is the difference between processes and threads? 2-c) [3 pts] What is the CPU context of a process? Briefly describe what the operating system does to perform a context switch (assume an operating system with a UNIX-like process model, i.e. without threads). Page 3/20

2-d) [4 pts] There are 3 types of events (at the instruction set level) that can trigger a context switch. Name them and give a short definition for each. 2-e) [3 pts] In a computer system with virtual memory a user program has the illusion of being alone in memory. Where in memory is the operating system program to which control is transferred when one of the events that trigger a context switch occurs? How is that operating system program protected? Page 4/20

B. CPU scheduling [15 points] 3) [15 pts] Suppose we have the following processes and their associated CPU running times. All the processes arrive in alphabetical order at time 0. Process ID CPU running time A 20 B 50 C 30 D 40 E 30 3-a) [4 pts] Show the scheduling order for these processes under 4 policies: First Come First Served (FCFS), Shortest Job First (SJF), Round-Robin (RR) with time slice quantum = 10, and Shortest Remaining Time First (SRTF). Assume that context-switch overhead is 2, and that there is a context switch to launch the first process and a context switch when the last process terminates. Use the table below for your answer. Give the ID of the process executed each time slot (quantum) You can omit the ID when it is the same as in the previous time slot. Time Slot (quantum number) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 FCFS SJF RR SRTF Page 5/20

3-b)[4 pts] For each process in each schedule above, indicate the waiting time (WT) and the completion time (CT). Note that the waiting time is the total time spent waiting in ready queue, while the completion time is the total time from arrival to completion. (Fill out the table below) Scheduler Process A Process B Process C Process D Process E FCFS WT CT SJF WT CT RR WT CT SRTF WT CT 3-c) [2 pts] With a context switch overhead of 2, is a quantum of 10 a good choice for Round Robin scheduling? Why or why not? 3-d) [3 pts] In this problem, we have so far ignored I/O. Real applications alternate between waiting for I/O (or other events) and CPU time bursts. The CPU time burst of a process is the time between blocking on I/O operations or other events. The CPU time burst is hard to determine before runtime. Describe one way to dynamically predict (at runtime) the CPU time burst of a process. Page 6/20

3-e) [2 pts] Suppose that a scheduling algorithm favours those processes that have used the least CPU time in the recent past. Why will this algorithm favour I/O-bound processes and yet not permanently starve CPU-bound processes? C. Synchronization (21 points) 4) [12 pts] Mutual exclusion consists in ensuring that only one thread does a particular thing at a time. That is, one thread excludes the others while doing its task (this task is a critical section of the thread and threads have to synchronize to access critical sections). Changing a shared variable, updating a table, writing a file are examples of tasks that have to be performed in a mutually exclusive way. 4-a) [2 pts] One way to implement mutual exclusion on a mono-processor system is to provide user programs with system calls to acquire and release locks managed by the operating system. Suppose a thread is running in a critical section: meaning that it has acquired all the locks through proper arbitration. Can it get context-switched? Why or why not? Page 7/20

4-b) [2 pts] Another way to provide mutual exclusion on a mono-processor system is to provide the user with a system call to disable interrupts and a system call to enable interrupts. List two problems with this approach. 4-c) [3 pts] Some processors have atomic instructions to read and modify a variable in memory (eg. test and set, swap) which can be used to implement spinlocks. With spinlocks, threads spin in a loop (busy waiting) until the lock is freed. In class, we motivated the use of blocking locks and semaphores as an improvement over spinlocks because busy waiting can be very inefficient in terms of processor utilization. However, spinlocks are not always less efficient than blocking locks. Briefly describe a scenario where spinlocks would be more efficient than blocking locks. Page 8/20

4-d) [3 pts] Briefly explain how one can implement mutual exclusion to a critical section without busy-waiting using interrupts disabling and enabling and a lock variable in kernel. When are interrupts disabled and re-enabled? 4-e) [2 pts] Briefly explain how semaphores can be used to implement mutual exclusion access to critical sections. 5) [9 pts] Monitors are language constructs. A monitor has internal state variables, zero or more condition variables for managing concurrent access to shared data, together with operations that are guaranteed to be mutually exclusive. The compiler, with the help of system calls provided by the operating system, insures that threads acquire the lock associated to the monitor at the entry of a monitor s operation and release the lock when they leave a monitor operation or block inside a monitor operation. When resumed, a thread blocked inside a monitor operation has to re-acquire the monitor s lock. A monitor has also an initialization operation, init(), executed once (at monitor creation). A condition variable can be seen as a queue of threads waiting for something inside a critical section. There are 2 operations that can be performed on a condition variable c: - c.wait() put the calling thread on the queue c - c.signal() remove one and only one thread from the queue c (no operation if the queue is empty). The scheduling of the queue is implementation dependent. Page 9/20

A key idea with monitors is that they make it possible for a thread to go to sleep inside critical section by atomically releasing the lock to monitor at the time the thread goes to sleep. An important issue is then: which of the signaler and the awaken waiter gets the lock to monitor? - In Hoare-style monitors: the signaler gives the lock and processor to the awaken waiter and the awaken waiter runs immediately. Waiter gives the lock and processor back to signaler when waiter exits critical section or waiter waits again. - In Mesa-style (most real operating systems): signaler keeps lock and processor, and waiter is placed on ready queue with no special priority. 5-a) [2 pts] Briefly compare Hoare-style and Mesa-style monitors. 5-b) [7 pts] A rendez-vous monitor It is sometimes useful to allow N threads to rendez-vous. That is, each thread has a meeting point in its own code, and no thread can go beyond its meeting point before all the N participating threads have arrived at their respective meeting points. This is usually called a synchronization barrier. In lab 2, we studied barrier implementation using semaphores. This problem deals with barrier implementation using a monitor. 5-b-i) [5 pts] Design a Mesa-style monitor rendezvous with 1 operation, arrived(). To achieve barrier synchronization N Threads use a rendezvous monitor as follows: - when the program is loaded for execution, the monitor initialization operation init is executed with N (the number of thread participating in the rendez-vous) as parameter. - each thread s program is as follows : //code before the meeting point rendezvous.arrived() //the thread is at its meeting point //code beyond the meeting point Page 10/20

When a thread calls rendezvous.arrived(), it is blocked until all the N participating threads have called rendezvous.arrived(). Your solution should work and avoid deadlock for any number of participating threads as far as they use the monitor rendezvous as indicated above. Explain your design for full credit (Do not forget to describe the internal state variables of the monitor and the code for initialization operation). Page 11/20

Answer to question 5-b-i (continued) 5-b-ii) [2 pts] Is it possible write a simpler solution using a Hoare-style monitor? Why or why not? D. Virtual Memory [26 points] 6) [8 pts] 6-a) [2 pts] What is a virtual address? What is the address space of a process? Page 12/20

6-b) [4 pts] Briefly explain what a page fault is and how it is handled by the operating system. 6-c) [2 pts] What are translation look-aside buffers (TLBs)? Why are TLB important? 7 [10 pts] Assume a machine with 64-bit virtual addresses and a memory addressing with segments that are paged. Each process can have up to 64K (2 16 ) segments, and page size is 64 K bytes. The segment tables and page tables are stored in main memory, and the processor has a segment register that contains the address of the process s segment table. The segment tables and page tables can start at any byte address. If valid, each segment table entry (STE) points to a page table, and each page table entry (PTE) points to a page in physical memory. Each PTE has also: a read-enable bit, a write-enable bit, a reference bit (set on each reference to the page), and a dirty bit (set each time the reference to the page is a write). The machine can support physical memories up to 64 gigabytes (2 36 ). Page 13/20

7-a) [5 pts] Draw a diagram of the machine s address translation system. Show how the pieces of the virtual address are used to reference each of the tables, and to generate the physical address. Give the size of each field, where it is used, and where it comes from. Also indicate where page faults or memory protection violation traps will be indicated. 7-b) [2 pts] How large (in bytes) is a full-sized segment table? Page 14/20

7-c) [2 pts] Is it a good idea to add a limit field in STE s? Why or why not? Should this limit field be in units of bytes or pages? 7-d) [1 pt] Considering only the memory addressing system described in this problem (no TLB is used), what needs to be saved and restored on context switch? (Assume a UNIX like process model without threads) 8 [8 pts] 8-a) [4 pts] The LRU (Least Recently Used) page replacement replaces the page that has not been used for the longest period of time. Explain why LRU implementations are not conceivable without hardware assistance beyond the standard TLB. Briefly explain how LRU can be approximated (be explicit and describe the hardware support which is necessary). Page 15/20

8-b) [4 pts] What is the working set of a process? Describe a way to approximate the working set of a process and how to use it to detect and avoid thrashing (ie detect and avoid system performance degradation due to too many swapping-out and swapping-in of pages). E. File systems [8 points] 9) [8 pts] 9-a) [2 pts] Which component of disk access time is the disk scheduling algorithm trying to minimize? 9-b) [6 pts] Consider the following 3 file descriptor structures: contiguous allocation, linked list allocation, and Unix multilevel indexed allocation. Each of the structures has its advantages and disadvantages depending on the goals for the operating system and the expected file access patterns. For each of the 2 following situations (9-b-i and 9-b-ii), rank the 3 file descriptor structures in order of preference. Give the justification for your ranking. Page 16/20

9-b-i) [3 pts] We have a file system where the most important criteria is the performance of random access to very large files. 9-b-ii) [3pts] We have a file system where the most important criteria is the utilization of the disk capacity (i.e. getting as much file bytes on the disk as possible)? F. I/O systems [8 points] 10) [8 pts] 10-a) [2 pts] What is the difference between an I/O device controller and an I/O device driver? For each of them say if it is or it is not part of the operating system. Page 17/20

10-b) [3 pts] The operating system can be notified that an I/O device has completed an operation using two different methods. Name these two I/O completion notification methods and briefly compare them. 10-c) [3 pts] Define Direct Memory Access (DMA). Under what conditions is it useful? End! (You can use the 2 following pages for additional space for your answers) Page 18/20

Use this blank page for additional space for your answers. (You should hand in this page even if you do note use it) Page 19/20

Use this blank page for additional space for your answers. (You should hand in this page even if you do note use it) Page 20/20