Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

COMP XXXXXXXXXXTutorial 10 Specification COMP 2401 − "Introduction to Systems Programming" Tutorial XXXXXXXXXXProcesses and Threads Tutorial 10 Processes and Threads Learning Objectives After...

1 answer below »
COMP XXXXXXXXXXTutorial 10 Specification
COMP 2401 − "Introduction to Systems Programming"
Tutorial XXXXXXXXXXProcesses and Threads
Tutorial 10
Processes and Threads
Learning Objectives
After this tutorial, you will be able to:
● Use fork to create child processes
● Use threads to distribute computationally intensive operations
Tutorial
This week’s tutorial will modify the send / handle program from last week so that it becomes a parent / child process with
the parent sending signals to the child.
In order to receive full marks, you must complete everything in both of the following tutorial sections.
Tutorial - Forking
1. Download the T10.tgz from the tutorial module on Brightspace. Extract and read through the tutorial files.
2. Write a program in t10-fork.c which creates a new process in main() using the fork system call. Using the
eturn value from fork(), print out whether the process is the child or the parent.
3. Add signal handlers to only the child process so that it prints to stdout when it receives SIGUSR1, SIGUSR2, o
SIGINT. The child should then wait until receiving SIGINT before terminating.
Hint: The child’s code should look very similar to the code for handle from Tutorial 9.
4. Add code for (only) the parent process so that it prompts the user to choose which signal to send to the child, then
send it. The process should terminate once it has sent a SIGINT to the child process.
Tutorial - Threading
5. Speed up t10-threads by using multiple threads to determine if the ten numbers are prime. You should not
make any changes to the prime() function itself.
COMP 2401 Tutorial #10 1
COMP 2401 − "Introduction to Systems Programming"
Tutorial XXXXXXXXXXProcesses and Threads
Saving and Submission
In-Person Attendance: Submission is optional, as you can be checked off in class, but you must still complete the
equired portion of the tutorial for marks.
Asynchronous: If you are completing the work on your own at home, make sure to follow the submission requirements.
1. Create an archive to submit your files, and include all of the files that you worked with in the tutorial.
a. They may be submitted as a .tar, .tar.gz, bz2, or .tgz file
. Make sure to include all of the code needed to run your program
2. For full marks you should have completed all problems in the Tutorial section (and they should be seen upon
unning the program).
3. For part-marks you should have attempted to complete most of the tutorial. Grades for part-marks will be at TA
discretion.
COMP 2401 Tutorial #10 2

COMP XXXXXXXXXXTutorial 9 Specification
COMP 2401 − "Introduction to Systems Programming"
Tutorial 9 - Signals
Tutorial 9
Signals
Learning Objectives
After this tutorial, you will be able to:
● Write and use a Makefile
● Use signals to communicate between processes. Specifically:
○ Send a signal to a process
○ Install signal handlers in a process to catch incoming signals
Tutorial
In order to receive full marks, you must complete everything in this tutorial section. There are no extra exercises this
week. You will be modifying this week’s code in next week’s tutorial.
1. Download the file T09.zip from the tutorial module on Brightspace. Extract and read through the tutorial files.
There is also a zip (unzip) tool in Linux. Read the man page for the zip tool to see how to unzip the tutorial files.
2. Create a Makefile to compile send.c and handle.c with targets send and handle. Make send and handle.
3. Run handle in the background, you should see something like:
$ ./handle &
[1] 2329
Where 2329 is an example of a process ID. In this case, the ID of the running handle process is 2329, but it will
e different for your process.
4. Run send, enter the PID of the handle process, and enter 1, 2, then 0.
5. Run ps to list the cu
ent running processes. Why is handle still running? Kill it.
$ kill 2329
Run ps to check that the process has terminated.
6. Modify send.c so that when the user chooses 0, a signal (SIGINT) is sent to the process pid.
7. Make send and re-run handle (again in the background), run send and enter 0. Run ps to verify that handle is
not still running.
Note: If you have completed this tutorial early, Tutorial 10 - Processes and Threads, has been released in advance
so that you can continue working with this material. You will need the files from this tutorial for T10.
COMP 2401 Tutorial #9 1
COMP 2401 − "Introduction to Systems Programming"
Tutorial 9 - Signals
Saving and Submission
In-Person Attendance: Submission is optional, as you can be checked off in class, but you must still complete the
equired portion of the tutorial for marks.
Asynchronous: If you are completing the work on your own at home, make sure to follow the submission requirements.
1. Create an archive to submit your files, and include all of the files that you worked with in the tutorial.
a. They may be submitted as a .tar, .tar.gz, bz2, or .tgz file
. Make sure to include all of the code needed to run your program
2. For full marks you should have completed all problems in the Tutorial section (and they should be seen upon
unning the program).
3. For part-marks you should have attempted to complete most of the tutorial. Grades for part-marks will be at TA
discretion.
COMP 2401 Tutorial #9 2
Answered Same Day Dec 06, 2022

Solution

Nidhi answered on Dec 07 2022
45 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here