Implementation And Experimentation Of Producer

2y ago
21 Views
2 Downloads
432.35 KB
6 Pages
Last View : 30d ago
Last Download : 3m ago
Upload by : Isobel Thacker
Transcription

International Journal of Computer Applications (0975 – 8887)Volume 14– No.3, January 2011Implementation and Experimentation of ProducerConsumer Synchronization ProblemSyed Nasir Mehmood, Nazleeni HaronVaqar Akhtar, Younus Javed,Universiti Teknologi PETRONASBandar Seri IskandarPerak, MalaysiaNational University of Science & TechnologyCollege of Electrical & Mechanical EngineeringPakistanABSTRACTThis paper presents the design and implementation of asimulator that allows user to study producer-consumersynchronization problem in three different contexts: simpleproducer-consumer problem, producer-consumer problem in asingle processor system and producer-consumer problem inmulti-processing system. The main contribution of our workis the facility to run the simulation in a multi-processorsenvironment. This has been deemed appropriate since most ofthe current applications are distributed in nature and run inmulti-processing environment. Additionally, the featuresoffered by the simulator enables user to analyze and evaluatevarious synchronization problems in a repeatable andcontrollable environment. The experimental results arepresented to show the viability of our proposed simulator.General TermsSimulation, SynchronizationKeywordsBounded Buffer Problem, Producer Consumer, SingleProcessor, Multi- Processor.1. INTRODUCTIONProducer-consumer problem is one classical example ization is needed in order to ensure that the producerstops producing when the buffer is full and the consumerstops removing items from the buffer if it is empty. Thevariations of producer-consumer problem can be implementedin different type of applications [1], [2], [3], [4] and can berun on both single and multi-processors systems [5]. Due toits importance, many researchers have studied this problemand normally simulation is used in order to visualize thebehavior of the problem [2], [6]. However, most of thesesimulators only allow user to experiment in the context of asingle producer and a single consumer. To address thislimitation, we propose a simulator that allows user to studyproducer-consumer synchronization problem in three differentcontexts such as simple producer-consumer problem,producer-consumer problem in a single processor system andproducer-consumer problem in multi-processing system. Thishas been deemed appropriate since most of the currentapplications are distributed in nature and run in multiprocessing environment. In addition, users can carry outcomparative evaluation among different contexts using thesimulator as to gain insights on the best model to use incertain situations. The simulator has been developed as acomprehensive software package which can run self-drivensimulation, generates useful data and provides a user-friendlyenvironment. Software design strategy is function-orientedand design is modular in nature. The system is designed to runon Windows and is written using Java.This paper presents the implementation and experimentalresults of the proposed simulator for producer-consumerproblem in three aforementioned contexts. In the next section,we describe the general producer-consumer problem. Section3 presents the models of the three different contexts. Section 4describes their implementations and section 5 provides theexperimental results for each context and outlines somediscussions. Section 6 concludes the paper.2. PRODUCER-CONSUMER PROBLEMIn producer-consumer problem, there are two types of processinvolved: producer and consumer who are sharing a fixed sizebuffer [3]. The role of producer is to put the item one a time inthe buffer and the role of consumer is to retrieve the item fromthe buffer. The problem is to make sure that the producer willnot try to add the item once the buffer is full and that theconsumer will not try to remove the item from an emptybuffer [3].According to [2], the normal behavior of this problem are (i)Random arrival of petitions to put item in the buffer; (ii) Oneconsumer that immediately after getting an information fromthe buffer intends to get another one; (iii) Buffer of definedand finite size; (iv) Consumer waits when the buffer is empty;(v) Producer waits when the buffer is full; (vi) Second andsubsequent productions wait when the customer is writing orheld up.3. PRODUCER-CONSUMER MODELSThis section presents the different models of the producerconsumer problem that can be simulated by the user.3.1 Simple Producer-Consumer ProblemThis problem describes one producer and one consumersharing the same finite buffer. Producer produces items andplace items in the buffer while consumer consumes itemsfrom the buffer.3.2 Producer-Consumer Problem in SingleProcessor EnvironmentThis model is the advanced form of the first model. In thefirst model, producer produces and places items in the bufferat random basis. Consumer simply consumes items from thebuffer without acknowledging whether it is meant for them ornot. But in this model, producer is producing items for thespecific consumer and only that consumer is given access tothat item. When that consumer is free, it will consume theitems from the buffer. This module of the simulator works forsingle processor environment.32

