(Solved) : Painting Shop Boxes Painted Assume Box Painted One Color Boxes Size Changing Colors Painti Q38174904 . . .
In a painting shop, boxes are being painted. Assume that eachbox is painted only in one color and that all boxes are of the samesize. Changing colors in the painting process is expensive due tothe added cost of wasted paint and solvents involved with eachcolor change in addition to the extra time required for thechanging process. Therefore, the objective is to order the boxes ina way to minimize the number of paint changeovers.
When boxes arrive at the painting shop, they are placed in a linebased on the time of their arrival, until it is their turn to bepainted. Painting starts only after all boxes have arrived and havebeen stored in the storage area. The box painting unit has acapacity of two, which means that two boxes of the same color canbe painted at the same time. In order to minimize the number ofpaint changeovers, when a painting resource becomes available, abox having the same color as the previous boxes has to be painted.Boxes of the same color are painted as first-come-first-serve basedon the order of their arrival. After both painting stations(resources) become empty, if there are no boxes of the same color,then a new box with another color should be painted. You can choosethis box color using a first-come-first-serve approach based on theorder of their arrival. Use the following values to simulate thetime a box occupies a painting resource:
Red: 1 second, Green: 2 seconds, Blue: 2 seconds, Yellow: 1 second,Purple: 1 second, Orange: 2 seconds
Program implementation: 1.Write a program in C to implement theabove simulation. 2.You should use semaphores and shared memorywhere necessary for IPC. You should NOT use signals forsynchronization. 3. Each box should be modeled as a separateprocess. No threads will be used. 4. A process (parent) creates allthe required resources and IPC primitives, prepares an arrayshowing the color for each box in a shared memory location andcreates the box processes using the fork system call.
5. At the end, after all boxes have been painted, the parentprocess removes all resources and IPC primitives. 6. The parentprocess reads the sequence of box colors from an input file inFile.The first line of the input file shows the total number of boxes tobe painted. Each line after this, contains one color code, showingthe color of the corresponding box. 7. Each box process will readits color from the array implemented on a shared memory, createdand filled in by the parent process. The index of the box processwill be the index with which it was created by the parent process.The color code on the array can be one of the following. R: red, G:green, B: blue, Y: yellow, P: purple, O: orange. You can assumethat the colors are provided correctly. No error checking isrequired. 8. Your program should output the results to an outputfile outFile. The first line of the output file will show the totalnumber of paint color changes and the remaining lines will show thenumbers and colors of the boxes in the order in which they havebeen painted. There should be one entry on each line. The pid ofthe corresponding process can be used as the box number.
Test: Your program will be tested in the form: ./program.exe
Please test and make sure to achieve expected results.
This means that 12 boxes will be painted. The first and secondboxes will be painted red, the third box will be painted green,etc
This means that the color has been changed 6 times, includingthe first time a color was loaded and the rest of the file showsthe order in which the boxes were painted
Example: inFile: 12 outFile: (It is assumed that the box processes are numbered consecutively starting from 100) 100 R 101 R 102 G 104 G 103 B 105 B 106 0 108 O 109 O 107 Y 110 P Show transcribed image text
Expert Answer
Answer to Painting Shop Boxes Painted Assume Box Painted One Color Boxes Size Changing Colors Painti Q38174904 . . .
OR