Homework Assignment #2 J. H. Wang Oct. 25, 2016.

Slides:



Advertisements
Similar presentations
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Advertisements

CPU-Scheduling Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The short term scheduler.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Homework Assignment #2 J. H. Wang Nov. 1, 2013.
Homework Assignment #2 J. H. Wang Oct. 17, 2007.
Homework Assignment #2 J. H. Wang Nov. 1, Homework #2 Chap.5: 5.8, 5.19, 5.22 Chap.6: 6.11, 6.12, *6.35 (Optional: End-of-chapter project for Chap.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
UNIT–II: Process Management
lecture 5: CPU Scheduling
CPU Scheduling CSSE 332 Operating Systems
CPU SCHEDULING.
Chapter 6: CPU Scheduling
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
Applied Operating System Concepts -
Practice Chapter Four.
Chapter 5a: CPU Scheduling
OPERATING SYSTEMS CS3502 Fall 2017
Homework Assignment #2 J. H. Wang Oct. 24, 2017.
CPU Scheduling Algorithms
Chapter 2 Scheduling.
Operating Systems Processes Scheduling.
CPU scheduling 6. Schedulers, CPU Scheduling 6.1. Schedulers
Process Scheduling B.Ramamurthy 9/16/2018.
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 5: CPU Scheduling
Process Scheduling B.Ramamurthy 11/18/2018.
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Andy Wang Operating Systems COP 4610 / CGS 5765
3: CPU Scheduling Basic Concepts Scheduling Criteria
Process Scheduling B.Ramamurthy 12/5/2018.
Chapter5: CPU Scheduling
Operating systems Process scheduling.
COT 4600 Operating Systems Spring 2011
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Outline Scheduling algorithms Multi-processor scheduling
CPU scheduling decisions may take place when a process:
Operating System Concepts
Chapter 6: CPU Scheduling
Process Scheduling Decide which process should run and for how long
Chapter 5: CPU Scheduling
Lecture 2 Part 3 CPU Scheduling
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Process Scheduling B.Ramamurthy 4/19/2019.
Process Scheduling B.Ramamurthy 4/24/2019.
Shortest-Job-First (SJR) Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Process Scheduling B.Ramamurthy 5/7/2019.
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
Scheduling 21 May 2019.
Chapter 6: CPU Scheduling
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Chapter 3: Process Management
Presentation transcript:

Homework Assignment #2 J. H. Wang Oct. 25, 2016

Homework #2 Chap.4: 4.3, 4.17*, 4.18* Chap.5: 5.8, 5.19, 5.22 Programming projects for Chap. 4* (*2) Chap.5: 5.8, 5.19, 5.22 Chap.6: 6.11, 6.23, 6.33* Programming projects for Chap. 6* (*3) (*: programming exercises) Note: at least one programming exercises or end-of-chapter programming projects must be done and submitted Due: two weeks (Nov. 8, 2016)

Chap. 4 4.3: Which of the following components of a program state are shared across threads in a multithreaded process? (a) Register values (b) Heap memory (c) Global variables (d) Stack memory

4.17*: An interesting way of calculating  is to use a technique known as Monte Carlo, which involves randomization. This technique works as follows: Suppose you have a circle inscribed within a square, as shown in Figure 4.18. (Assume that the radius of this circle is 1.)

First, generate a series of random points as simple (x,y) coordinates First, generate a series of random points as simple (x,y) coordinates. These points must fall within the Cartesian coordinates that bound the square. Of the total number of random points that are generated, some will occur within the circle. Next, estimate  by performing the following calculation:  =4*(number of points in circle)/(total number of points) (…to be continued)

(…continued from the previous slide) Write a multithreaded version of this algorithm that creates a separate thread to generate a number of random points. The thread will count the number of points that occur within the circle and store the result in a global variable. When this thread has exited, the parent thread will calculate and output the estimated value of .

4.18*: Repeat exercise 4.17, but instead of using a separate thread to generate random points, use OpenMP to parallelize the generation of points. Be careful not to place the calculation of  in the parallel region, since you want to calculate  only once.

Chap.5: 5.8: The following processes are being scheduled using a preemptive round-robin scheduling algorithm. Each process is assigned a numerical priority, with a higher number indicating a higher relative priority. In addition to the processes listed below, the system also has an idle task (which consumes no CPU resources and is identified as Pidle). This task has priority 0 and is scheduled whenever the system has no other available processes to run. (… to be continued)

The length of a time quantum is 10 units The length of a time quantum is 10 units. If a process is preempted by a higher-priority process, the preempted process is placed at the end of the queue. (… to be continued) Thread Priority Burst Arrival P1 40 20 P2 30 25 P3 P4 35 15 60 P5 5 10 100 P6 105

(a) Show the scheduling order of the processes using a Gantt chart (a) Show the scheduling order of the processes using a Gantt chart. (b) What is the turnaround time for each process? (c) What is the waiting time for each process? (d) What is the CPU utilization rate?

5. 19: Assume that two tasks A and B are running on a Linux system 5.19: Assume that two tasks A and B are running on a Linux system. The nice values of A and B are -5 and +5, respectively. Using the CFS scheduler as a guide, describe how the respective values of vruntime vary between the two processes given each of the following scenarios: (a) Both A and B are CPU-bound. (b) A is I/O-bound, and B is CPU-bound. (c) A is CPU-bound, and B is I/O-bound.

5.22: Consider two processes, P1 and P2, where p1=50, t1=25, p2=75, and t2=30. (a) Can these two processes be scheduled using rate-monotonic scheduling? Illustrate your answer using a Gantt chart such as the ones in Fig.5.16-5.19. (b) Illustrate the scheduling of these two processes using earliest-deadline-first (EDF) scheduling.

Chap.6: 6.11: Assume that a system has multiple processing cores. For each of the following scenarios, describe which is a better locking mechanism – a spinlock or a mutex lock where waiting processes sleep while waiting for the lock to become available: (a) The lock is to be held for a short duration. (b) The lock is to be held for a long duration. (c) A thread may be put to sleep while holding the lock.

6.23: How does the signal() operation associated with monitors differ from the corresponding operation defined for semaphores?

6.33*: Exercise 4.17 asked you to design a multithreaded program that estimated pi using the Monte Carlo technique. In that exercise, you were asked to create a single thread that generated random points, storing the result in a global variable. Once that thread exited, the parent thread performed the calculation that estimated the value of pi. Modify that program so that you create several threads, each of which generates random points and determines if the points fall within the circle. Each thread will have to update the global count of all points that fall within the circle. Protect against race conditions on updates to the shared global variable by using mutex locks.

End-of-Chapter Programming Projects Programming Project for Chap. 4: Project 1. Sudoku solution validator Passing parameters to each thread Returning results to the parent thread Project 2. Multithreaded sorting application

End-of-Chapter Programming Projects Programming Projects for Chap. 6: Project 1: The Sleeping Teaching Assistant Room: 1 desk with a chair and computer Hallway: 3 chairs POSIX threads, mutex locks, and semaphores Project 2: The Dining Philosophers Problem Pthread mutex locks and condition variables Project 3: Producer-Consumer Problem Producer and consumer threads Pthreads mutex locks/semaphores Windows mutex locks/semaphores

Any Question or Comments?