Assignment #2: Implementing a new system call
Implement a new system call named getmemutil()
whose system call number is 491. It returns an integer value n
ranging from 0 to 10000 where n/100.0
represents the (physical) memory utilization in percentage.
The current memory usage information is already available via the special file /proc/meminfo
. Using that information, you can compute the memory utilization as 1 - (the total amount of free memory / the total amount of memory)
. For more information on the /proc/meminfo
, please refer to the kernel document in ./Documentation/filesystems/proc.rst
. You may find the relevant code in the ./fs/proc/meminfo.c
file useful during the implementation of the getmemutil()
system call.
Also, you need to write a user-level program that prints the memory utilization every second by calling the getcmemutil()
system call. Then, run an application of your choice (e.g., Firefox, Redis, RocksDB, or other memory-intensive application) along with the above program to obtain a graph that shows the variation in the memory utilization. Please attach the graph in your report with the explanation on your getmemutil()
implementation.
- Due: 11:55PM, April 2nd.
- Submission: Upload your gzipped kernel patch file and your report file (in PDF) here
How to prepare your compressed patch file
You can prepare a compressed patch file as follows. Assume that the vanilla 6.1.14 kernel is in the ./linux-6.1.14-vanilla
directory, while your modified kernel is in the ./linux-6.1.14
directory.
$ (cd linux-6.1.14-vanilla; make distclean)
$ (cd linux-6.1.14; make distclean)
$ diff -uprN linux-6.1.14-vanilla linux-6.1.14 > studentID.patch
$ gzip studentID.patch
Please double-check your patch file whether it contains some unnecessary materials. Also, please make sure that you should build your kernel with the default Ubuntu kernel configuration.
For more details on generating a patch file, please refer to here.
Assignment #1: Modifying Linux Kernel
Setup your Ubuntu environment in your own machine or in the Virtual Machine, and replace its kernel with the latest longterm support version of the Linux kernel, 6.1.14. You need to submit the screenshots of the booting message where you print your student ID and name, and also the result of the cat /proc/version
command.
- Due: 11:55PM, March 19th.
- Submission: Upload your PDF file here
How to setup your Linux kernel
Install the latest VirtualBox 7.0.6 from https://virtualbox.org on your
x86_64
machineDownload the Ubuntu Desktop 22.04 LTS Desktop version here and install it in your VirtualBox.
Download the reference Linux kernel 6.1.14 as follows:
$ wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.1.14.tar.xz $ tar xvf linux-6.1.14.tar.xz
Install prerequisite packages for kernel compiling
$ sudo apt install build-essential ncurses-dev libssl-dev flex bison libelf-dev zstd dwarves
Configure the new kernel using Ubuntu kernel’s
config
file$ cd linux-6.1.14 $ cp /boot/config-$(uname -r) .config $ scripts/config --disable SYSTEM_TRUSTED_KEYS $ scripts/config --disable SYSTEM_REVOCATION_KEYS
Compile the Linux kernel
$ make all -j n (replace n with the number of cores)
$ sudo make INSTALL_MOD_STRIP=1 modules_install
$ sudo make install
FYI: The tutorial video is available at https://youtube.com/c/openssds
How to submit your screenshots
Modify the Linux kernel to print your student ID and name in the middle of booting message and take a screenshot during booting. Please be creative when you print your name.
After the booting, please execute the following command and take a screenshot of its output.
$ cat /proc/version
Paste those two screenshots into a word file or a powerpoint file, and upload the file using the Google Form.
Reference Platform
The following shows the reference platform used in this course.