(c) j. m. garrido1 object oriented simulation with oosiml detachable resources fall 2015
DESCRIPTION
(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 acquiredTRANSCRIPT
(C) J. M. Garrido 1
Object Oriented Simulationwith OOSimL
Detachable ResourcesFall 2015
(C) J. M. Garrido 2
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 3
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 4
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 5
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 6
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 7
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 8
(C) J. M. Garrido 9
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 10
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 11
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 12
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 13
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 14
Simplified Activity Diagram of a Producer Process
(C) J. M. Garrido 15
Simplified Activity Diagram of a Consumer Process
(C) J. M. Garrido 16
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 17
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 18
Producer Process
(C) J. M. Garrido 19
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 messageshold for cons_int // consume items
(C) J. M. Garrido 20
Consumer Process
(C) J. M. Garrido 21
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 22
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 23
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 24
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 25
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 26
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 27
Simplified Machine Operation
(C) J. M. Garrido 28
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
(C) J. M. Garrido 29
Simplified Repairman Operation
(C) J. M. Garrido 30
(C) J. M. Garrido 31
Simulation Results
Average machine down period (not operational)
Average machine up period (operational) Average machine utilization Repairman utilization (?)
Partial Output of a Simulation Run
End Simulation of Machine Parts Replacement System
date: 11/28/2014 time: 11:34 Total machines serviced: 3Average down period: 15.29999Average up period: 2782.1547Average machine utilization: 0.7273
(C) J. M. Garrido 32