4P13
Lab 5

(This Lab will cover 2 weeks)


Objective

Lab Component

This lab focus on the recompilation of the kernel and modification to the scheduling algorithm to enhance the responsiveness of NICE. You will be given 2 week in which to complete the task, simple because the time in order to obtain the source and do an initial compilation may take hours. It is also expected a learning curve will be required. Extra lab time will be required to complete the tasks as outlined below.

Task 1

Creation of a non-interactive processes .
1) Write a C program, timewaster.c which is purely non-interactive, it should cycle and integer between 0 and 1 million No i/o is required, this is a small process which simply grabs cpu cycles. Just think of this as the name suggests a time waster.

Task 2

Open another window, run top to view the CPU usage statistics. Run 1 instance of your time waster (another window). The process should appear in top as grabbing the most of the CPU.

In a separate window, play around with renice, which adjusts the nice value of the above process between -20 and 20. Do you see a difference as NICE is adjusted.
How do you use renice, see the man pages.

You can start a process using nice (see man pages)

Task 3


Write a script which starts 2 instances of timewaster as background jobs, both with default NICE values. Play around with the NICE value of 1 process, incrementing and decrementing its' value. For an exercise, manually vary the nice value of 1. Once the processes have stabilized in terms of CPU usage, record the usage of each as a percent. E.g. Process 1 consumes 40% Process 2 consumes 30%.  Do this for NICE values ranging from -20 to +20, for intervals, -20, -15, -10, -5, -4, -3 ,-2 ,-1, 0, 1, 2, 3, 4, 5, 10, 15, 20. You might find restarting the scripts with the defined NICE values each time will give you more accurate numbers.

Plot these on a graph (excel would be nice), showing P1 and P2 as relative CPU usages wrt the intervals listed above. Remember, only vary the NICE of P2.

Here is a starter script to be written to a file and executed like any other executable. Call it MyFirstScript.sh or some other name.

#!/bin/sh
YourProcess-timewaster
FirstPID=$(echo $!)
echo $FirstPID

What you need to add to the script is to ensure that each process executes on a defined CPU. Use cpuset to ensure this. This will force the scheduler to run both instances of timewaster on the same core, adjusting the priority based on NICE. Google how you use this.

Task 4


This one will take allot of time and you are required to spend extra lab time, most of which will be waiting, to complete. Start by reading Section 23 of the freeBSD handbook form freebsd.org. It will make reference to svn which is the version tracker which the developers use. Read it all.

If you do not have the source file installed /usr/src then you will need to update and synchronize your sources. Expect hours of waisted time waiting. Start it, go for dinner and movie. "svn" is referred to as svnlite, where synchronization can be done with <svnlite checkout https://svn.freebsd.org/base/stable/10/  /usr/src>.

Consider the scheduler sched_ule.c located in src/sys/kern. Modify the scheduler so the value of NICE is enhanced by a factor of 2. Define a scaling value as a constant and then modify the code to account for the scaling value. Compile the kernel and install it as per directions in Section 23. Be sure you read everything very carefully, or bad things can happen.

Once complete rerun the Task 3 experiment, with the new scheduler.


Reward Requirements