International Journal of Computer Applications (0975 – 8887)Volume 14– No.3, January 20113.3 Producer-ConsumerProblemMulti-Processor EnvironmentinThis model is designed for multi-processor environment.Parallel processing technique has been employed in thismodule to enable N number of producers and consumersexecuting at the same time. This is to ensure that resources arefully optimized. In this model, producers can produceitems/data for specific consumers and only that consumer canconsume those items/data.4. SIMULATORDESIGNIMPLEMENTATION4.1 Class DiagramANDThis section provides details on fundamental classes of thesimulator, which are the building blocks of the simulator. Therelationship among the classes is depicted in Figure vassSConsumerFig 1: Simulator Classes4.1.1 ProducerConsumerApplet ClassThis is the main class of a Java applet file for the simulator.The GUI of this applet contains three parts: animation canvas,message canvas and a button panel. The animation canvas iswhere the producer/consumer animation is displayed. Themessage canvas is where the status of producers andconsumers are displayed. The button panel has six basicbuttons for the users to use while simulating the problems.The user also can select the number of the buffer, the numberof producers and the number of consumers. Unless the userselects different values, the default number of buffer is 10,and default number of the producers and consumers are two.4.1.2 IntQueue ClassThis class contains the control of execution of the producerand consumer. It provides the bounded buffer of size 10.Producer and consumer call the enqueue and dequeuemethods of this class to access the shared buffer. Enqueuemethod is used to place items in the buffer while dequeue is toremove the items from the buffer.4.1.3 Producer ClassProducer's main activity is to call the enqueue method inIntQueue class. This class is inherited from the thread classand the run method of this class performs the majorfunctionality. This method will start a loop which willcontinuously produce the items. The item value is producedby calling the built in random method. Then this method callsthe enqueue method of the IntQueue class. This will place theproduced item on the queue. Then this method also calls theupdateTime method of MessageCanvas class to update thetime on main canvas. This method also appends the produceditem in the message window.4.1.4 Consumer ClassConsumer's main activity is to call the dequeue method inIntQueue class. This class is also inherited from the threadclass and the run method of this class performs the majorfunctionality. This method will start a loop which willcontinuously check the need for consuming by calling thegetConsmerSel method. If it needs consuming operation thenit will call the dequeue method of IntQueue class. Then thismethod also appends message in the message window that anitem is consumed and also display on the canvas board.4.1.5 MessageCanvas ClassThis class provides message canvas for the applet GUI. It willprint the statuses of producers and consumers on the GUI. Allof the other classes use the methods of this class to display themessages on the canvas.4.2 Simulator Options and FeaturesThe simulator allows user to explore the three differentmodels visually through the use of 2D graphics. The menusystem will allow the user to choose the desired options. Auser will be provided with the following options and featuresof the simulator:Producer Process.Consumer ProcessAbility to change number of CPUsAbility to change the size of the buffer. (Maximum of: 20slots and a minimum of: 5 slot)Ability to adjust the speed of the simulation.Ability to change the status of each of the processes evenwhile the simulation is executing.Nine buttons are provided: Start, Stop, Pause, Continue,Faster, Slower and Save: Start Button: Will activate the simulation and start theprocess(s) execution. Stop Button: Will completely stop the simulation. Thisshould happen until all the locks are released. Processesshould be terminated naturally. Pause Button: Will pause the simulation Continue Button: Will resume the simulation after anypause Faster Button: Will increase the speed of the simulation Slower Button: Will decrease the speed of thesimulation Save Button: Will save the performance parameters inword/excel format Pause Producer/Consumer : Will pause any chosenproducer or customer Resume Producer/Consumer : Will resume thesimulation of chosen producer or consumerMessages to the user: When the producer is the only process active in thesimulation. (i.e. when the buffer is filled completely, amessage will be displayed informing the user that adeadlock has occurred and that the Consumer must beadded for the deadlock to be removed). When the Consumer is the only process active in thesimulation. (i.e. when the buffer is completely empty, amessage will be displayed informing the user that adeadlock has occurred and that the Producer will beadded for the deadlock to be removed). The simulation cannot start unless a buffer exists.33

