Project Spring2023 Eng FINAL SV

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

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 (DON’T
ZIP the files)

PART 1 (2.0 points): 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


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


CT104H – Operating System

PART 2 (1.5 points): 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-6f98250a8c3
8
- https://medium.com/anubhav-shrimal/adding-a-hello-world-system-call-to-linux-kernel-dad3287
5872
- https://linux.die.net/man/2/syscalls

PART 3 (1.5 points): PRINT OUT THE CALLING PROCESS’S INFORMATION

Implement a print_self system call such that this system call will identify the calling process at the user-level
and print out the Process id, running state, and program name.
HINT: https://linuxgazette.net/133/saha.html

PART 4 (3.0 points): CPU SCHEDULING


Write a program called IDcpuscheduling.c (ID is your student ID) to implement the CPU scheduling
algorithms: FCFS, SJF-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.
Problem description: the program will take the number of processes n. Then, the program will allow users
to input (n x 2)+1 parameters:
q x1 y1 x2 y2 …. xi yi …xn yn
where q is the quantum value of the Round Robin algorithm, xi and yi are the arrival time and burst time of
the process i.
Output format: For each scheduler, the program will have the following lines:
- A line “*************** XXX SCHEDULER *****************” to separate schedulers (XXX
is the name of the scheduler).
- Each process will have a line of states. For example: RRRRRWWRRRR
- The last line of each scheduler presents the average values of the waiting time (AVGW), respond time
(AVGR) and turnaround time (AVGT).

Example: the number of processes provided by a user is n=3. Then, the user provides parameters of
processes as 1 0 2 1 3 2 2. The output of the program will be as following:

Lecturer: Lam Nhut Khang


CT104H – Operating System

************* FCFS SCHEDULER ******************* 


RR------ 
-WRRR-- 
--WWWRR 
AVGW= 1.33 AVGR=1.33 AVGT=3.66 
************** SJF PREEMPTIVE SCHEDULER ****************** 
………..

PART 5 (2.0 point): 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

You might also like