330 likes | 352 Views
Object Oriented Simulation with OOSimL. Detachable Resources Fall 2015. Review Standard Resources. A system can include zero or more resource pools Each resource pool has a number of resource items A number of these resource items can be acquired by one or more processes.
E N D
Object Oriented Simulationwith OOSimL Detachable Resources Fall 2015 (C) J. M. Garrido
Review Standard Resources • A system can include zero or more resource pools • Each resource pool has a number of resource items • A number of these resource items can be acquired by one or more processes (C) J. M. Garrido
Resource Allocation and Deallocation Every process follows the sequence: • Request a number of resource items from a resource pool, wait until these become available • Acquire a number of items from a resource pool • Use the resource items for a finite period • Release the some or all resource items acquired (C) J. M. Garrido
Standard Resources • A resource pool is an passive object • A simulation model must declare a resource pool and create the resource pool object with a number of resource items • A specific number of items of a resource pool can be used by at most one process (C) J. M. Garrido
Resource Contention Mechanism • Processes compete for a limited number of resource items. • When there are not sufficient resource items for a request, the requesting process is suspended and placed in an internal queue by priority. • The processes waiting for resource items are reactivated when another process releases sufficient items. (C) J. M. Garrido
Resource Classes in OOSimL • A standard resource pool is an object of class Res • The resource pool object is created with a number of resource items • The resource pool object includes mechanism for processes to compete in a mutual exclusive manner for resources (C) J. M. Garrido
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 (C) J. M. Garrido
Detachable Resource Container • A detachable resource is an infinite container and behaves in a different manner as the standard resource • Usually a process either deposits items into the container or removes items from the container (C) J. M. Garrido
Producer-Consumer Cooperation • There is also synchronization among producer processes and consumer processes • An infinite container stores items and allows cooperation of producer and consumer processes • Producer processes place items in the container • Consumer processes take items from the container. (C) J. M. Garrido
Resource Manipulation This type of resource manipulation involves: • An infinite container object with an initial number of items • One or more producer processes that place a number of items into the container object • One or more consumer processes that take a number of items from the container object (C) J. M. Garrido
Producer/Consumer Synchronization • 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. • When a producer process places items into the container object, the container object reactivates the waiting consumer process (C) J. M. Garrido
Producer and Consumer Objects • A Producer object takes a finite time interval to produce one or more items • It then places (gives) the items in the container • A consumer object takes items (if available) from the container then spends a finite time interval consuming these items. (C) J. M. Garrido
Simplified Activity Diagram of a Producer Process (C) J. M. Garrido
Simplified Activity Diagram of a Consumer Process (C) J. M. Garrido
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 (C) J. M. Garrido
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 (C) J. M. Garrido
Producer Process (C) J. M. Garrido
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 A Consumer Using Resource Objects (C) J. M. Garrido
Consumer Process (C) J. M. Garrido
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 < ref_variable > to < var_name > (C) J. M. Garrido
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 (C) J. M. Garrido
Machine Parts-Replacement Model • There are several machines in a shop. • Each machine has parts have fail periodically. • When a part fails, it needs to be replaced for a replacement part by the operator. • A repairman repairs the faulty parts (C) J. M. Garrido
Processes in the Model • The shop has several machines and a single repairman. • Several objects of class Machine are created • Only one object of class Repairman is created (C) J. M. Garrido
Resource Containers in the Model Two container objects are defined and created • A container for the parts that failed, called fault_parts • A container for the repaired parts (replacement parts), called rep_parts (C) J. M. Garrido
Machine Behavior • A machine operates normally for a finite time interval until a part fails • An operator removes the damaged part, places it in the fault_parts container • The operator takes a replacement part from the rep_parts container and installs the part on the machine (C) J. M. Garrido
Simplified Machine Operation (C) J. M. Garrido
Repairman Behavior • The repairman takes a damaged part from the fault_parts container • After repairing the part during finite period, the repairman places it in the rep_parts container • The repairman carries out background jobs when the fault_parts container is empty (C) J. M. Garrido
Simplified Repairman Operation (C) J. M. Garrido
Simulation Results • Average machine down period (not operational) • Average machine up period (operational) • Average machine utilization • Repairman utilization (?) (C) J. M. Garrido
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. Garrido