International Journal of Computer Applications (0975 – 8887)Volume 14– No.3, January 20114.3 Modes of OperationsThe simulator can be run in 3 different modes asfollows:4.3.1 Simple Producer ConsumerIn this mode, the simulation uses only one CPU and the rest ofthe parameters such as Buffer Size, Number of Producers andConsumers must be given by the user. The user interface forthis mode is as shown in Figure 2.Figure 2 displays a scenario where a user selects buffer sizeten, chooses three producers and consumers respectively andclicks on START button. Producers P1, P2 and P3 startproducing items and consumers C1, C2 and C3 startconsuming items produced by the producers. A circular bufferhas been maintained. Two logical pointers have been shown,In and Out. In pointer points to the position where item is tobe placed where Out pointer points to the position from whereitem is to be removed. Simulator also shows the status ofbuffer during execution. When buffer becomes full it gives amessage “Buffer Status: Full” and in case of empty buffer itgives a message “Buffer Status: Empty”.User may also interact with the simulation at run time as toattain information such as buffer size, empty slots, availableitems, status of each producer and each consumer. A user maypause or resume any producer or any consumer at any instantduring execution of simulator. Initially all producers andconsumers are in sleeping state. When buffer becomes full,then producer moves in waiting state. When buffer becomesempty then it is the consumer’s turn to be in waiting state.Sleeping state and waiting states are highlighted with yellowcolor. Active/running states of producers and consumers /consumers are shown with red color.4.3.2 Producer-Consumer Problem in SingleProcessor EnvironmentAll options as discussed in the first mode are also available inthis mode. However, additional information is available in thismode and as shown in Figure 3. In this mode, the status foreach producer is added with information on the correspondingconsumer who is expecting the item. Figure 3 illustrates ascenario where two producers (P1 and P2) are producingitems for two consumers (C1 and C2) with a shared buffer ofsize ten.The simulator will also display the information on theproducer-consumer activities throughout the simulation. Usermay save the complete history for later analytical use in Wordor Excel format. Figure 4 shows example of simulationactivities saved in Word format. In addition, the simulatoralso captures the elapsed time that can be used to measure thethroughput of the system.Fig 2: Interface for Simple Producer-Consumer Simulation34

International Journal of Computer Applications (0975 – 8887)Volume 14– No.3, January 2011Fig 3: Interface for Producer-Consumer Simulation in a Single EnvironmentFig 1: Sample of simulation activities in Microsoft Word formatFig 5: Interface for Producer-Consumer Simulation in Multi-Processor Environment35

