Question: To develop a better sense of how an operating system works, you will also do a few projects inside a real OS kernel. The kernel
To develop a better sense of how an operating system works, you will also do a few projects inside a real OS kernel. The kernel we'll be using is a port of the original Unix version and is runnable on modern x processors. It was developed at MIT and is a small and relatively understandable OS and thus an excellent focus for simple projects.
This first project is just a warmup, and thus relatively light on work. The goal of the project is simple: to add a system call to xv Your system call, getreadcount simply returns how many times that the read system call has been called by user processes since the time that the kernel was booted.
Background
If you haven't watched the discussion video, you might want to read this background section.
More information about xv including a very useful book written by the MIT folks who built xv is available here. Do note, however, that we use a slightly older version of xvfor various pedagogical reasons and thus the book may not match our code base exactly.
Your System Call
Your new system call should look have the following return codes and parameters:
int getreadcountvoid
Your system call returns the value of a counter perhaps called readcount or something like that which is incremented every time any process calls the read system call. That's it
Tips
Watch this discussion video it contains a detailed walkthrough of all the things you need to know to unpack xv build it and modify it to make this project successful.
One good way to start hacking inside a large code base is to find something similar to what you want to do and to carefully copymodify that. Here, you should find some other system call, like getpidor any other simple call Copy it in all the ways you think are needed, and then modify it to do what you need.
Most of the time will be spent on understanding the code. There shouldn't be a whole lot of code added.
Using gdb the debugger may be helpful in understanding code, doing code traces, and is helpful for later projects too. Get familiar with this fine tool!
Running Tests
Running tests for your system call is easy. Just do the following from inside the initialxv directory:
prompttestgetreadcounts.sh
If you implemented things correctly, you should get some notification that the tests passed. If not
The tests assume that xv source code is found in the src subdirectory. If it's not there, the script will complain.
The test script does a onetime clean build of your xv source code using a newly generated makefile called Makefile.test. You can use this when debugging assuming you ever make mistakes, that is eg:
prompt cd src prompt make f Makefile.test qemunox
You can suppress the repeated building of xv in the tests with the s flag. This should make repeated testing faster:
prompttestgetreadcounts.sh s
The other usual testing flags are also available.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
