Sale!

CSC 3150 Assignment 1 solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (3 votes)

CSC3150 Assignment 1
Task 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 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 outputs:
Demo output for normal termination:
Demo output for hangup:
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:
main@ubuntu:~/Desktop/Assignment_1_example/source/program1$ ./program1
./normal
Process 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 receiving the SIGCHLD signal
Normal termination with EXIT STATUS = 0
main@ubuntu:~/Desktop/Assignment_1_example/source/program1$ ./program1
./hangup
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 SIGHUP program
Parent process receiving the SIGCHLD signal
child process get SIGHUP signal
child process is hung up
CHILD EXECUTION FAILED
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 program
Parent process receiveing the SIGCHLD signal
child prcess get SIGSTOP signal
child process stopped
CHILD PROCESS STOPPED
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)
All 15 signals from Tasks 1 should be tested again in Task 2.
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:
Use “_do_fork” to fork a new process. (/kernel/fork.c)
Use “do_execve” to execute the test program. (/fs/exec.c)
Use “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:
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:
[ 3769.385776] [program2] : module_init
[ 3769.385777] [program2] : module_init create kthread start
[ 3769.385777] [program2] : module_init kthread start
[ 3769.389787] [program2] : The child process has pid = 2914
[ 3769.389793] [program2] : This is the parent process, pid = 2912
[ 3769.391602] [program2] : child process
[ 3769.391604] [program2] : get SIGTERM signal
[ 3769.391605] [program2] : child process terminated
[ 3769.391605] [program2] : The return signal is 15
[ 3773.346070] [program2] : module_exit./my
main@ubuntu:~/Desktop/Assignment_1_117010033/source/bonus$ ./myfork hangup
normal8 alarm
————CHILD PROCESS START————
This is the SIGALRM program
This is normal8 program
————CHILD PROCESS START————
This is the SIGHUP program

Process tree: 5712->5713->5714->5715
Child process 5715 of parent process 5714 is terminated by signal 14 (Alarm
clock)
Child process 5714 of parent process 5713 terminated normally with exit code 0
Child process 5713 of parent process 5712 is terminated by signal 1 (Hangup)
Myfork process (5712) terminated normally
Completion Marks
Bonus 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
Your name and student id.
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?
Grading rules
Here is a sample grading scheme. Differ from the points specified above, this is the general guide
when TA’s grading.