International Journal of Computer Applications (0975 – 8887)Volume 14– No.3, January 20114.3.3 Producer-Consumer Problem in MultiProcessor Environment5.1.1 Relationship between Simulator Output andElapsed TimeIn this mode, a user is given option to select number of CPUsin addition to pre-mentioned options. A user may runsimulator with different number of CPUs and can watch theperformance of implemented producer consumer algorithm. Auser is given an option “SAVE” to save the simulationhistory. A user may record the performance parameters inWord format as well in Excel format.Figure 5 displays a working simulator running this mode for ascenario of three producers and consumers using two CPUs.This experiment is aimed at quantifying the effect of elapsedtime on the number of items produced and consumed. It isalso meant to see the effects of elapsed time for the producerconsumer problem in single processor and multi-processorenvironments. For a single processor environment, we runthree set of experiments with the following constant inputparameters: three producers, three consumers, buffer size 10and one CPU. We varied the elapsed time for eachexperiment. As for multi-processors environment, we havekept the same value of parameters except for number ofCPUs. Figure 6 depicts the sample result of this experimentfor three different elapsed time; 20, 40 and 60 seconds. Theresults attest that elapsed time have significant effects ofnumber of items produced and consumed in both type ofenvironments.5. EXPERIMENTAL RESULTSThis section presents the experiments that have been carriedout to evaluate the efficiency of the simulator in simulatingthe different contexts of producer-consumer synchronizationproblem. We have performed a series of experiments byvarying the input parameters as to study the following:Items Produced/Consumed140No of Producers 3No of Consumers 3Buffer Size 101201008060CPU 340CPU 12002040Elapsed Time (secs)60No of ItemsFig 6: Simulation results for relationship between items produced/consumed and elapsed time for single and multi-processorsenvironments4035302520151050No of Producers 3No of Consumers 3Buffer Size 10Elapsed time 20 sItem ConsumedItem Produced123No of CPUsFig 7: Simulation results for relationship between items produced/ consumed and number of CPUs36

No of Items Produced/ConsumedInternational Journal of Computer Applications (0975 – 8887)Volume 14– No.3, January 201116014012010080CPU 360CPU 240CPU 1200101520Buffer SizeFig 8: Simulation results for relationship between items produced/ consumed and buffer size running in three differentenvironments5.1.2 Relationship between Simulator Output andNumber of CPUsTo study this relationship, we performed three sets ofexperiments with the following constant input parameters:three producers, three consumers, buffer size 10 and elapsedtime of 20 seconds. Each set of experiment has been run withdifferent number of CPUs. Output of the simulator ismeasured in terms of number of items produced and itemsconsumed. Figure 7 shows a sample result for this experiment.The results show that the output of the system increases as thenumber of CPUs increases.5.1.3 Relationship between Simulator Output andBuffer SizeThe performance of the simulator with regards to buffer sizewas computed via this experiment. In this case, the otherentire parameters are kept constant and only buffer size isvaried. Three sets of experiment have been conducted forthree types of environment; single (set number of CPU to 1)and multiprocessor (set number of CPU to 2 and 3). Theresults for this experiment are depicted in Figure 8 with threedifferent buffer sizes : 10, 15 and 20 . The results demonstratethat for all environments, simulator output (number of itemsproduced and consumed) increases as the buffer sizeincreases. They are not linearly proportional although thebuffer size was increased linearly. Significant increased canbe seen when buffer size was increased from 15 to 20.6. CONCLUSIONThis simulator provides a facility for the user to experimentwith three different contexts such as simple producerconsumer problem, producer-consumer problem in a singleprocessor system and producer-consumer problem in multiprocessing system. This has been deemed appropriate sincemost of the current applications are distributed in nature andrun in multi-processing environment. In addition, users cancarry out comparative evaluation among different contexts ina repeatable and controllable environment as to gain insighton the best model to use in certain situations. All developedmodules of the simulator guarantee synchronization ofprocesses and satisfy necessary requirements to providesolution to the critical section problem.This simulator has been designed to run self-drivensimulations which are intrinsically limited in accuracy. It isbecause the input data on which the simulation runs isgenerated artificially to model the target system. As such, weplan to incorporate the trace-driven simulation in the existingsimulator for more accurate results. Trace-driven uses as input,a trace of actual events collected and recorded on a real system.Capability of running a trace-driven simulation can beincorporated in the existing system by developing a softwaremodule that can translate the trace of events recorded on a realsystem, into the format of input data file. The input data file sogenerated then can be used to run the simulation.7. REFERENCES[1] Stefano, A. D., Bello, L. L., Santoro, C.1997.Synchronous Producer-consumer transactions for realtime distributed process control. In Proceedings of theIEEEInternationalWorkshoponFactoryCommunication Systems.[2] Juiz, C., Puigjaner, R. 1995. Improved performancemodel of a real-time software element: the producerconsumer. In Proceedings of the Second InternationalWorkshop on Real-Time Computing Systems andApplications.[3] Zhang, Y., Zhang, J., Zhang, D. 2009. Implementing andtesting Producer-consumer problem using aspectoriented programming. In Proceedings of the FifthInternational Conference on Information Assurance andSecurity.[4] Shen, C. 2000. Discrete-event simulation on the Internetand the web. Future Generation Computer Systems, vol.17, 187-196.[5] Hilzer, Jr., R. C. 1992. Synchronization of theProducer/Consumerproblemusing semaphores,monitors, and the Ada Rendezvous. Operating SystemsReview, vol. 26, 31-39.[6] Robbins, S. 2000. Experimentation with bounded buffersynchronization. In Proceedings of the 31st SIGCSETechnical Symposium on Computer Science Education.37

