290 likes | 309 Views
Explore the process-interaction approach to simulation, managing resource pools, allocation, contention mechanisms, and prioritization for efficient system modeling and analysis using OOSimL. Learn about standard and detachable resources, resource classes, and executable models in a warehouse scenario with varying truck sizes. Study workload, performance metrics, and output analysis. Resources and processes coordination in a simulated environment with the ability to allocate resources based on priorities for optimal system functioning.
E N D
Object Oriented Simulation with OOSimL Models with Resources Fall 2015
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
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. • Detachableresources 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
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
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 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
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
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
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 (C) J. M. Garrido
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
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
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 (C) J. M. Garrido
Executing The Warehouse Model (C) J. M. Garrido
Executing The Warehouse Model (C) J. M. Garrido
Executing The Warehouse Model (C) J. M. Garrido
Executing The Warehouse Model (C) J. M. Garrido
Executing The Warehouse Model (C) J. M. Garrido
Executing The Warehouse Model (C) J. M. Garrido
Executing The Warehouse Model (C) J. M. Garrido
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. Garrido
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
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
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
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 (C) J. M. Garrido