Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Simulation with OOSimL Models with Resources Fall 2015.

Similar presentations


Presentation on theme: "Object Oriented Simulation with OOSimL Models with Resources Fall 2015."— Presentation transcript:

1 Object Oriented Simulation with OOSimL Models with Resources Fall 2015

2 (C) J. M. Garrido2 Resources l Processes are the active components of system l Resources are passive components of a system l In the process-interaction approach to simulation, resource pools are defined and created. Processes can acquire a number of resource items from a resource pool.

3 (C) J. M. Garrido3 Types of Resources l Standard resources that are accessed in a mutually exclusive manner by processes. These resource objects represent a finite pool of resource units and are created with the Res class. l Detachable resources that are consumed by the processes. These resource objects represent infinite pools of resource units and are created with the Bin class.

4 (C) J. M. Garrido4 Resource Pools 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

5 (C) J. M. Garrido5 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

6 (C) J. M. Garrido6 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

7 (C) J. M. Garrido7 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.

8 (C) J. M. Garrido8 Resource Classes in OOSimL l A 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 by

9 (C) J. M. Garrido9 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

10 (C) J. M. Garrido10

11 (C) J. M. Garrido11 Get Available Resources The following lines of code get the current number of available resource units in the resource pool chairs, which was defined above, and assigns this value to variable num_res. define num_res of type integer... assign available units of chairs to num_res

12 (C) J. M. Garrido12 Checking for Available Items A process may want to first check the number of available resource items before attempting to acquire items. assign available units of chairs to items_left if items_left >= 15 then acquire 15 from chairs else // carry out some other activity endif

13 (C) J. M. Garrido13 A Simple Model of a Warehouse l Trucks arrive periodically to a busy warehouse to unload goods l Trucks need to wait for an unloading bay l Small trucks need two workers for unloading l Big trucks need three workers for unloading

14 (C) J. M. Garrido14 Resources and Processes in the Warehouse Model l Warehouse resources: n 2 unloading bays n 5 workers for unloading l Processes: n small trucks n big trucks n arrivals for small trucks n arrivals for big trucks

15 (C) J. M. Garrido15

16 (C) J. M. Garrido16 Workload and Performance l Both types of trucks have different mean arrival rates and different mean unloading periods. l Some of the performance measures calculated for this model are: n Average wait period for each type of truck n Number of trucks serviced of each type n Resource utilization

17 Executing The Warehouse Model (C) J. M. Garrido17

18 Executing The Warehouse Model (C) J. M. Garrido18

19 Executing The Warehouse Model (C) J. M. Garrido19

20 Executing The Warehouse Model (C) J. M. Garrido20

21 Executing The Warehouse Model (C) J. M. Garrido21

22 Executing The Warehouse Model (C) J. M. Garrido22

23 Executing The Warehouse Model (C) J. M. Garrido23

24 Output of a Simulation Run of The Warehouse Model End Simulation of Busy Warehouse System date: 6/17/2009 time: 15:42 Elapsed computer time: 907 millisec Total small trucks serviced: 42 Average period small truck spends in warehouse: 23.981 Small truck average wait period: 16.285 Total number of big trucks serviced: 54 Big truck average wait period: 20.659 Avg per btruck in warehouse: 33.006 (C) J. M. Garrido24

25 (C) J. M. Garrido25 Allocating Resources with Priorities l Priorities are assigned to every process that needs resources l Processes compete for resources based on their priorities l To implement priorities, use an integer value for the priority

26 (C) J. M. Garrido26 Using Priorities with OOSimL l Invoke method set_prio with an integer argument in the class definition for the processes define my_prio = 3 of type integer // priority … fix priority my_prio // set priority … assign priority my_prio // get priority of this process l In OOSimL, priority 0 is the highest priority.

27 (C) J. M. Garrido27 Deadlock l When processes compete for resources, deadlock may occur. l Deadlock is a situation in which a set processes are waiting indefinitely for each other to release resources. l Good synchronization is necessary to prevent or avoid deadlock.

28 (C) J. M. Garrido28 Deadlock Example l Processes P1 and P2 are waiting for each other l Process P1 holds on item of resource R2 and is requesting one item of resource R1, which is held by P2 l Process P2 holds one item of resource R1 and is requesting one item of resource R2, which is held by P1


Download ppt "Object Oriented Simulation with OOSimL Models with Resources Fall 2015."

Similar presentations


Ads by Google