Resume Producer/Consumer : Will resume the simulation of chosen producer or consumer Messages to the user: When the producer is the only process active in the simulation. (i.e. when the buffer is filled completely, a message will be displayed informing the user that

Related Documents:

This document provides step-by-step instructions for the Producer Online Contracting Application process. TAKE NOTE: There are two options that apply for producer contracting: - Producer (Individual Producer only) - Producer Entity Agency (Individual Producer and Agency) This document has three sections: 1. Producer (Individual Producer Only) 2.

This document provides step-by-step instructions for the Producer Online Contracting Application process. TAKE NOTE: There are two options that apply for producer contracting: - Producer (Individual Producer only) - Producer Entity Agency (Individual Producer and Agency) This document has three sections: 1. Producer (Individual Producer Only) 2.

Vertical mergers h Examples of a vertical relationship: – producer and retailer – car parts producer and car producer – cement producer and concrete producer – electricity producer and distributor h Vertical mergers have implications which differ from horizo

3 Life and Health Producer Combo General 2015 60 Life and Health Producer Combo State 2016 Property Producer General 2017 60 Property Producer State 2018 Property Casualty Producer Combo General 2019 60 Property Casualty Producer Combo State 2020 Adviser Property Casualty General 2021 60 Adviser Property Casualty State 2022 Retake of the two-part exam

Producer and Director Producer Name: In the box, type the name of the producer of the programme Producer Contract Type: From the Producer Contract Type drop down list, select the relevant contract type for the producer, identifying if they are a freelancer, or a member of staff (which includes producers on Fixed Term Contracts)

investigating whether radical experimentation is sustainable in the long run. This work draws on several strands of literatures, concerned with experimentation, social learn-ing, and innovation. The literature on multi-armed bandits and strategic experimentation typically considers a xed set of independent arms.

Aug 19, 2021 · Marion OH Producer Nucor Steel - Kingman, AZ Kingman AZ Producer Nucor Steel - Utah Plymouth UT Producer Nucor Steel Sedalia, LLC. Sedalia MO Producer Optimus Steel, LLC - Beaumont, TX Vidor TX Producer Ozark Rebar, LLC. Greenbrier AR Fabricator Re-Steel Express Services, Inc.

Artificial Intelligence in Supply Chains Martin Zapke, 3806 A Field Lab carried out on the Master in Management Program, under the supervision of: Professor José Crespo de Carvalho 4th January 2019 . ii Disclaimer With this disclaimer, Martin Zapke, ensures that the following work project to obtain the Master of Science degree in Management is conducted by himself. The mentioned references .