Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Programming Assignment 2

CS450 Spring, 2023

1. This assignment is an individual effort. It is due on 03/03/2023

2. Requirements:

The best way to learn how to implement a system call (or the control mechanism of an operating system) is to trace an existing system call and implement one. This assignment therefore consists of two parts. The first part asks you to trace the execution of the read()system call. The second part asks you to implement a system call that will allow a user program to change the number of time slices allocated to it.

1) (15 points) You will trace the read()system call. Assume that a user program executes the statement read(fd, *buf, count) but fd is undefined. Therefore, the result of the execution will be an exception. You are asked to write down in a document which lines in which files of xv6 are executed. Organize the lines of code into blocks of code and explain the purpose of each of block. The result will be a story of what happened when a non-existing file descriptor is given to a read(). The story starts in the user space when the system call first gets executed and ends with feedback to the user that fd is bad.

2) (50 points) In this exercise, you will implement the alsoNice(int n) system call that will increase the amount of time slice allocated to the program that calls it.

i. The default xv6 scheduler uses a simple FCFS and RR policies with each process having the same time slice (T).

ii. (20 points) The program that calls alsoNice() will have its time slice increased to n times T.

iii. (20 points) After alsoNice(), your xv6 will now execute programs with different time slices. In addition to FCFS with RR, we ask you to at least implement LTSF (largest time slice first) and STSF (shortest time slice first) with RR.

iv. (Up to 15 points)For additional credit, you can implement other scheduling algorithms.

v. (10 points) We ask you to analyze and compare the different scheduling algorithms that you implement. You need to be clear about the criteria that you use to compare them

To implement alsoNice(), you will need to understand how xv6 handles timer interrupts and process preemption. The xv6 code for these functionalities is basically in proc.c and trap.c. Chapter 7 of the xv6 book will be helpful.

To help with your experiment, we advise that you should turn off the multi-core scheduling of xv6. Yun will write you later on how to do that. 

3. Deliverables:

1) Your documentations will be graded for conciseness. They should be typed with font size no less than 11.

2) (See Section 2 on points allocation) A document describing the execution of read()with a non-existing file descriptor starting from the user level. This document should not be longer than 2 pages.

3) (15 points on 3.3, 3.4 and 3.7) A manual page for the system call alsoNice()including the exception handling interface. You also need to describe how to call it from user level. This document should not be longer than 1 page.

4) (See Section 2 on points allocation) A document that compares the different scheduling algorithms. It should not be longer than 2 pages.

5) A document describing each file that you changed (Notice using:$ diff -uw “$orginal” “$modified$ > ./diff/“$orginal.txt”) to implement your scheduler and alsoNice().

6) A document describing how you test the results of the assignment.

7) Screen shots of your results.

8) Source and executable objects of the system call and test drivers with a README on how to build and execute them.

9) All deliverables must be in a zip file named Lastname-Firstname-AID.zip.

10) You are not allowed to post this or any other programming assignment of this course to the Internet such as in GibHub that will allow others to get access to your results. Violation of this will result in an E grade for the course.