Menu

[Solved]Think Primitive Bag Handling Belt Conveyor System Bags Move Conveyor Belt Three Different Q37231525

Think about a primitive Bag Handling Belt Conveyor system. Bags move in a Conveyor belt in three different sizes (Large, MediTwo threads done. Main is now printing... Producer Started with TID 912 Consuner Started with TID 230912 Produc i ng : L Prodcommodities.dat X MLmMMLSMSMMSmLLMSMLLmMMMSLLMMBLMmLSSLMmMMSSBmBBLSLLSMSMLBmMmD 2

Think about a primitive Bag Handling Belt Conveyor system. Bags move in a Conveyor belt in three different sizes (Large, Medium and Small). There are miscellaneous items also. All miscellaneous items can be considered as one type The worker on the right picks up bags and miscellaneous items one by one and place it in the shared location. The second worker to the left picks up bags, boxes and miscellaneous items one by one and arrange them in to shelves while keeping a count of each item type Large Bags Count Medium Bags Count Small Bags Count Bags (Large. Medium, Small) Boxed and Miscellaneous Items Moving on a Convoy Belt Shared This worker will take bags from shared location stack them on appropriate shelves and keep a count on each type. This worker will take bags from the Micelaneous tems Clonation stask hemoond th places them on the shared location Write a C/C++ multi-threaded application to simulate the above scenario. You can consider the worker to the right as the producer and the worker to the left as the consumer. Program must adhere to the following. a. Main program create and invokes two threads namely the producer and the consumer b. Producer opens and reads a text file (representing the commodities on the belt) character by character and put each character into a global character memory location. When each time the producer reads a character and then puts to the global location, we consider an item is ‘produced’. The file contains a text string like this LMLmMMLSMSMMSmLLMSMLLmMMMSLLMMBLMmLSSLMmMMSSBmBBLSLLSMSMLBmMmD S Small bag D Done (end of items) Large Bag m Miscellaneous Item M Medium Bag B Box The last character written to the shared location is the character ‘D’ (Done) indicating the end of items on the belt. Then the Producer closes the file. Producer completes. c. Consumer on the other end reads the character in the shared location (we consider the value in the shared location is consumed), and increments globally defined counts depending on the bag type, a box or miscellaneous items received. Then we assume the picked up item is put into a proper shelf. When the last character “D’ is consumed, the Consumer completes. d. The main program who created and invoked the two threads (Producer and Consumer) will wait until the two threads complete their jobs and then prints the Bag Counts as follows: Two threads done. Main is now printing… Producer Started with TID 912 Consuner Started with TID 230912 Produc i ng : L Producing: M Producing: L Producing: m Producing: M Producing: M Items Produced and Consumed Large Bags Medium Bags Small Bags Boxes Misce11aneous Items: 8 Total Items Consuming: Consuming: M Consuming Consuming: M Consuming: M Consuming: L Consuming: s Consuming: M Consuming: s Consuming: M Consuming Consuming: s Producing: S Producing: M e. You must simulate this scenario in a way that the program willProducing: s Producing: M Producing: S run at least for a minute and at most for 2 minutes. Use the sleep() and/or usleep() system calls to control the execution speed of the application. Producing Producing: L Producing: L Consuming: L Consuming: M Consuming: s Consuming: M Consuming: L Consuming: L Consuming: f. Read the file character by character. NO BUFFERED READING.producing: s Producing: L Producing: L Producing: m Producing: M Producing: M Producing: M Producing: S Producing: L Producing: L Producing: M Producing: M Producing: B Producing: L Producing: M Producing: m Producing: L Producing: S Producing: s Producing: L Producing: M Producing: m Producing: M Producing: M Producing: S Producing: S Producing: B g. Use proper Mutexes in both the threads. h. Create two threads. Make sure to join the two threads. I. Use proper system calls. You are free to use system calls you Consuming: M Consuming: M Consuming: s Consuming: L Consuming: L Consuming: M Consuming: M Consuming Consuming: L have learnt in class and/or any other To the right is a screen dump of an actual run. Consuming: m Consuming: L Consuming: S Consuming: s Consuming: L Consuming: M Consuming: n Consuming Note: IF YOU NEED FULL CREDIT, YOU MUST STRICTLY USE PROPER SYSTEM CALLS IN YOUR CODE AND MUST ADHERE TO THE STEPS DESCRIBED IN THIS DOCUMENT INCLUDING MATCHING THE OUTPUT SHOWN TO THE RIGHT. IF YOU DO NOT USE SYSTEM CALLS AND TIMING AND STILL PRODUCE AN OUTPUT TO MATCH THE GIVAN OUTPUT YOU GET ONLY 30% OF THE GRADE. Consuming: S Consuming: s Consuming: B Consuming: m Consuming: B Consuming: B Consuming: L Consuming: s Consuming 1 Producing: B Producing: B Producing: L Producing: s Consuming: S Consuming: M Consuming: s Consuming: M Consuming: L Consuming: B Consuming: n Consuming Producing: S Producing: M Producing: S Producing: L Producing: B Producing: m Producing: M Producing: m Producing: D Consuming: D Two threads done. Main is now printing Itens Produced and Consumed Large Bags Small Bags Miscellaneous Items: 8 Total Items commodities.dat X MLmMMLSMSMMSmLLMSMLLmMMMSLLMMBLMmLSSLMmMMSSBmBBLSLLSMSMLBmMmD 2 Show transcribed image text Think about a primitive Bag Handling Belt Conveyor system. Bags move in a Conveyor belt in three different sizes (Large, Medium and Small). There are miscellaneous items also. All miscellaneous items can be considered as one type The worker on the right picks up bags and miscellaneous items one by one and place it in the shared location. The second worker to the left picks up bags, boxes and miscellaneous items one by one and arrange them in to shelves while keeping a count of each item type Large Bags Count Medium Bags Count Small Bags Count Bags (Large. Medium, Small) Boxed and Miscellaneous Items Moving on a Convoy Belt Shared This worker will take bags from shared location stack them on appropriate shelves and keep a count on each type. This worker will take bags from the Micelaneous tems Clonation stask hemoond th places them on the shared location Write a C/C++ multi-threaded application to simulate the above scenario. You can consider the worker to the right as the producer and the worker to the left as the consumer. Program must adhere to the following. a. Main program create and invokes two threads namely the producer and the consumer b. Producer opens and reads a text file (representing the commodities on the belt) character by character and put each character into a global character memory location. When each time the producer reads a character and then puts to the global location, we consider an item is ‘produced’. The file contains a text string like this LMLmMMLSMSMMSmLLMSMLLmMMMSLLMMBLMmLSSLMmMMSSBmBBLSLLSMSMLBmMmD S Small bag D Done (end of items) Large Bag m Miscellaneous Item M Medium Bag B Box The last character written to the shared location is the character ‘D’ (Done) indicating the end of items on the belt. Then the Producer closes the file. Producer completes. c. Consumer on the other end reads the character in the shared location (we consider the value in the shared location is consumed), and increments globally defined counts depending on the bag type, a box or miscellaneous items received. Then we assume the picked up item is put into a proper shelf. When the last character “D’ is consumed, the Consumer completes. d. The main program who created and invoked the two threads (Producer and Consumer) will wait until the two threads complete their jobs and then prints the Bag Counts as follows:
Two threads done. Main is now printing… Producer Started with TID 912 Consuner Started with TID 230912 Produc i ng : L Producing: M Producing: L Producing: m Producing: M Producing: M Items Produced and Consumed Large Bags Medium Bags Small Bags Boxes Misce11aneous Items: 8 Total Items Consuming: Consuming: M Consuming Consuming: M Consuming: M Consuming: L Consuming: s Consuming: M Consuming: s Consuming: M Consuming Consuming: s Producing: S Producing: M e. You must simulate this scenario in a way that the program willProducing: s Producing: M Producing: S run at least for a minute and at most for 2 minutes. Use the sleep() and/or usleep() system calls to control the execution speed of the application. Producing Producing: L Producing: L Consuming: L Consuming: M Consuming: s Consuming: M Consuming: L Consuming: L Consuming: f. Read the file character by character. NO BUFFERED READING.producing: s Producing: L Producing: L Producing: m Producing: M Producing: M Producing: M Producing: S Producing: L Producing: L Producing: M Producing: M Producing: B Producing: L Producing: M Producing: m Producing: L Producing: S Producing: s Producing: L Producing: M Producing: m Producing: M Producing: M Producing: S Producing: S Producing: B g. Use proper Mutexes in both the threads. h. Create two threads. Make sure to join the two threads. I. Use proper system calls. You are free to use system calls you Consuming: M Consuming: M Consuming: s Consuming: L Consuming: L Consuming: M Consuming: M Consuming Consuming: L have learnt in class and/or any other To the right is a screen dump of an actual run. Consuming: m Consuming: L Consuming: S Consuming: s Consuming: L Consuming: M Consuming: n Consuming Note: IF YOU NEED FULL CREDIT, YOU MUST STRICTLY USE PROPER SYSTEM CALLS IN YOUR CODE AND MUST ADHERE TO THE STEPS DESCRIBED IN THIS DOCUMENT INCLUDING MATCHING THE OUTPUT SHOWN TO THE RIGHT. IF YOU DO NOT USE SYSTEM CALLS AND TIMING AND STILL PRODUCE AN OUTPUT TO MATCH THE GIVAN OUTPUT YOU GET ONLY 30% OF THE GRADE. Consuming: S Consuming: s Consuming: B Consuming: m Consuming: B Consuming: B Consuming: L Consuming: s Consuming 1 Producing: B Producing: B Producing: L Producing: s Consuming: S Consuming: M Consuming: s Consuming: M Consuming: L Consuming: B Consuming: n Consuming Producing: S Producing: M Producing: S Producing: L Producing: B Producing: m Producing: M Producing: m Producing: D Consuming: D Two threads done. Main is now printing Itens Produced and Consumed Large Bags Small Bags Miscellaneous Items: 8 Total Items
commodities.dat X MLmMMLSMSMMSmLLMSMLLmMMMSLLMMBLMmLSSLMmMMSSBmBBLSLLSMSMLBmMmD 2

Expert Answer


Answer to Think about a primitive Bag Handling Belt Conveyor system. Bags move in a Conveyor belt in three different sizes (Large,… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *