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: Multi-Process Calculator
Congratulations on reaching the 7th 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 real-world 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:
1. 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.
2. 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.
3. Use SIGUSR1 for addition, SIGUSR2 for subtraction, and SIGCHLD for multiplication.
Skeleton Code:
Here's a skeletion code to help you get started:
```
Hinergata CxtEELa-in:
|xn=1ata Cxtal1is.n3
tinelaste Sandxtad. ns \
tsme1gata cxtgmne1.n*)
tsn=1gatn cxyy/yant_ns)
```
detipetran
```
wrald matbop_ evisa [{nt {nalmx);
mold perant procarx [pla t en11d plata[]);
```
```
Ant mastan {
```
```
77 rago: Cragen ginat fax mach entrg
```
```
sat\arn [7
3
rolal mattop_ens.1a[[{nt inalnx) i
/// rege: Gnt un ximgat handtar
I/ raOQ: clema unumed mina anda
```
```
3
wald parant_prodaxx [p1a_t eh11a_padx []) i]
/// range: Rmad ingue Sxas uxmx
```
```
77 ragos gigmal ehtld to senforn enleulntien
``````
3
walla hnme11_xAgne1[{nt xAgmon){
```
```
3
```
Sample Input/Output: The enild paoeaxa with DID: 1234 will prowtda tha ramalt.
Ramalt: 13\(\qquad \) The elilid proesex whth DID: 123 will proutde the ramalt. \(\qquad \) Ramalts 13 The ex11d proesux whth DIT: 1230 will pxovide the momalt.
Ramalts 48
Hints:
- Use p-pe(1) to create pipes for each child process.
- Use a gnas (3) to set up signal handiers in child procesocs.
- Use ka11() 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 (1) 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 inter-peocess communication.
Challenge Task: Multi - Process Calculator

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!