Assignment 1 Solved

$24.99 $18.99

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…

Rate this product

You’ll get a: zip file solution

 

Description

Rate this product

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 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)

    1. Use “do_execve” to execute the test program. (/fs/exec.c)

    1. Use “getname” to get filename. (/fs/namei.c)

    1. 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:

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?

Submission Requirement

The report should be submitted in the format of pdf, together with your source code. Please compress all files into a single zip file and name it according to your student id. The project structure is illustrated as below:

    • Assignment_1_Student ID.zip

  • source

  1. program1

    • program1.c

    • Makefile

    • abort.c

  1. program2

    • program2.c

    • Makefile

    • test.c

      1. bonus

        • myfork.c

        • Makefile

        • abort.c

    • Report.pdf

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 too similar to your fellow students’ code using plagiarism detectors.

Violation against the format requirements will lead to grade deduction.

Due on: 23:59, 11 Oct 2020

Grading rules

Completion

Bonus

Report

Completed with good

quality

Completed accurately

Fully Submitted

(compile successfully)

Partial submitted

No submission

Late submission

Marks

0 ~ 10 points

  1. points

  1. ~ 90

  1. +

  1. +

0~60

0

Not allowed

Assignment 1 Solved
$24.99 $18.99