Presentation is loading. Please wait.

Presentation is loading. Please wait.

(C) J. M. Garrido1 Object Oriented Simulation with OOSimL Detachable Resources Fall 2015.

Similar presentations


Presentation on theme: "(C) J. M. Garrido1 Object Oriented Simulation with OOSimL Detachable Resources Fall 2015."— Presentation transcript:

1 (C) J. M. Garrido1 Object Oriented Simulation with OOSimL Detachable Resources Fall 2015

2 (C) J. M. Garrido2 Review Standard Resources l A system can include zero or more resource pools l Each resource pool has a number of resource items l A number of these resource items can be acquired by one or more processes

3 (C) J. M. Garrido3 Resource Allocation and Deallocation Every process follows the sequence: l Request a number of resource items from a resource pool, wait until these become available l Acquire a number of items from a resource pool l Use the resource items for a finite period l Release the some or all resource items acquired

4 (C) J. M. Garrido4 Standard Resources l A resource pool is an passive object l A simulation model must declare a resource pool and create the resource pool object with a number of resource items l A specific number of items of a resource pool can be used by at most one process

5 (C) J. M. Garrido5 Resource Contention Mechanism l Processes compete for a limited number of resource items. l When there are not sufficient resource items for a request, the requesting process is suspended and placed in an internal queue by priority. l The processes waiting for resource items are reactivated when another process releases sufficient items.

6 (C) J. M. Garrido6 Resource Classes in OOSimL l A standard resource pool is an object of class Res l The resource pool object is created with a number of resource items l The resource pool object includes mechanism for processes to compete in a mutual exclusive manner for resources

7 (C) J. M. Garrido7 Using Resources in OOSimL For example, to declare and create a resource with 50 chairs: define chairs of class Res // chairs as a resource pool.... create chairs of class Res using “Wood chairs”, 50 A process acquires 15 chairs then releases 10: acquire 15 from chairs // acquire 15 chairs … release 10 of chairs // release 10 chairs

8 (C) J. M. Garrido8

9 9 Detachable Resource Container l A detachable resource is an infinite container and behaves in a different manner as the standard resource l Usually a process either deposits items into the container or removes items from the container

10 (C) J. M. Garrido10 Producer-Consumer Cooperation l There is also synchronization among producer processes and consumer processes l An infinite container stores items and allows cooperation of producer and consumer processes l Producer processes place items in the container l Consumer processes take items from the container.

11 (C) J. M. Garrido11 Resource Manipulation This type of resource manipulation involves: l An infinite container object with an initial number of items l One or more producer processes that place a number of items into the container object l One or more consumer processes that take a number of items from the container object

12 (C) J. M. Garrido12 Producer/Consumer Synchronization l If the container object has fewer items than the number requested by a consumer process, the process is suspended and moved to a resource queue to wait for resources. l When a producer process places items into the container object, the container object reactivates the waiting consumer process

13 (C) J. M. Garrido13 Producer and Consumer Objects l A Producer object takes a finite time interval to produce one or more items l It then places (gives) the items in the container l A consumer object takes items (if available) from the container then spends a finite time interval consuming these items.

14 (C) J. M. Garrido14 Simplified Activity Diagram of a Producer Process

15 (C) J. M. Garrido15 Simplified Activity Diagram of a Consumer Process

16 (C) J. M. Garrido16 Declaring and Creating Detachable Resources in OOSimL To declare and create a container object, the Bin library class is used. For example, to declare and create a container object called messages of initially 15 items: define messages of class Bin// declare.... create messages of class Bin using “My_messages”, 15

17 (C) J. M. Garrido17 A Producer Using Resource Objects A producer process spends a time interval, prod_int, producing items then places 15 messages items in the container (Bin object) hold for prod_int // interval producing items give 15 units of messages // place 15 items // container now has total now 30

18 (C) J. M. Garrido18 Producer Process

19 (C) J. M. Garrido19 A Consumer Using Resource Objects A consumer process requests and takes 20 items from the container, then spends a finite interval, cons_int, consuming these items take 20 units from messages hold for cons_int // consume items

20 (C) J. M. Garrido20 Consumer Process

21 (C) J. M. Garrido21 Available Units in a Resource Container The assign available statement gets the number of available resource units in a detachable resource object, and assigns this number to the specified integer variable. assign available units of to

22 (C) J. M. Garrido22 Example of Available Units The following example gets the current number of available resource units in the resource container cust_cont and assigns this number to the integer variable num_units define num_units of type integer... assign available units of cust_cont to num_units

23 (C) J. M. Garrido23 Machine Parts-Replacement Model l There are several machines in a shop. l Each machine has parts have fail periodically. l When a part fails, it needs to be replaced for a replacement part by the operator. l A repairman repairs the faulty parts

24 (C) J. M. Garrido24 Processes in the Model l The shop has several machines and a single repairman. l Several objects of class Machine are created l Only one object of class Repairman is created

25 (C) J. M. Garrido25 Resource Containers in the Model Two container objects are defined and created l A container for the parts that failed, called fault_parts l A container for the repaired parts (replacement parts), called rep_parts

26 (C) J. M. Garrido26 Machine Behavior l A machine operates normally for a finite time interval until a part fails l An operator removes the damaged part, places it in the fault_parts container l The operator takes a replacement part from the rep_parts container and installs the part on the machine

27 (C) J. M. Garrido27 Simplified Machine Operation

28 (C) J. M. Garrido28 Repairman Behavior 1. The repairman takes a damaged part from the fault_parts container 2. After repairing the part during finite period, the repairman places it in the rep_parts container 3. The repairman carries out background jobs when the fault_parts container is empty

29 (C) J. M. Garrido29 Simplified Repairman Operation

30 (C) J. M. Garrido30

31 (C) J. M. Garrido31 Simulation Results l Average machine down period (not operational) l Average machine up period (operational) l Average machine utilization l Repairman utilization (?)

32 Partial Output of a Simulation Run End Simulation of Machine Parts Replacement System date: 11/28/2014 time: 11:34 Total machines serviced: 3 Average down period: 15.29999 Average up period: 2782.1547 Average machine utilization: 0.7273 (C) J. M. Garrido32


Download ppt "(C) J. M. Garrido1 Object Oriented Simulation with OOSimL Detachable Resources Fall 2015."

Similar presentations


Ads by Google