Question
Example inputs and outpus queue D 0 1 4 2 -1 2 4 3 2 Parent, pid 12345: debug mode Child 1, pid 12346: 4
Example inputs and outpus
queue D 0 1 4 2 -1 2 4 3 2 |
Parent, pid 12345: debug mode Child 1, pid 12346: 4 customers arriving at 0 1 5 7 Child 1, pid 12346: 4 customers requiring service for 2 4 3 2 Child 1, pid 12346: time 0 customer 1 arrives, customer 1 waits for 0, queue length 0 Child 1, pid 12346: time 1 customer 2 arrives, queue length 1 Child 1, pid 12346: time 2 customer 1 departs, customer 2 waits for 1, queue length 0 # just for debugging, no need for output: Child 1, pid 12346: time 3 queue length 0 # just for debugging, no need for output: Child 1, pid 12346: time 4 queue length 0 Child 1, pid 12346: time 5 customer 3 arrives, queue length 1 Child 1, pid 12346: time 6 customer 2 departs, customer 3 waits for 1, queue length 0 Child 1, pid 12346: time 7 customer 4 arrives, queue length 1 # just for debugging, no need for output: Child 1, pid 12346: time 8 queue length 1 Child 1, pid 12346: time 9 customer 3 departs, customer 4 waits for 2, queue length 0 # just for debugging, no need for output: Child 1, pid 12346: time 10 queue length 0 Child 1, pid 12346: time 11 customer 4 departs, queue length 0 Child 1, pid 12346: all customers served at time 11 Child 1, pid 12346: maximum queue length 1 Child 1, pid 12346: average queue length 0.364 Child 1, pid 12346: total waiting time 4 Child 1, pid 12346: average waiting time 1.000 Child 1, pid 12346: child 1 completed execution Parent, pid 12345: child 1 completed execution |
queue D 0 1 4 2 3 1 2 3 -1 2 4 3 2 6 3 5 1 |
Parent, pid 12348: debug mode Child 1, pid 12349: 8 customers arriving at 0 1 5 7 10 11 13 16 Child 1, pid 12349: 8 customers requiring service for 2 4 3 2 6 3 5 1 Child 1, pid 12349: time 0 customer 1 arrives, customer 1 waits for 0, queue length 0 Child 1, pid 12349: time 1 customer 2 arrives, queue length 1 Child 1, pid 12349: time 2 customer 1 departs, customer 2 waits for 1, queue length 0 Child 1, pid 12349: time 5 customer 3 arrives, queue length 1 Child 1, pid 12349: time 6 customer 2 departs, customer 3 waits for 1, queue length 0 Child 1, pid 12349: time 7 customer 4 arrives, queue length 1 Child 1, pid 12349: time 9 customer 3 departs, customer 4 waits for 2, queue length 0 Child 1, pid 12349: time 10 customer 5 arrives, queue length 1 Child 1, pid 12349: time 11 customer 4 departs, customer 6 arrives, customer 5 waits for 1, queue length 1 Child 1, pid 12349: time 13 customer 7 arrives, queue length 2 Child 1, pid 12349: time 16 customer 8 arrives, queue length 3 Child 1, pid 12349: time 17 customer 5 departs, customer 6 waits for 6, queue length 2 Child 1, pid 12349: time 20 customer 6 departs, customer 7 waits for 7, queue length 1 Child 1, pid 12349: time 25 customer 7 departs, customer 8 waits for 9, queue length 0 Child 1, pid 12349: time 26 customer 8 departs, queue length 0 Child 1, pid 12349: all customers served at time 26 Child 1, pid 12349: maximum queue length 3 Child 1, pid 12349: average queue length 1.038 Child 1, pid 12349: total waiting time 27 Child 1, pid 12349: average waiting time 3.375 Child 1, pid 12349: child 1 completed execution Parent, pid 12348: child 1 completed execution |
queue D 0 1 2 3 2 4 3 2 -1 1 4 1 1 2 4 2 1 |
Parent, pid 12355: debug mode Child 1, pid 12356: 8 customers arriving at 0 1 3 6 8 12 15 17 Child 1, pid 12356: 8 customers requiring service for 1 4 1 1 2 4 2 1 Child 1, pid 12356: time 0 customer 1 arrives, customer 1 waits for 0, queue length 0 Child 1, pid 12356: time 1 customer 1 departs, customer 2 arrives, customer 2 waits for 0, queue length 0 Child 1, pid 12356: time 3 customer 3 arrives, queue length 1 Child 1, pid 12356: time 5 customer 2 departs, customer 3 waits for 2, queue length 0 Child 1, pid 12356: time 6 customer 3 departs, customer 4 arrives, customer 4 waits for 0, queue length 0 Child 1, pid 12356: time 7 customer 4 departs, queue length 0 Child 1, pid 12356: time 8 customer 5 arrives, customer 5 waits for 0, queue length 0 Child 1, pid 12356: time 10 customer 5 departs, queue length 0 Child 1, pid 12356: time 12 customer 6 arrives, customer 6 waits for 0, queue length 0 Child 1, pid 12356: time 15 customer 7 arrives, queue length 1 Child 1, pid 12356: time 16 customer 6 departs, customer 7 waits for 1, queue length 0 Child 1, pid 12356: time 17 customer 8 arrives, queue length 1 Child 1, pid 12356: time 18 customer 7 departs, customer 8 waits for 1, queue length 0 Child 1, pid 12356: time 19 customer 8 departs, queue length 0 Child 1, pid 12356: all customers served at time 19 Child 1, pid 12356: maximum queue length 1 Child 1, pid 12356: average queue length 0.211 Child 1, pid 12356: total waiting time 4 Child 1, pid 12356: average waiting time 0.500 Child 1, pid 12356: child 1 completed execution Parent, pid 12355: child 1 completed execution |
D in the input indicate the program is in debug mode, the -1 indicate theend of arriving time of the customer. The value follow -1 is the requiring service time. Only 1 child process needs to be created. The first customer is arrive at time 0.
Please write the program in C language and use the function fork(). here the child should be able to extract its own part of the input data knowing its position from the argument list or from any stored array before fork() is executed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started