CT104H – Operating System
CAN THO UNIVERSITY
COLLEGE OF INFORMATION AND COMMUNICATION TECHNOLOGY
DEPARTMENT OF INFORMATION TECHNOLOGY
OPERATING SYSTEMS (CT104H)
PROJECT
Declaration of own work
I, YOUR FULL NAME (ID student) , certify that this assignment is my own work, is not copied from
any other person's work.
Virtual machine: Ubuntu VM
Submission:
- A report describes clearly how did you solve problems
- All programs (in both kernel-level codes and user-level codes for testing) with comments (zip them in
a .RAR file)
PART 1: BUILD THE LINUX KERNEL
*** Note: At the first step, it will be better if you install an old version of OS kernel. Then, the process
of building a new Linux kernel will be clear
You need to be a root user (root user)
$su -
A. GET THE LINUX KERNEL CODE
1. Download and install development tools on your system.
$sudo apt-get install -y gcc libncurses5-dev make wget
$sudo apt-get install -y gcc libssl-dev
$sudo apt-get install bison
$sudo apt-get install flex
2. Obtain the version of your current kernel, type:
# uname –r
you will have something like: 4.4.0-31-generic (Ubuntu)
3. Visit http://kernel.org and download the source code of your current running kernel. Then, download a
new kernel from https://www.kernel.org/ (e.g., 4.16.3) and extract the source:
# wget http://www.kernel.org/pub/linux/kernel/v4.x/linux-4.16.3.tar.gz
# tar xvzf linux-4.16.3.tar.gz
Lecturer: Lam Nhut Khang
1
CT104H – Operating System
B. CONFIGURE YOUR NEW KERNEL
1. Make sure you are at ~/linux-4.16.3 such that the “linux-4.16.3” is the top directory of the kernel source.
2. Generate the configuration file
# make menuconfig
Do not change anything. Press ESC to save and exit the configuration menu. The configuration file will be
generated
C. COMPILE THE KERNEL
1. At ~/linux-4.16.3, create a compressed kernel image
# make –j4
2. To compile kernel modules:
# make modules
D. INSTALL THE KERNEL
1. Install kernel modules
# make modules_install
2. Install the kernel
# make install
E. MODIFY GRUB CONFIGURATION FILE (GRUB CONFIGURATION FILE)
Change the grub configuration file:
# vim /etc/default/grub
Make the following changes:
GRUB_DEFAULT=0
GRUB_TIMEOUT=25
F. REBOOT VM
1. Reboot to the new kernel
# reboot
2. After boot, check if you have the new kernel:
# uname -r
You will see something like: 4.16.3
Lecturer: Lam Nhut Khang
2
CT104H – Operating System
PART 2: ADD A NEW SYSTEM CALL INTO THE LINUX KERNEL
We add a simple system call helloworld to the Linux kernel. The system call prints out a “Hello! My name is
XXX” message to the syslog (XXX is your student name and your student ID). You need to implement the
system call in the kernel and write a program at the user-level to test your created system call.
These are very good articles to start:
- https://www.kernel.org/doc/html/v4.10/process/adding-syscalls.html
- https://brennan.io/2016/11/14/kernel-dev-ep3/
- https://medium.com/@ssreehari/implementing-a-system-call-in-linux-kernel-4-7-1-
6f98250a8c38
- https://medium.com/anubhav-shrimal/adding-a-hello-world-system-call-to-linux-kernel-
dad32875872
- https://linux.die.net/man/2/syscalls
PART 3: PROCESS
Write a program in C to create a parent process P1. The parent process P1 forks a child (named P2) and waits
for the child to complete the program multiplicationtable. The child process prints its pid, executes the
multiplicationtable program and then exits. The multiplicationtable gets an argument arg and prints the arg
times table. When P2 is finished, P1 prints the information of P2 including pid and the exit state, and then exits.
----------------------THE END ----------------------
Lecturer: Lam Nhut Khang
3