Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Nguyen Vo Thuan Thien (B2005893) : Part 1: Build The Linux Kernel (2.0 Points)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

CT104H – Operating System

CAN THO UNIVERSITY


COLLEGE OF INFORMATION AND COMMUNICATION TECHNOLOGY
OPERATING SYSTEMS (CT104H)
PROJECT

Declaration of own work


I, NGUYEN VO THUAN THIEN (B2005893), certify that this assignment is my own work, is not copied
from any other person's work.

Virtual machine: Ubuntu VM

Submission:
- A folder consists of all programs (in both kernel-level codes and user-level codes for testing) with
comments
- A report describes clearly how did you solve problems

PART 1: BUILD THE LINUX KERNEL (2.0 points)

*** Note: At the first step, it will be better if you install an old version of the OS kernel. Then, the
process of building a new Linux kernel will be clear

To become a root user, I use command sudo su

A. GET THE LINUX KERNEL CODE


1. Download and install development tools on your system.

In Ubuntu:
$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:


To obtain the version, I use the command # uname –r
CT104H – Operating System
My kernel version is 5.13.0-37-generic

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:

I download the newest stable version (up to 03/2022), which is linux-5.16.6:


# wget http://www.kernel.org/pub/linux/kernel/v4.x/linux-5.16.6.tar.gz
# tar xvzf linux-5.16.6.tar.gz

B. CONFIGURE YOUR NEW KERNEL


1. Make sure you are at ~/linux-5.16.6 such that the “linux-5.16.6” is the top directory of the kernel
source.
2. Generate the configuration file
# make menuconfig
We need to install the command ‘make’ before doing this, so I using the command apt-get install build-
essential to install make and all other packages needed to build my code
CT104H – Operating System

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
As far as I was running this command, i encountered a fatal error:

This error means that I have to install the libelf-dev in order to continue compressing the kernel image. So I
used the command: apt-get install libelf-dev
CT104H – Operating System
This is after I finish creating a compressed kernel image

2. To compile kernel modules:


# make modules
The compile kernel part took me a lot of effort to understand what my error was about. Turn out, the solution
is very simple.

This is my error. All I need to do is to disable 2 specific options in the kernel configuration. So I use the
commands: scripts/config –disable SYSTEM_TRUSTED_KEYS and scripts/config –disble
SYSTEM_REVOCATION_KEYS

D. INSTALL THE KERNEL


1. Install kernel modules
# make modules_install

Before install kernel modules, I will use # make bzImage to prevent unpredictable error
CT104H – Operating System

2. Install the kernel


# make install
CT104H – Operating System
Run # make before #make install

E. MODIFY GRUB CONFIGURATION FILE (GRUB CONFIGURATION FILE)


Change the grub configuration file:
# vim /etc/default/grub
CT104H – Operating System
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

PART 2: ADD A NEW SYSTEM CALL INTO THE LINUX KERNEL (2.0 points)

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.
CT104H – Operating System

PART 3: CPU SCHEDULING (3.0 points)


Write a program called IDcpuscheduling.c (ID is your student ID) to implement the CPU scheduling
algorithms (FCFS, SJF preemptive, Priority preemptive, and Round Robin). The program
IDcpuscheduling.c will take the parameters of n processes. Each scheduler will create a Gantt chart showing
the states of the processes in a string format, where R denotes the running state and W denotes the waiting
state. Finally, the program will calculate the average values of the waiting time, response time, and
turnaround time of each scheduler.

PART 4: MEMORY MANAGEMENT (3.0 points)


Write the program IDmemmanagement.c (ID is your student ID) that takes a parameter filename. In the file
filename contains a sequence of logical memory addresses. Each address is stored as 8 bytes (unsigned long
type). The program IDmemmanagement.c will read and translate each logical memory address in the file to
its corresponding physical address, and print them to the screen.

----------------------THE END ----------------------

You might also like