Operating Systems 2013/14 Assignment 3. Submission Deadline: Tuesday, December 17th, :30 a.m.

Similar documents
Operating Systems 2013/14 Assignment 1. Submission Deadline: Monday, November 18th, :30 a.m.

8: Scheduling. Scheduling. Mark Handley

COSC243 Part 2: Operating Systems

Programming Assignment HW4: CPU Scheduling v03/17/19 6 PM Deadline March 28th, 2019, 8 PM. Late deadline with penalty March 29th, 2019, 8 PM

CS370 Operating Systems Midterm Review

Homework Assignment #5

Programming Assignment HW5: CPU Scheduling draft v04/02/18 4 PM Deadline April 7th, 2018, 5 PM. Late deadline with penalty April 9th, 2018, 5 PM

Starting the Threads

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

Operating System Concepts Ch. 5: Scheduling

Midterm Exam. October 20th, Thursday NSC

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

Chapter 6: CPU Scheduling

Course Syllabus. Operating Systems

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

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

Operating Systems. Process scheduling. Thomas Ropars.

Frequently asked questions from the previous class survey

Scheduling. Scheduling 1/51

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018

IT 540 Operating Systems ECE519 Advanced Operating Systems

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Round Robin (RR) ACSC 271 Operating Systems. RR Example. RR Scheduling. Lecture 9: Scheduling Algorithms

1.1 CPU I/O Burst Cycle

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

CSE 120 Principles of Operating Systems Spring 2017

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

Scheduling. Scheduling 1/51

Operating Systems. Scheduling

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition

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

CS370 Operating Systems

Assignment 3 (Due date: Thursday, 10/15/2009, in class) Part One: Provide brief answers to the following Chapter Exercises questions:

Operating Systems and Networks Assignment 9

CS370 Operating Systems

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

CS370 Operating Systems Midterm Review. Yashwant K Malaiya Spring 2019

Practice Exercises 305

SAMPLE MIDTERM QUESTIONS

Operating Systems (1DT020 & 1TT802)

CSE473/Spring st Midterm Exam Tuesday, February 19, 2007 Professor Trent Jaeger

CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. Dispatcher. CPU Scheduler. Alternating Sequence of CPU and I/O Bursts

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

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

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition,

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Scheduling

CHAPTER NO - 1 : Introduction:

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

Signals, Synchronization. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

CS370 Operating Systems

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering)


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

CS 5523: Operating Systems

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ!

CPU Scheduling. Schedulers. CPSC 313: Intro to Computer Systems. Intro to Scheduling. Schedulers in the OS

Tasks. Task Implementation and management

Last Class: Processes

QUESTION BANK UNIT I

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

Operating Systems. Figure: Process States. 1 P a g e

CS140 Operating Systems and Systems Programming Midterm Exam

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms

UNIT 2 Basic Concepts of CPU Scheduling. UNIT -02/Lecture 01

Chapter 5 CPU scheduling

Synchronization. Race Condition. The Critical-Section Problem Solution. The Synchronization Problem. Typical Process P i. Peterson s Solution

CSE 4/521 Introduction to Operating Systems

Chapter 5: CPU Scheduling

Process Synchronisation (contd.) Operating Systems. Autumn CS4023

CS3733: Operating Systems

CS370 Operating Systems

Problem Set: Processes

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

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

CSE 421/521 - Operating Systems Fall Lecture - VII CPU Scheduling - II. University at Buffalo

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

Midterm Exam Amy Murphy 6 March 2002

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

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

FCM 710: Architecture of Secure Operating Systems

CISC 7310X. C05: CPU Scheduling. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/1/2018 CUNY Brooklyn College

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

Chapter 5: Process Synchronization. Operating System Concepts Essentials 2 nd Edition

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Scheduling. Today. Next Time Process interaction & communication

CSE 120 Principles of Operating Systems

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

CSC369 Lecture 5. Larry Zhang, October 19,2015

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

Process & Thread Management II. Queues. Sleep() and Sleep Queues CIS 657

Process & Thread Management II CIS 657

CS 326: Operating Systems. CPU Scheduling. Lecture 6

Lesson 6: Process Synchronization

CSE 4/521 Introduction to Operating Systems

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

Transcription:

Operating Systems 2013/14 Assignment 3 Prof. Dr. Frank Bellosa Dipl.-Inform. Marius Hillenbrand Dipl.-Inform. Marc Rittinghaus Submission Deadline: Tuesday, December 17th, 2013 9:30 a.m. In this assignment you will study scheduling, communication, and synchronization of processes. In the practical part, you will implement a simple user-level scheduler. All the organizational words of the first assignment are still valid and have to be followed. Please print out the pages containing T-Questions and answer them on your printout. Clearly mark every page with your name, matriculation number and tutorial number. Simply put it in the mailbox in the basement of building 50.34 (Info-Neubau). P-Questions are programming assignments. Download the provided tarball from the VAB and make sure to use the included templates and Makefiles. Do not fiddle with the compiler flags. Submission instructions can be found in the first assignment sheet. Any assignment handed in after its deadline will be ignored! T-Question 3.1: Scheduling Algorithms a. Depict the Gantt chart for scheduling the following processes with Round-Robin scheduling and a timeslice length of 2 time units. New processes are added to the tail of the ready queue. Check the lecture slides for how to draw a Gantt chart for scheduling. Process Burst length Arrival time P 1 5 0 P 2 2 1 P 3 3 2 2 T-pt b. Calculate the average waiting time in the example given in 3.1 a. 1 T-pt 1

