Question: Challenge Task: Multi - Process Calculator Congratulations on reaching the 7 th week of the semester! You've grown significantly in your understanding of operating systems
Challenge Task: MultiProcess Calculator
Congratulations on reaching the th week of the semester! You've grown significantly in your understanding of operating systems concepts. Now it's time to flex those knowledge muscles and tackle a realworld challenge. Are you ready to put your skills to the test and create a multiprocess calculator? This task will bring together everything you've learned so far about process creation, signals, and pipes. Don't worry if it seems daunting at first remember, every great programmer started with small steps. Let's dive in and show what you can do
Task Overview:
Create a program that implements a simple calculator using multiple processes and IPC mechanisms. The program should have a main process that forks three child processes, each responsible for a different operation: addition, subtraction, and multiplication.
Requirements:
The main process should:
Fork three child processes.
Read two integers and an operation from the user.
Send the two integers to the appropriate child process using pipes.
Use signals to notify the child process to perform the calculation.
Receive and display the result from the child process.
Each child process should:
Set up a signal handler to know when to perform the calculation.
Read the two integers from its pipe. a Perform the calculation when signaled.
a Send the result back to the parent through another pipe.
Use SIGUSR for addition, SIGUSR for subtraction, and SIGCHLD for multiplication.
Skeleton Code:
Here's a skeletion code to help you get started:
Hinergata CxtEELain:
xnata Cxtalisn
tinelaste Sandxtad. ns
tsmegata cxtgmnen
tsngatn cxyyyantns
detipetran
wrald matbop evisa nt nalmx;
mold perant procarx pla t end plata;
Ant mastan
rago: Cragen ginat fax mach entrg
satarn
rolal mattopensant inalnx i
rege: Gnt un ximgat handtar
I raOQ: clema unumed mina anda
wald parantprodaxx pat ehapadx i
range: Rmad ingue Sxas uxmx
ragos gigmal ehtld to senforn enleulntien
walla hnmexAgnent xAgmon
Sample InputOutput: The enild paoeaxa with DID: will prowtda tha ramalt.
Ramalt: qquad The elilid proesex whth DID: will proutde the ramalt. qquad Ramalts The exd proesux whth DIT: will pxovide the momalt.
Ramalts
Hints:
Use ppe to create pipes for each child process.
Use a gnas to set up signal handiers in child procesocs.
Use ka in the parent process to send signals to children.
Remember to close unused pipe ends in both parent and child processes.
Use zasa and wate for pipe communication.
Good luck! This challenge will test your understanding of both signals and pipes, as well as how they can be used together for comples interpeocess communication.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
