+ All Categories
Home > Documents > Object Oriented Simulation with OOSimL Conditional Waiting.

Object Oriented Simulation with OOSimL Conditional Waiting.

Date post: 19-Jan-2016
Category:
Upload: james-sherman
View: 225 times
Download: 0 times
Share this document with a friend
Popular Tags:
22
Object Oriented Simulation with OOSimL Conditional Waiting
Transcript
Page 1: Object Oriented Simulation with OOSimL Conditional Waiting.

Object Oriented Simulation

with OOSimL

Conditional Waiting

Page 2: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Conditional Waiting

One or more processes wait for a condition to become true.

Waiting processes are suspended and automatically placed in a queue.

A suspended process will be reactivated when another process changes the condition.

Page 3: Object Oriented Simulation with OOSimL Conditional Waiting.

Conditional Waiting

The processes involved use the synchronization mechanism implemented in a synchronization conditional object

This synchronization object suspends and later reactivates the interacting processes.

The synchronization object evaluates the specified condition on behalf of a process

Feb. 2015

Page 4: Object Oriented Simulation with OOSimL Conditional Waiting.

Evaluating the Condition

If the condition is not true, the process is suspended by the synchronization object and placed in the condition queue.

Suspended processes are held in the condition queue that belongs to the synchronization object.

Another process, which changes the parameters of the condition, will signal the synchronization object and it reactivates any waiting processes.

Feb. 2015

Page 5: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Synchronization Object

The mechanism that controls conditional waiting synchronization is implemented in class Condq

An object of class Condq is a passive object and includes an internal queue to hold waiting processes

An object of class Condq is needed for each condition.

Page 6: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

UML Diagram With Conditional Wait

Page 7: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Two Processes and Conditional Waiting

Page 8: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Declaring and Creating an Object of Class Condq

To use a conditional object of class Condq, the object reference must be declared and the object created with title and the optional number of priorities to use.

The default number of priorities is 250.

define cond_cust of class Condq ...create cond_cust of class Condq using "Customer Cond”, priorities

Page 9: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Waituntil Statement

A Process tests a condition by executing the waituntil statement, and if the condition is not true, is suspended and placed in the condition queue

waituntil < condition > in < cond_obj >

Page 10: Object Oriented Simulation with OOSimL Conditional Waiting.

Example of ‘waituntil’

define mcond of type boolean

...

set mcond = false

while mcond not equal true do

// evaluate boolean expression

set mcond = (att1 > 3 ) and (att2 <= att1)

waituntil mcond in cond_cust

endwhile

// now acquire resources

// hold for a specified time interval

// release resources

Feb. 2015

Page 11: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Signal Statement

A process that changes the condition, execute the signal statement to reactivate waiting process at the head of the queue

A reactivated process will re-evaluate the condition

signal to < cond_obj >

Page 12: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Length of Conditional Queue

The assign length statement, gets the number of processes waiting in the conditional queue of the specified Condq object, and assigns it to the specified integer variable.

define cond_num of type integer

...

assign length of cond_cust to cond_num

Page 13: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Conditional Port System

Ships arrive periodically at a port to unload their cargo

To dock, ships require the following resources: a pier and two tugboats

To leave, ships require one tugboat Ships can only dock if the tide is high The tide changes every 13 hours, and lasts for

4 hours.

Page 14: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Processes and Resources in the Port System

There are four types of processes Ships, with several instances Arrivals, one instance Tide, with only one instance Cport, the top class

The resource types are: Tugboats Piers

Page 15: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Conditions in the Port System

The condition for ships to dock is: a pier and two tugboats available the tide is not low.

The tide remains low for 4 time units. The cycle continuously repeats.

Page 16: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Ships Behavior

1. First acquire a pier, if there any available2. Evaluate the condition for tide not low and

enough tugs available3. Wait suspended if condition is not true4. Continue5. Acquire the necessary tugs for docking6. Unload, which takes a finite time interval7. Acquire 1 tugboat for undocking and

departure.

Page 17: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Timings for the Simulation

Inter-arrival time of ships follows an exponential distribution with mean of 26.0 minutes.

Docking time is constant: 32.5 minutes. Unloading follows a normal distribution: mean

time is 74.0 minutes with a standard deviation of 8.0 minutes.

Undocking time interval is constant: 25.0 time units.

Page 18: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Tide Behavior and Condition Changes

The tide is modeled as a process When the tide changes state, the evaluation of

the condition also changes When the tide changes to high, this process

invokes the signal method of the conditional object, so ships can re-evaluate the condition

Page 19: Object Oriented Simulation with OOSimL Conditional Waiting.

Main Body of Tide

while clktime < simperiod do

set lowtide = true

hold self for 4.0

set lowtide = false

signal to cond_obj

hold self for 9.0

endwhile

Feb. 2015

Page 20: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Condition Changes

When a ship process releases resources, this event may also cause a change of the condition.

The ship process executes the signal statement.

Page 21: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Implementation

The Conditional Port model is archived in file cport.jar

The classes of this model are stored in files: Cport.osl, Arrivals.osl, Ship.osl, and Tide.osl.

Page 22: Object Oriented Simulation with OOSimL Conditional Waiting.

Feb. 2015

Partial Output of a Simulation Run

End Simulation of Port System with Conditions

date: 10/13/2014 time: 7:16

Total number of ships that arrived: 27

Average wait period: 123.5


Recommended