object oriented simulation with oosiml models with resources fall 2015

Post on 18-Jan-2018

222 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

(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.

TRANSCRIPT

Object Oriented Simulation with OOSimL

Models with ResourcesFall 2015

(C) J. M. Garrido 2

Resources Processes are the active components of

system Resources are passive components of

a system 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.

(C) J. M. Garrido 3

Types of Resources

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.

Detachable resources that are consumed by the processes. These resource objects represent infinite pools of resource units and are created with the Bin class.

(C) J. M. Garrido 4

Resource Pools

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 5

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 6

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 7

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 8

Resource Classes in OOSimL

A 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 by

(C) J. M. Garrido 9

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 10

(C) J. M. Garrido 11

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

(C) J. M. Garrido 12

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_leftif items_left >= 15 then acquire 15 from chairs else // carry out some other activityendif

(C) J. M. Garrido 13

A Simple Model of a Warehouse

Trucks arrive periodically to a busy warehouse to unload goods

Trucks need to wait for an unloading bay Small trucks need two workers for

unloading Big trucks need three workers for unloading

(C) J. M. Garrido 14

Resources and Processes in the Warehouse Model

Warehouse resources: 2 unloading bays 5 workers for unloading

Processes: small trucks big trucks arrivals for small trucks arrivals for big trucks

(C) J. M. Garrido 15

(C) J. M. Garrido 16

Workload and Performance

Both types of trucks have different mean arrival rates and different mean unloading periods.

Some of the performance measures calculated for this model are: Average wait period for each type of truck Number of trucks serviced of each type Resource utilization

Executing The Warehouse Model

(C) J. M. Garrido 17

Executing The Warehouse Model

(C) J. M. Garrido 18

Executing The Warehouse Model

(C) J. M. Garrido 19

Executing The Warehouse Model

(C) J. M. Garrido 20

Executing The Warehouse Model

(C) J. M. Garrido 21

Executing The Warehouse Model

(C) J. M. Garrido 22

Executing The Warehouse Model

(C) J. M. Garrido 23

Output of a Simulation Run of The Warehouse Model

End Simulation of Busy Warehouse System date: 6/17/2009 time: 15:42Elapsed computer time: 907 millisec Total small trucks serviced: 42Average period small truck spends in warehouse: 23.981Small truck average wait period: 16.285Total number of big trucks serviced: 54Big truck average wait period: 20.659Avg per btruck in warehouse: 33.006

(C) J. M. Garrido 24

(C) J. M. Garrido 25

Allocating Resources with Priorities

Priorities are assigned to every process that needs resources

Processes compete for resources based on their priorities

To implement priorities, use an integer value for the priority

(C) J. M. Garrido 26

Using Priorities with OOSimL

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 In OOSimL, priority 0 is the highest priority.

(C) J. M. Garrido 27

Deadlock

When processes compete for resources, deadlock may occur.

Deadlock is a situation in which a set processes are waiting indefinitely for each other to release resources.

Good synchronization is necessary to prevent or avoid deadlock.

(C) J. M. Garrido 28

Deadlock Example

Processes P1 and P2 are waiting for each other

Process P1 holds on item of resource R2 and is requesting one item of resource R1, which is held by P2

Process P2 holds one item of resource R1 and is requesting one item of resource R2, which is held by P1

top related