Kyle_Smith_HW09

.docx

School

Fort Hays State University *

*We aren’t endorsed by this school

Course

421

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

3

Uploaded by DoctorMask12981

(CSCI 331) Homework Nine Note: The homework problems are selected from Chapter Nine of your textbook. The students shall first read the book content and do all participant activities in corresponding section before they do the homework questions that are selected from that section. The homework needs to be typed in this word file and submitted via link on blackboard. You may rename this file as YourInitialsCSCI331HW09.docx. Problem 1 (20 points) I/O Overhead A fast laser printer produces 20 pages per minute, where a page consists of 4000 characters. The system uses interrupt-driven I/O, where processing each interrupt takes 50 μsec. a) How much overhead will the CPU experience if the output is sent to the printer one character at a time? 50*4000*20=4000000 microseconds = 4 seconds 4 seconds out of every minute are spent handling interrupts. 4/60=1/15 or 6.67% b) Would polling be a better approach than interrupts? Yes, polling would be a better approach than interrupts. This is because the overhead of running interrupts is much slower than read and write processes. Problem 2 (30 points) Polling vs interrupts. A program is outputting a series of blocks by repeatedly issuing an I/O instruction. a) Executing the I/O instruction takes 1 unit of CPU time. All other instructions take 0 units of time. b) The device starts at the end of the I/O instruction and remains busy for 6 time units. c) When polling is used, the CPU polls the device every 5 time units. d) A poll takes 1 unit of CPU time. e) When interrupts are used, the interrupt handler takes 3 time units to process the interrupt. Draw a timing diagram showing when the CPU and the device are busy during the first 24 time units a) with polling b) with interrupts
Problem 3 (30 points) Disk scheduling algorithms The r/w head of a disk is at track 143. The previous position was track 0. Requests to access the following tracks have arrived: 143, 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130 a) In which order will the tracks be visited using: FIFO – 143, 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130 SSTF – 143, 130, 86, 913, 948, 1022, 1509, 1470, 1750, 1774 Scan – 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 130, 86 C-Scan – 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 86, 130 b) Starting from track 143, determine the number of tracks traversed by the r/w head under each algorithm to service all requests: FIFO = 57 + 1384 + 557 + 861 + 826 + 561 + 487 + 728 + 1620 = 7081 SSTF = 13 + 44 + 827 + 35 + 74 + 448 + 39 + 241 + 24 = 1745 Scan = 770 + 35 + 74 + 448 + 39 + 241 + 24 + 1644 + 44 = 3319 C-Scan = 770 + 35 + 74 + 448 + 39 + 241 + 24 + 1688 + 44 = 3363 Problem 4 (20 points) Incorrect SSTF implementation. The monitor below is an attempt to implement the SSFT algorithm. monitor disk_scheduler { condition q; position = busy = 0 move_to(destination) { if (busy) q.wait(abs(destination - position)) busy = 1 position = destination } release() { busy = 0 q.signal } Explain why the implementation does not correctly enforce the SSTF policy. Construct a scenario to demonstrate the failure. The problem is with the q.wait and q.signal operations. The q.wait(abs(destination – position)) line allows the thread to proceed but after waiting for a random amount of time. Therefore, this does not guarantee that the seek time will be the shortest. Scenario Initial position: 100 Requests arrive in the following order: 50, 150, 200
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