CSC3150 Assignment 1
CSC3150 Assignment 1
Homework Requirements
Please note all bold fonts!!!!!!!!!
Environment
WARNING!!! Before starting this assignment, make sure you have set up your VM properly. We would
test all students' homework using the following environment. You can type the following command in
terminal on your VM to see whether your configuration matches the test environment. If not, you can
still continue, but please try to test your program with the following environment at least once.
Because you may be able to run your program on your environment, but not on TAs' environment,
causing inconvenience or even grade deduction.
If you follow the tutorials guidance, your VM setting should be fine. However, we also highly
recommend you to verify your environment again.
Linux Kernel Version: 5.10.x (Test Environment) (use uname -r to get it)
Makefile: Please write makefile to compile and install your program in this course. So please learn
how to write makefile. We only use makefile to test your program when we grade (If not used, this
program will have a score of 0, and it is not acceptable to use your own computer to run).
Code Style: Please use clang-format to format your code before submitting. (-10 points if not)
Submission
Due on: 23:59, 10 Oct 2022 (no late submission for any reason)
Please note that, teaching assistants may ask you to explain the meaning of your program, to ensure
that the codes are indeed written by yourself. Please also note that we would check whether your
program is similar to your peers’ code using plagiarism detectors.
Violation against the format requirements will lead to grade deduction.
Here is the format guide. The project structure is illustrated as below. You can also use tree command to
check whether your structure is fine. Structure mismatch would lead to grade deduction.
main@ubuntu:~/Desktop/Assignment_1_<student_id>$ tree
.
├── report.pdf
└── source
├── bonus
│ ├── Makefile
│ ├── pstree.c
│ └── <other_files>
├── program1
│ ├── abort.c
│ ├── alarm.c
│ ├── bus.c
│ ├── floating.c
│ ├── hangup.c
│ ├── illegal_instr.c
│ ├── interrupt.c
│ ├── kill.c
│ ├── Makefile
│ ├── normal.c
│ ├── pipe.c
│ ├── program1.c
│ ├── quit.c
│ ├── segment_fault.c
│ ├── stop.c
│ ├── terminate.c
│ └── trap.c
└── program2
├── Makefile
├── program2.c
└── test.c
Please compress all files in the file structure root folder into a single zip file and name it using your
student id as the code showing below, for example, Assignment_1_118010001.zip. The report should
be submitted in the format of pdf, together with your source code. Format mismatch would cause grade
deduction(5 points deducted). Here is the sample step to compress your code.
In user mode, fork a child process to execute the test program. (10 points)
When child process finish execution, the parent process will receive the SIGCHLD signal by wait()
function. (5 points)
There are 15 test programs provided. 1 is for normal termination, and the rest are exception cases.
Please use these test programs as your executing programs.
The termination information of child process should be print out. If normal termination, print normal
termination and exit status. If not, print out how did the child process terminates and what signal was
raised in child process. (15 points)
When program2.ko being initialized, create a kernel thread and run my_fork function. (10 points)
Within my_fork, fork a process to execute the test program. (10 points)
The parent process will wait until child process terminates. (10 points)
Print out the process id for both parent and child process. (5 points)
Within this test program, it will raise signal. The signal could be caught and related message should be
printed out in kernel log. (10 points)
Follow the hints below to implement your function. If the function is non-static, you should firstly
export this symbol so that it could be used in your own kernel module. After that, you should compile
the kernel source code and install it. (Kernel compile: 15 points)
Hints:
Demo output(Please output your name and student id when module init):
❯ pstree
systemd─┬─NetworkManager───2*[{NetworkManager}]
├─abrt-watch-log
├─abrtd
├─agetty
├─atd
├─auditd───{auditd}
├─blackbox_export─┬─run_blackbox_ex───tee
│ └─75*[{blackbox_export}]
In this task, we need to create a file to implement this function and the file name is pstree.c . There are
many options of pstree . You can use man pstree to discover it. Before implementing this program, I
suggest that use this command by yourself to see how it works.
Please note that the report will only be graded if your total score for Task 1 and Task 2 exceeds 54
points.
Grading rules
Here is a sample grading scheme. Different from the points specified above, this is the general guide when
TA's grading.
Completion Marks
Bonus 10 Points
Report 10 Points
Completed accurately 80 +
Partial submitted 0 ~ 60
No submission 0
References
https://www.gnu.org/software/libc/manual/html_node/Process-Identification.html
https://elixir.bootlin.com/linux/v5.10/source (This one can help you to search symbols in the kernel.)
https://seisman.github.io/how-to-write-makefile/ (Chinese)
https://makefiletutorial.com/