CSC3150-OS-AS1-2024
CSC3150 Assignment 1Homework Requirements Environment
WARNING!!! Before starting on this assignment, make sure you have set up your VMfollowing the instructions in tutorial 1 or meet the following conditions. We would test allstudents' homework using the following environment. For the programs unable to run onTA's environment, an offline meeting is a must.
- Linux Distribution
- Ubuntu 16.04-22.04
- Linux Kernel Version
- Target version: 5.10.x
- In the tutorials, we will cover installing a new version of the kernel, which follows the steps ofdownloading and compiling the source code and then loading the kernel modules into thesystem.
- GCC Version
- 4.9 above (use gcc -v 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 owncomputer to run).ubmission
- Due on: 23:59, 9 Oct 2024
Please note that, teaching assistants may ask you to explain the meaning of your program, toensure that the codes are indeed written by yourself. Please also note that we would checkwhether your program is too similar to your fellow students’ code using plagiarismdetectors.•
Late submission: A late submission within 15 minutes will not induce any penalty on yourgrades. But 00:16 am-1:00 am: Reduced by 10%; 1:01 am-2:00 am: Reduced by 20%; 2:01am-3:00 am: Reduced by 30% and so on. (e.g. Li Hua submit a perfect attemp of hw1 on2:10 am. He will get (100+10 (bonus))*0.7=77 points for his hw1.
Here is the format guide. The project structure is illustrated as below. You can also use treecommand to check if your structure is fine. Structure mismatch woulcausegrade deduction.main@ubuntu:~/Desktop/Assignment_1_122010001$ treePlease compress all files in the file structure root folder into a single zip file and name it usingyour student id as the code showing below and above, for example,
Assignment_1_122010001.zip. The report should be submitted in the format of pdf,together with your source code. Format mismatch would cause grade deduction. Here is thesample step for compress your code.
main@ubuntu:~/Desktop$ zip -q -r Assignment_1_122010001.zip
Assignment_1_12201000112Task 1 (30 points)
In this task, you should write a program ( program1.c ) that implement the functions below:In user mode, fork a child process to execute the test program. (10 points)
- When child process finish execution, the parent process wil 代 写CSC3150-OS-AS1 Requirements EnvironmentCSC3150-OS-AS1 Requirements Environment l receive the SIGCHLD signal bywait() function. (5 points)
- There are 15 test programs provided. 1 is for normal termination, and the rest are exceptioncases. Please use these test programs as your executing programs.
The termination information of child process should be print out. If normal termination, printnormal termination and exit status. If not, print out how did the child process terminates andwhat signal was raised in child process. (15 points)The main flow chart for Task 1 is:Demo outputs:Demo output for normal termination:main@ubuntu:~/Desktop/Assignment_1_example/source/program1$ ./program1 ./normalProcess start to fork
I'm the Parent Process, my pid = 4903
I'm the Child Process, my pid = 4904
Child process start to execute test program:
------------CHILD PROCESS START------------
This is the normal program
------------CHILD PROCESS END------------
Parent process receives SIGCHLD signal
Normal termination with EXIT STATUS =
Demo output for signaled abort:main@ubuntu:~/Desktop/Assignment_1_example/source/program1$ ./program1 ./abort
Process start to fork
I'm the Parent Process, my pid = 4908
I'm the Child Process, my pid = 4909
Child process start to execute test program:
------------CHILD PROCESS START------------
This is the SIGABRT program
Parent process receives SIGCHLD signal
child process get SIGABRT signal
Demo output for stopped:
main@ubuntu:~/Desktop/Assignment_1_example/source/program1$ ./program1 ./stop
Process start to fork
I'm the Parent Process, my pid = 4931
I'm the Child Process, my pid = 4932
Child process start to execute test program:
------------CHILD PROCESS START------------
This is the SIGSTOP programParent process receives SIGCHLD signal
hild process get SIGSTOP signaIn this task, a template (“program2.c”) is provided. Within the template, please implement thefunctions below:When program2.ko being initialized, create a kernel thread and run my_fork function. (10points)
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 shouldfirstly export this symbol sothat it could be used in your own kernel module. After that, youshould compile the kernel source code and install it. (Kernel compile: 15 points)
Hints:
Use “_do_fork” to fork a new process. (/kernel/fork.c)
Use “do_execve” to execute the test program. (/fs/exec.c)
◦se “getname” to get filename. (/fs/namei.c)
◦Use “do_wait” to wait for child process’ termination status. (/kernel/exit.c)
The main flow chart for Task 2 is:Demo output:[ 3769.385776] [program2] : module_init
[ 3769.385777] [program2] : module_init create kthread start
[ 3769.385777] [program2] : module_init kthread start[
- Hints: This reference(https://en.wikipedia.org/wiki/Procfs) might help you to finish theonus task.Report (10 points)
标签:fork,CSC3150,AS1,process,Environment,program,test,your,points From: https://www.cnblogs.com/comp9313/p/18450899