Assignment1 CPSC 457
Assignment1 CPSC 457
Assignment 1
Due: Friday September 25th @ 11:59 PM
Total: 20 marks; Worth 8% of your final mark
Objectives:
This assignment is intended to:
1. Introduce you to KOS
2. Show you how to add system calls to KOS
3. Understand the cost of system calls
Supplied material:
As part of the assignment, you are given a file called syscall_test.cc, which is the user-level program that you will use to test
your system call.
Deliverables:
1. Add a new system call to KOS long sysadd(long, long)that adds two integers. [6 points]
2. Write a user-level procedure call long procadd(long, long) that adds two integers in syscall_test.cc. [2 points]
3. Use the user level program given in syscall_test.cc to invoke your system call and the procedure call and verify the
output. [2 point]
4. Measure, print, and compare the average number of CPU cycles consumed for the execution of the system call and the
procedure call. Use Time Stamp Counter(TSC) for measuring the same. Repeat each call 50k times or more using a loop.
Measure the total number of CPU cycles consumed by the loop. Find the average number of clock cycles consumed per call. [6
points]
5. Which of the two calls is more expensive? What is the reason of the extra cost for the costlier call? Answer each question in no
more than 3 sentences. [4 points]
(Code that does not compile receives at most 40% of the total mark.
Code that compiles but does not run receives at most 60% of the total mark)
Sample output:
proc_add sum: 8
proc_add cpu_cycles: xxxxx
syscall_add sum: 8
syscall_add cpu_cycles: yyyy
Notes:
1.
2.
3.
Add syscall_test.cc and run make from kos/src/user to create an executable of syscall_test.cc called
syscall_test. The executable syscall_test would be loaded as a RAM file when you run KOS.
You can run the executable by invoking syscall_test as a new process in kos/src/main/InitProcess.cc
You are allowed to modify syscall_test.cc
Submission Instructions:
Submit one hardcopy per team of the following (in the shown order)
1.
2.
3.
4.
5.
6.
7.
diff of the files that were modified in KOS. Use git diff command
Answers to item 5 in the deliverables