midterm-03_ans

pdf

School

McGill University *

*We aren’t endorsed by this school

Course

427

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

4

Uploaded by DukeTapir3947

Report
OPERATING SYSTEMS (COMP 310 / ECSE 427) – Midterm #3 – Nov. 20, 2023 (10:35-11:25) Name: Student ID: Give a concise but complete answer for each question. Each question is worth 10 points. 1. Assume you are given a C like language that has a built-in monitor data type (there is a monitor keyword in the language). As discussed in the class, this monitor data type provides facility to implement data manipulations that require synchronization (e.g., critical sections). Using this monitor, implement an atomic int data type. Your atomic int data type should provide the following methods: (i) init(x) to initialize the variable to x, (ii) add(x) to add x to the value of the variable and return the result stored in the variable, (iii) sub(x) to subtract x from the variable and return the result stored in the variable. 2. Consider a UNIX like file system that uses i-Nodes. The i-Node representing the root directory is already cached in memory. No other directory or data block is cached in memory. Assume that all directories we consider below are small such that a single data block is enough to hold them. What is the number of disk accesses needed to access the first block of the file given by /home/Galvin/OSBook/10Ed/Outline.pdf ?
3. Consider a UNIX like file system that uses i-Nodes. The i-Node in this file system has 12 direct pointers, one indirect pointer, one double indirect pointer, and one triple indirect pointer. The block size is B in the storage device. The disk block pointer is d bytes long. What is the largest file size you could have in this file system (obtain an expression in terms of B and d)? 4. Consider the above file system. The block size B = 4096 bytes and d is 4 bytes. Assume that the i-Node is already loaded in memory for a file in the file system. A program has already opened a file for read-only access and fd is the file descriptor of the file (it is greater than 0). The file is very large. The program does a seek(fd, 323443355556) and issues a read(fd, buf, 1) operation afterwards on the file to get 1 byte. Assume no index or data block is cached in memory. Also, assume that memory has been allocated for the buf (character buffer with sufficient capacity). What is the number of disk accesses created by the above read operation? 5. Consider a FAT file system. The FAT is already loaded into the memory from the disk. We have a file in this file system that is stored in 20 disk blocks. We want to access data in the middle of the file. So, we execute a seek() operation to move the file pointer to that location and issue a read() command. How many minimum disk blocks accesses would happen due to the read() command? If the file is very large, would this number remain the same or increase very fast?
6. Consider a set of tasks (t A , t B , t C , t D ) that have already arrived at a scheduler that is managing a single processor. The arrival order of the tasks are as follows: A, B, C, and D with A arriving first. Let the burst time of A=6, B=10, C=5, and D=15. a. What would be the turnaround time of the whole set of tasks with the First-Come- First-Serve algorithm (FCFS)? b. What would be the average response time for the whole set of tasks with FCFS? c. What would be the average response time for the whole set of tasks with the Shortest Job First (SJF) algorithm? d. What would be the wait time of task D with SJF? 7. Following tasks arrive at a scheduler that is managing a single processor. a. At time t = 0, task t X with 20 burst time arrives b. At time t = 10, task t Y with 10 burst time arrives c. At time t = 15, task t Z with 10 burst time arrives d. At time t = 20, task t V with 10 burst time arrives What is the time at which task t V would complete? Assume that the scheduler is implemented using a Round-Robin algorithm with a time slice of 5 units (switching overhead is 0). The task switching happens when the running task completes, or the time slice ends for the current run. 8. Which of the following statements are true regarding the Multi-Level Feedback Queue (MLFQ) scheduling? a. MLFQ can use round robin scheduling for some queues b. MLFQ can separate interactive tasks from batch tasks c. MLFQ can starve CPU hogging tasks if there is a constant supply of interactive tasks d. Interactive tasks can be offered very small response times by MLFQ e. None of the above
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
9. Consider a real-time task scheduling situation where Rate Monotonic Scheduling (RMS) is used for three tasks for a single processor. What is the maximum CPU utilization for which RMS can find a feasible schedule for three tasks? Consider the following tasks: a. Task P 1 with a period of 100 and burst of 35 b. Task P 2 with a period of 80 and burst of 20 c. Task P 3 with a period of 60 and burst of 20 Can you find a feasible schedule for these tasks using RMS? 10. We are using a real-time task scheduler running Earliest Deadline First (EDF) to schedule the following tasks on a single processor. a. Task P 1 with a period of 100 and burst of 35 b. Task P 2 with a period of 80 and burst of 20 c. Task P 3 with a period of 60 and burst of 20 Can you find a feasible schedule for these tasks using EDF? If yes, show the schedule for the first 100-time units?