c. Calculate the average turnaround-time in the example given in 3.1 a. 1 T-pt d. Which of the following scheduling algorithms are vulnerable to process starvation, which are not? (correctly marked: 0.5P, not marked: 0P, incorrectly marked: -0.5P) 3 T-pt vulnerable not vulnerable Round-Robin with priorities FCFS Lottery Scheduling Preemptive SJF MLFB Linux CFS T-Question 3.2: Interprocess Communication a. What are the two fundamental models of interprocess communication? 1 T-pt T-Question 3.3: Synchronization a. What are the three requirements for a valid solution of the critical-section problem? 1 T-pt b. What is the difference between a binary semaphore and a counting semaphore? 1 T-pt 2

c. A spinlock might be implemented using the following code: while( TestAndSet( &lock ) ) ; Why can this code exhibit poor performance on modern multiprocessor systems? 1 T-pt d. Which of the following statements are correct, which are incorrect? (correctly marked: 0.5P, not marked: 0P, incorrectly marked: -0.5P) 3 T-pt correct incorrect Spinlocks can be implemented entirely in userspace. Disabling interrupts is a valid solution to the critical section problem on uniprocessor systems. The compareandswap instruction is useful on uniprocessor systems. The Swap instruction atomically swaps two registers. Disabling interrupts is a valid solution to the critical section problem on SMP systems. T-Question 3.4: Deadlock Basics a. Enumerate and explain the 4 necessary conditions for a deadlock. 2 T-pt 3

P-Question 3.1: Scheduling Data Structures a. Implement a priority-based run queue that could be used by an operating system to keep track of all runnable processes. Each process is identified by a unique id (id 0) and has a priority (where a higher number means a higher priority). The algorithmic complexity of each function should be O(n) at most, while pop whould work in O(1) because of it is called for each scheduling decision. The following functions need to be supported: 4 P-pt void insert ( int id, int priority ); int pop (); // get id of element with highest priority, // and remove it from the list // (return -1 if there are no more elements) void popid ( int id ); // remove element with given id, if present Note: You only have to implement the data structure and the functions mentioned above! You don t have to implement code to fill your data structure with processes (though you might want to do so for testing) or to select/dispatch/schedule the processes. P-Question 3.2: Signal Handlers a. Read man 7 signal and man 2 sigaction. Add a SIGINT-handler to the program listed below. The handler should write Received Signal on the screen. In addition, when the handler receives three signals within three seconds it should write Shutting down and then terminate the program with the exit status 1. 3 P-pt int main() { printf( "Hello World!" ); for( ;; ) { /* infinite loop */ } return 0; } P-Question 3.3: The clone System Call & POSIX Semaphores a. Recall the code in Tutorial-Assignment 7.1 (full code in asst3-clone/ folder in tarball). OpenMP was used to create multiple threads in the example main-openmp.c. Write an alternative which creates the threads using the clone system call. Place it into main-clone.c. Carefully read the manual page (man 2 clone) before you start writing code; think about the flags you need to pass to the clone call to have the threads share the same address space and to be waitable by the waitpid syscall. Don t modify the signature of the increment-function! b. Use POSIX semaphores to solve the critical section problem in tally.c. If you failed to complete the a. part of this assignment, use the OpenMP version for testing (./tally-openmp). Read man 3 sem init, man 3 sem post, man 3 sem wait and man 3 sem destroy. Keep the critical section as short as possible and clean up the semaphores at the end! 2 P-pt 2 P-pt 4

P-Question 3.4: Round-Robin Scheduling In this assignment, we offer you a simple implementation of many-to-one (userlevel) threads. ult.c contains code for thread management (such as context switching and random blocking/deblocking of threads). scheduler.c is meant to contain the implementation of the actual scheduling policy. To get familiar with the provided code, answer yourself the following questions: What thread states are supported by our implementation? What function is executed by all threads (except for the idle thread)? What is the thread id of the idle thread? What is the probability that a thread will block during one time slice? What does the thread management code do to emulate a timer interrupt? What is the frequency of the emulated timer interrupt? Which function can be considered to be the interrupt-handler for the emulated timer interrupt? Given a pointer char *p to a thread s context (in the threads-array), write C code that derives the thread s id. a. The current scheduler only switches between thread 0 and thread 1. Modify it so that it selects the next thread to be executed among all runnable threads according to a Round-Robin scheduling policy. Do not reorder the threads-array! 5 P-pt Total: 16 T-pt 16 P-pt 5