OS A1 Easy
OS A1 Easy
Assignment 1 – Easy
Total: 40 Marks
Instructions:
1. The assignment has to be done individually.
2. You can use Piazza for any queries related to the assignment and avoid
asking queries on the last day.
The assignment has 5 parts.
1
sys_fork 10
sys_read 20
int
main ( int argc , char * argv [])
{
// If you follow the naming convention , the system
call
// name will be sys_toggle and you
// call it by calling the function toggle () ;
// toggle () ;
toggle () ;
exit () ;
}
– Create two files called, “user toggle.c”, and “print count.c” in the
root directory.
– Add a line “ user toggle” and “ print count” in the Makefile. The
relevant part of your Makefile should look like this:
UPROGS=\
_cat\
_echo\
_forktest\
_grep\
_init\
_kill\
_ln\
_ls\
_mkdir\
_rm\
_sh\
_stressfs\
_usertests\
_wc\
_zombie\
_user_toggle\
_print_count\
2
The only change in this part is the last two lines.
– Also make changes to the Makefile as follows (the only change is on
the second line):
1 EXTRA=\
2 user_toggle.c print_count.c\
3 mkfs.c ulib.c user.h cat.c echo.c forktest.c grep.c kill.c\
4 ln.c ls.c mkdir.c rm.c stressfs.c usertests.c wc.c zombie.c\
5 printf.c umalloc.c\
6 README dot-bochsrc *.pl toc.* runoff runoff1 runoff.list\
7 .gdbinit.tmpl gdbutil\
– Now, enter the following commands to build the OS in the xv6 di-
rectory.
make clean
make
– If you want to test the user program, launch xv6 using the command
make qemu-nox
After xv6 has booted in the new terminal, you can type
ls
This will show user toggle and print count in the list of available
programs.
• Add system call: sys add()
In this part, you have to add a new system call to xv6. This system call
should take two integer arguments and return their sum. Create a system
call, sys add(), and then create a user-level program to test it.
• Process List: sys ps()
In this part you have to add a new system call, sys ps(), to print a list of
all the current running processes in the following format:
Similarly for this part, create a new user program, which should in turn
call your sys ps() system call.
3
for reading the data sent from a sender process at the receiver process.
The length of the message is fixed at 8 bytes. The signatures of the
system calls are:
• msg: Pointer to the buffer where the message from the sender is
stored (after sys recv returns). This is a blocking call.
The return type is int: 0 means success and any other value indicates an
error.
Note: You can implement the multicast communication model using the
sys recv system call instead of a signal handler.
4
A sample program has been provided. It needs to be completed. The pro-
gram takes two command line arguments: ⟨type⟩ and ⟨input f ile name⟩. If the
type is 0, you use unicast communication, and if it is 1, you use multicast based
communication.
Some more points:
5 Report: 10 Marks
Page limit: 10
The report should clearly mention the implementation methodology for all the
parts of the assignment. Small code snippets are alright, additionally, the pseu-
docode should also suffice.
• Distributed Algorithm: How exactly does your algorithm work?
• IPC: Explain the implementation of the interrupt handler
• Any other details that are relevant to the implementation.
• Submit a pdf file containing all the relevant details.
• Say what you have done that is extra.
6 Submission Instructions
• We will run MOSS on the submissions. We will also include last year’s
submissions. Any cheating will result in a zero in the assignment, a penalty
as per the course policy and possibly much stricter penalties (including a
fail grade).
• There will be NO demo for assignment 1. Your code will be evaluated
using a check script (check.sh) on hidden test cases and marks will be
awarded based on that. You can find the test scripts here. The README
file inside the test scripts tarball contains the instructions to run the test
scripts. You need to submit only the assign1 8.c file.
5
How to submit:
1. Copy your report and the assign1 8.c file to the xv6 root directory.
2. Then, in the root directory run the following commands:
make clean
tar czvf assignment1_easy_<entryNumber>.tar.gz *
This will create a tarball with the name, assignment1 easy < entryN umber >
.tar.gz in the same directory. Submit this tarball on Moodle. Entry num-
ber format: 2020CSZ2445. (All English letters will be in capitals in the
entry number.)
3. Please note that if the report is missing in the root directory, then no
marks will be awarded for the report.
How to validate:
1. Make the following changes in the Makefile of XV6: