代写 Task 1 (30 points)

Task 1 (30 points)
CSC3150 Assignment 1
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 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)
• The main flow chart for Task 1 is:

• Demo output for normal termination:
• Demo output for signaled abort:
• Demo output for stopped:

Task 2 (60 points)
In this task, a template (“program2.c”) is provided. Within the template, please implement the functions below:
• 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:
1) Use “_do_fork” to fork a new process. (/kernel/fork.c)
2) Use “do_execve” to execute the test program. (/fs/exec.c)
3) Use “getname” to get filename. (/fs/namei.c)
4) Use “do_wait” to wait for child process’ termination status. (/kernel/exit.c)
• The main flow chart for Task 2 is:

• Demo output:

Bonus Task (10 pionts)
In this task, you should create an executable file named “myfork” to implement the functions below:
• Execute “./myfork test_program” will show the signal message that child process executes test_program. (3 points)
• We can add multiple executable files as the argument of myfork, like “./myfork test_program1 test_program2 test_program3”. From second argument, the queue indicates the relationship of parent and child. The proceeding one is parent, and the tailing one is child. For example: test_program_1 is parent of test_program_2, and test_program_2 is the parent of test_program_3. (3 points)
• Print out a process tree, which can indicate the relationship of the test programs. For example: 1 -> 2 -> 3 (1/2/3 is the process ID) (4 points)
• Demo output

Report (10 points)
Write a report for your assignment, which should include main information as below:
• How did you design your program?
• The environment of running your program. (E.g., version of OS and kernel)
• The steps to execute your program.
• Screenshot of your program output.
• What did you learn from the tasks?

Submission
• Please submit the file as package with directory structure as below:  Assignment_1_Student ID.zip
– source
o program1
 program1.c  Makefile
 abort.c …
o program2
 program2.c
 Makefile
 test.c o bonus
 myfork.c  Makefile  abort.c …
– Report
• Due on: 23:59, 29 Sep 2019

Grading rules
Completion
Marks
Bonus
0 ~ 10 points
Report
10 points
Completed with good quality
80 ~ 90
Completed accurately
80 +
Fully Submitted (compile successfully)
60 +
Partial submitted
0 ~ 60
No submission
0
Late submission
Not allowed