+ All Categories
Home > Documents > A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221...

A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221...

Date post: 13-Sep-2018
Category:
Upload: buinhi
View: 243 times
Download: 0 times
Share this document with a friend
36
Appendix A A SHORT MANUAL FOR PSIM-J A.1 INTRODUCTION TO THE PSIM-J LIBRARY This appendix presents a brief reference manual for Psim-J. The summary documentation for all the Java classes in Psim-J is available on the Psim-J Web pages. The Psim-J simulation library is a set of Java classes that implements the mechanisms necessary to develop simulation models and to carry out simula- tion runs using the process interaction approach. For constructing simulation models, these library classes provide the following facilities: • The definition of processes; • The starting of a simulation run that will execute for a predetermined period, called the simulation period. • Definition of various queues that are used in the simulation models. • Definition of resource pools as passive objects. • The generation of random numbers, each with its own probability dis- tribution. Every user program that implements a simulation model with the Psim-J library needs to include the first line with the following import statement: import psimjava.*; This gives the simulation model access to all the class specifications in the basic Psim-J library. The most important class in the library is class Process. 219
Transcript
Page 1: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

Appendix A

A SHORT MANUAL FOR PSIM-J

A.1 INTRODUCTION TO THE PSIM-J LIBRARY

This appendix presents a brief reference manual for Psim-J. The summary documentation for all the Java classes in Psim-J is available on the Psim-J Web pages.

The Psim-J simulation library is a set of Java classes that implements the mechanisms necessary to develop simulation models and to carry out simula­tion runs using the process interaction approach. For constructing simulation models, these library classes provide the following facilities:

• The definition of processes;

• The starting of a simulation run that will execute for a predetermined period, called the simulation period.

• Definition of various queues that are used in the simulation models.

• Definition of resource pools as passive objects.

• The generation of random numbers, each with its own probability dis­tribution.

Every user program that implements a simulation model with the Psim-J library needs to include the first line with the following import statement:

import psimjava.*;

This gives the simulation model access to all the class specifications in the basic Psim-J library. The most important class in the library is class Process.

219

Page 2: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

220 List Of Classes

A.2 LIST OF CLASSES

The Psim-J simulation library is implemented as a set of Java classes grouped into a Java package called psimjava. The following is a list and summary of the Psim-J library Java classes:

Bin This class controls the declaration, allocation and deallocation of producer­consumer resources.

Bin_chain Internal class called by the Bin class and the simulation executive.

Comm_timer Communication timer process

Condq Class for controlling conditional waiting.

Erand Random number generator.

Normal Random number generator, with Normal distribution

Pobject Internal class in Psim package.

Poisson Random number generation from Poisson distribution

Pqueue Priority queue class for Psim-J.

Process Basic behavior of a process in Psim.

Qobject Auxiliary (internal) class used by the other Psim classes

Randint Java random number generators.

Res Resource class.

Res_chain Internal class used by class Res and by the simulation executive

Rqueue This is an auxiliary class used by class Res.

Rsqueue Internal class used by class Res.

Sched Top level class for scheduling processes.

Simulation Class used by modeler (user) to set up and start a simulation run.

Squeue Simple queue class for Psim-J.

Startlock Internal class used the simulation executive.

StaticSync This class is part of the simulation engine.

Suspend Internal class for Psim-J

Urand Random number generator, Uniform distribution For Psim-J.

Waitq Class Waitq manipulates the cooperation of processes.

Page 3: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 221

A.3 DEFINING PROCESSES IN A SIMULATION MODEL

A simulation model that applies the process interactive approach to simula­tion using Psim-J must define one or more process types, and then create instances of these process types. To define a process in a simulation model implemented in Java, the program must define a class with an appropriate name and inherit class Process. All process definitions in a simulation model must inherit the class Process, which implements the general behavior of a process. For example:

class Server extends psimjava.Process { II private members

public Server( String serv_name •... ) { II constructor super(serv_name); II invoke parent constructor

}

public void Main_body() {

}

II other public members }

The above definition in a simulation model defines a process, called Server, that inherits class Process from the Psim-J library. All instances of class Server will behave as processes. As any other, class Server includes definitions of its private features (data members and methods) and its public features.

Two of the public features defined above are very important and must be included in every class that represents a process in the simulation model:

1. The constructor (Server), which is a method that is executed when an object of the class is created. The only parameter required is a character string for the name of the process.

2. The special method, Main_body, which is present in every process defined in the simulation model. This method defines all the activities that are to be carried out by the process, i.e., defines the actual behavior of the objects instantiated by from the process definition. The name of this method, (Main_body) is the same in all processes.

Page 4: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

222 The Time Dimension

A.4 THE TIME DIMENSION

All variables and objects that refer to the time dimension use type double in Java. The units for time measurement are not predefined, so most models implemented use the generic "time units" as a time measure. All implementa­tions of simulation models in Java and Psim-J can access the simulation time from the simulation clock. The time references used by the models are based on instances of the simulation time. For example, the following instruction defines variable start and initializes it to the current simulation time; this time is accessed from the system clock using method geLclock in the Psim-J library.

double start = get_clock();

A.5 OTHER PROCESS METHODS

In addition to the methods mentioned above, several other methods are de­fined in class Process. These are used to get information about a process and to manipulate processes.

Method details are given next for all methods in class Process. For more practical use of these methods as applied in actual simulation models, refer to the appropriate chapters in this book.

get-Ilame public java.lang.String getJlameO. Gets the name of the calling process (activate object). The following Java code gets the name of object machine of class Server.

Server machine; II ref to machine object String machine_name; II variable for process name

machine_name = machine.get_name();

terminate public void terminateO. Terminates the called process (object). This method changes the state of the process to TERMINATED, and the time of the next event to zero. The Java garbage collector will destroy the object referenced. The following Java code gets the name of the object then it terminates object machine.

machine_name = machine.get_name(); machine.terminate(); System.out.println("Process II + machine_name +

II terminated. II);

Page 5: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 223

is_terminated public boolean is_terminatedO. Checks if the calling process has been terminated. If the process has been terminated, it cannot be scheduled. The following Java code checks if process machine has been terminated, if so, it prints a message. If the process has not been terminated, it is scheduled.

if (machine.is_terminated()) II test object termination System.out.println(machine.get_name() + " terminated.")j

else { II schedule process

}

deactivate public void deactivate(Process p). Suspends the called process. The process will remain suspended until another process reactivates it. Parameters: p, - the process to suspend. The following Java code sus­pends process machine.

machine_name = machine.get_name()j System.out.println(machine_name + " suspended.")j deactivate(machine)j II suspend process

reactivate public void reactivate(Process p). Reactivates the called process. The called process becomes activate again to be scheduled and carry out normal activities. Parameters: p, - the process to reactivate.

machine_name = machine.get_name()j System.out.println(machine_name + " reactivated.")j reactivate(machine)j II reactivate process

delay public void delay(double d). Schedules the calling process at d time units from the current clock time. In the mean time, the process remains active in the event list waiting for the time to become the currently run­ning process. Parameters: d, - the interval from the current simulation time after which the current process will become the running process.

The following Java code delays the execution of the current process for a period called waiLp. The process is scheduled to continue execution after this period has elapsed.

double wait_pj II period to wait for

II wait for this period to elapse

Page 6: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

224 Other Process Methods

p_interrupt public void pJnterrupt(int intJevel). Interrupts the calling process using the specified interrupt level. The interrupted process is rescheduled immediately so it can take appropriate action. Note that this is different from the Java Thread interrupt. Parameters; intJevel, - the interrupt level used with the interrupt.

In the following Java code, the current process interrupts object machine with an interrupt level of 2.

int interr_lev = 2;

machine.p_interrupt(interr_lev); II interrupt object machine

inLlevel public int intJevelO. Gets the interrupt level of the calling process. This value is zero if the process has not been interrupted, or the flag has been cleared. This method is invoked by an interrupted process to check if has been interrupted with a given interrupt level. The following Java code in the interrupted process checks if it has been interrupted. If the value of the interrupt level is 2, the process executes an interrupt handling routine. If this value is not 2, either the process has not been interrupted (value zero), or it has been interrupted by another process using a different interrupt level.

if (int_level() == 2) { II execute interrupt handling

}

else II not interrupted

geLremain_t public double getJemain_tO. Get the remaining interval left after the process has been interrupted. This is useful if the interrupted process was carrying out some task for a specified period, just before it was interrupted. When the process resumes (gets rescheduled), it will continue the task for the remaining period. The following Java code in the interrupted process stores the remaining period in variable rem_period.

if (int_level() == 2) { rem_period = get_remain_t(); II remeining period

II interrupt handling }

else II not interrupted

cleaLint public void clearJntO. Clears the Psim interrupt level of the pro­cess (to zero). Note that this is different than the Java Thread interrupt

Page 7: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 225

mechanism. This method is normally invoked in the interrupt handling routine. The following Java code in the interrupted process invokes this function to clear the interrupt level.

if (int_level() == 2) { rem_period = get_remain_t(); II remaining period clear_int(); II clear interrupt level

II interrupt handling }

else II not interrupted

run public void runO. This is an internal method that sets up and starts executing the main body of the process. This function is called by method start in the Java Thread package. Overrides: run in class java.lang.Thread.

Main_body public abstract void Main_bodyO. This method represents the main code of every user process. It normally contains the more special­ized behavior of the user process. Therefore every user process must implement this function. See sections above for more details on this method.

idle public boolean idleO. Checks if the process is idle (Le., has been sus­pended). This check is useful before attempting to interrupt a process. The following Java code first checks if process machine is not idle before interrupting it with interrupt level 2.

int mint_lev = 2;

if ( ! machine.idle()) II if not idle machine.p_interrupt(mint_lev); II interrupt obj machine

else II alternative

comm_wait public boolean comm_waitO. Gets the value of the communi­cation flag of the calling process. This method is used for synchronous communication among processes.

seLcomm..1lag public void seLcommJlag(boolean flag). Set the commu­nication flag to the specified truth-value. This method is used for synchronous communication among processes. Parameters: flag, - the boolean value to set the communication flag.

set...simuLp public static void set...simuLp(double tt). Internal method used by Psim.

Page 8: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

226 Starting and Running a Simulation

geLsimuLp public static double get-simuLpO. Internal method used by Psim.

preempt public void preemptO. Internal method used by Psim.

schedat public void schedat(double timeat). Schedules the called process at time timeat. At that instant, the process will become the running process. Parameters: timeat, - the instant at which the calling process will be scheduled.

A.6 STARTING AND RUNNING A SIMULATION

A Java program that implements a simulation model declares and creates an object of class Simulation in method main. The instantiation of this class requires a title for the simulation project. The following is an example of an instantiation of class Simulation.

Simulation sim_run = new Simulation("Simple Port System");

The Java statement above declares and creates an object called sim_run. The object created includes the title of the model, or the object can be used as a title for the simulation run (i.e., every simulation run can have a different title) .

To start a simulation run and to let it execute for a specified period, sim­period, method starLsim is invoked, of object sim_run created above. For example:

double simperiod = 650.5; II duration of simulation period

sim_run.start_sim(simperiod); II start simulation

The Java code above declares a variable, simperiod, of type double. This variable represents the simulation period for the simulation run. Recall that all variables and objects that refer to the time dimension must be declared with this type. The variable simperiod is used above as an argument when invoking method starLsim. In this example, the simulation runs for 650.5 time units.

After the simulation run completes, a Java program that implements a simulation model will normally compute some final results, display them, and terminate.

A.7 PRIORITY OF A PROCESS

The priority of a process is an integer value and represents its relative impor­tance in relation to other processes. In Psim-J, the highest priority value is O.

Page 9: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 227

To access the priority of a process, the method geLprio is invoked. For exam­ple, the following Java code gets the priority of process, by invoking method geLprio.

Server machine; int mach_prio;

II reference to object II priority

mach_prio = machine.get_prio();

The code above declares a reference to a process of class Server. Then it declares an integer variable, mach_prio, to store the priority of the process referenced. Method geLprio is invoked to get the priority and assigns it to the integer variable mach_prio.

To set the priority of a process, method seLprio is invoked with an integer argument. For example, suppose a process needs to set its priority to 1. The following Java code sets the process' priority to 1:

Now suppose that a process needs to increase its priority by 1. The follow­ing Java code accomplish this:

int my_priority;

my_priority = get_prio(); my_priority++; set_prio(my_priority);

A.8 PROCESS STATES

II get current priority II increment current priority II set new priority

In Psim-J, there are three predefined states for a process, IDLE, RUNNING, and TERMINATED. The state of a process can be accessed by method rdstate. When invoked, this method returns the value corresponding to the state of the process. The state of a process cannot be directly set since the simulation executive directly controls the scheduling of processes. Method idle, discussed above directly evaluates the state of a process being IDLE, if so, returns true. Similarly, method is_terminated returns true if the state of the process is TERMINATED. Method rdstate is usually invoked to check the state of a process. The following Java code, for example, checks if the process reference as machine is in the RUNNING state the:

Server machine; if ( machine.rdstate() == RUNNING) {

II carry out some activities if true

}

Page 10: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

228 Scheduling Processes

A.9 SCHEDULING PROCESSES

The dynamic behavior of a system is dependent on the scheduling of processes during an observation period, or the simulation period. To schedule a process means to place it in an event list with a time stamp so that the simulation executive will execute its appropriate phase when the system clock reaches that time. Method delay, discussed above, is used for this type of scheduling in Psim-J. The following Java code, for example, schedules a process 5 time units from the current clock time:

delay(12.5);

The simulation executive will execute the instruction following the delay call after 12.5 time units from the current clock time.

The delay operation is applied to simulate an activity that has a certain time duration, or to simulate a wait activity. Method delay can also used to reactivate a process that has been suspended.

A.I0 HANDLING QUEUES

A.IO.I General Description

Psim-J provides two classes for queue handling designed to be used with simulation models. These classes are:

1. The Squeue class for simple queues;

2. The Pqueue class for priority queues.

A.I0.2 Methods in Class Squeue

Objects of this class are simple first-in-first-out (FIFO) queues. The methods explained below are the most relevant members of class Squeue and are used to manipulate objects of simple queues. Some of the methods do not follow the conventional rules for queue processing.

Squeue(java.lang.String aJlame) Constructor for simple queue for ini­tializing queues with specified name. The default capacity is 1000 ob­jects. Parameters: aJlame - Title for the simple queue.

Squeue(java.lang.String aJlame, int max_objects) Constructor for ini­tializing objects of simple queues with a specified name and capacity

Page 11: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 229

(number of objects). Parameters: aJlame - Title for the simple queue. max_objects - Maximum number of objects (capacity of the queue).

The constructor for creating a simple queue requires the name of the queue and the queue size. This last parameter is optional; if not in­cluded, the assigned default size is 1,000. For example, the following Java code declares and creates a simple queue, cusLqueue with an as­signed name "Customer Queue" and size of 15 customers:

Squeue cust_queue; II declare simple queue

II now create simple queue cust_queue = new Squeue("Customer Queue", 15);

void back(java.lang.Object p) Insert the specified object to the head of the queue. Parameters: p - Object (or process) to insert into the queue.

Method back inserts an object or a process to the head of a queue and requires a reference to the process as the only parameter. This is an abnormal operation. For example, the following Java code inserts pro­cess cusLobj to the head of simple queue (not an enqueue operation) cusLqueue.

II put back customer into queue cust_queue.back(cust_obj);

boolean fullO Check if the queue is full.

To check for the general states of the queue, empty or full, methods full and empty are provided. These methods return a boolean value (true or false). For example, the following Java code checks if queue object cusLqueue (defined above) is full.

if( cust_queue.full()) { II if queue is full execute instructions here

}

else II queue is not full

In a similar manner, the empty function checks if a queue is empty.

boolean emptyO Check if queue is empty. For example, the following Java code checks if queue object cusLqueue (defined above) is empty. The process suspends itself if the queue is empty, otherwise, it proceeds to dequeue an object from the queue.

if( cust_queue.empty()) { II if queue is empty, suspend here

Page 12: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

230 Handling Queues

deactivate(this)j

}

else II dequeue object

void into(java.lang.Object p) Insert specified object to the tail of the queue. Parameters: p - Object (or process) to enqueue.

Method into is used to insert an object or a process into a simple queue. The only parameter required by this function is the object to insert; this object becomes the new object at the tail of the queue. The size of the queue is increased by one. For example, the following Java code inserts (also called an enqueue operation) object cusLobj into simple queue cusLqueue.

Customer cust_objj II reference to a customer process

II enqueue customer process cust_queue.into(cust_obj)j

java.lang.Object lastO Remove the last object enqueued (the one at the tail of queue). Method last removes the last process inserted to the queue (i.e., the process at the tail of the queue). This is an abnormal operation; the usual operation is to remove the process at the head of the queue (dequeue). This method requires no parameters. For example, the following Java code removes a customer process from the tail of queue cusLqueue (the last process inserted) and assigns reference cusLobj to it:

cust_obj = (Customer) cust_queue.last()j

int lengthO Get current number of objects in queue (queue size). This method gets the current size of a simple queue. It returns an integer value that corresponds to the current length of the queue. For example, the following Java code gets the current length of the queue object cusLqueue (defined above).

cust_queue.length()j II get queue length

java.lang.Object outO Dequeue an object or process from the head of queue. Method out removes the object or process from the head of a simple queue. This method requires no parameters. The size of the queue is reduced by one, as a result of this operation. For example, The following Java code removes (also called a dequeue operation) a customer process from queue cusLqueue and assigns a reference cusLobj to it.

Page 13: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 231

cust_obj = (Customer) cust_queue.out()j

The casting to Customer reference is necessary to specify the type of object or process dequeued.

void remov(java.lang.Object pr) Find and remove specified object or pro­cess from queue. Method remov removes a specified object or process from the queue. This method requires the reference to the process as the only parameter. For example, the following Java code removes the process referenced by cusLobj from queue cusLqueue:

cust_queue.remov(cust_obj)j II remove process

A.I0.3 Members of Class Pqueue

Methods of class Pqueue define and manipulate priority queues. Some of the methods do not follow the conventional rules for queue processing. The text below includes a general description and list of the most relevant members of class Pqueue.

Pqueue public Pqueue(java.lang.String aJlame, int max_prio). Initialize pri­ority queue object with title and maximum priority to use.

public Pqueue(java.lang.String aJlame, int max_prio, int maxsize). Ini­tialize priority queue object with title, maximum number of priorities to use, and the capacity of the component queues. Parameters: SJlame­title for the priority queue; max_prio - maximum priority to use; maxsize - capacity (maximum size) of the component queues.

The constructor for creating a priority queue requires the name of the queue, the number of different priorities, and the queue size for all prior­ities. The last two parameters are optional; if not included, the number of priorities is assigned to 300 and the assigned default queue size is 1,000 for every priority. For example, the following Java code declares and creates priority queue, cusLqueue with an assigned name "Customer Queue," using 8 different priorities and size of 25 customers for every priority.

Pqueue cust_queue II declare priority queue

II create priority queue cust_queue = new Pqueue("Customer Queue", 8, 25)j

length public int lengthO. Get the total length of the priority queue.

Method length gets the current size (total number of processes) of a priority queue. This method returns an integer value that corresponds to the current length of the queue. For example, the following Java code gets the current length of priority queue cusLqueue defined above.

Page 14: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

232 Handling Queues

cust_queue.length(); II get queue length

empty public boolean emptyO. Return true if total queue is empty, other­wise, return false.

Method empty returns true if the complete priority queue is empty. This function requires no parameters and returns a boolean value. For example, the following Java code checks if queue cusLqueue is empty (for all priorities).

if (cust_queue.empty()) { II execute if the queue is empty

}

plength public int plength(int prio). Return the length of a particular group with given priority. Parameters: prio - priority of the group (queue).

Method plength gets the number of processes of a specified priority in a queue. The only parameter required is the priority of the processes. The function returns an integer that corresponds to the number of processes found with the specified priority. For example, the following Java code gets the current number of processes in the priority queue cusLqueue, with priority Lprio.

cust_queue.plength(l_prio); II get number of processes

This method can also be used to test if the number of processes of a specified priority is zero. For example, to test if the number of processes with priority Lprio in priority queue cusLqueue is zero:

if (cust_queue.plength(l_prio) == 0) { II execute if no processes yith priority l_prio

}

full public boolean full(int prio). Return true if queue is full of processes with priority prio, return false otherwise.

Method full tests if the number of processes of a specified priority has reached its limit (upper bound). This method needs only one parameter, the priority. The function returns a boolean value (true or false). For example, the following Java tests if the number of processes with priority Lprio in priority queue cusLqueue has reached its limit:

if (cust_queue.pfull(l_prio)) { II execute if queue yith priority l_prio is full

}

maxprio public int maxprioO. Return the maximum priority used. For example, the following Java code gets the maximum priority in queue cusLqueue.

Page 15: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 233

int mprio; II for maximum priority

mprio = cust_queue.maxprio()

into public void into(java.lang.Object ps). Enqueue (insert) the specified object (process) into the priority queue. Parameters: ps - The object (process) to insert into the queue.

Method into inserts a given process into the priority queue. The only parameter required by this method is the process to insert; its priority is implicit. This process becomes the new process at the tail of the priority group, for its implicit priority, in the queue. The size of the correspond­ing priority group is increased by one. For example, the following Java code inserts process cusLobj into the priority queue cusLqueue.

II reference to a customer process Customer cust_obj;

II enqueue customer process cust_queue.into(cust_obj);

out public java.lang.Object outO. Dequeue (remove) object (process) with the highest priority.

Method out removes the highest priority process from the priority queue. If there are several processes with the same high priority, the process at the head of the queue is removed. This function requires no parameters. For example, the following Java code removes the highest priority cus­tomer process from priority queue cusLqueue and assigns it a reference cusLobj.

cust_obj = (Customer) cust_queue.out();

The casting to Customer is necessary to specify the type of process dequeued.

pout public java.lang.Object pout(int prio). Dequeues an object (process) with the specified priority. Parameters: prio - Priority of the object to dequeue.

Method pout removes the next process with the specified priority from the queue. The process removed is the one at the head of its priority group. The only required priority for this function is the priority of the process. For example, the following Java code removes the next customer process with priority m_prio from priority queue cusLqueue and assigns it reference cusLobj.

cust_obj = (Customer) cust_queue.pout(m_prio);

Page 16: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

234 Handling Queues

plast public java.lang.Object plast(int prio). Get last object enqueued with the specified priority. Parameters: prio - Priority of the object to re­trieve.

Method plast removes the last process inserted into the queue with a specified priority (i.e., the process at the tail of the priority group in the queue). This is another abnormal operation. This method requires the priority as the only parameter. For example, the following Java code removes the last customer process that was inserted into queue cusLqueue with priority Lprio and assigns it a reference cusLobj.

cust_obj = (Customer) cust_queue.plast(l_prio);

Hast public java.lang.Object llastO. Get last object enqueued to lowest pri­ority queue.

Method llast removes the last process inserted to the queue with the lowest priority (i.e., the process at the tail of the lowest priority group in the queue). This is an abnormal queue operation. This method requires no parameters. For example, the following Java code removes the last customer process with the lowest priority that was inserted into queue cust-queue and assigns it reference cust-obj.

cust_obj = (Customer) cust_queue.llast();

pllast public java.lang.Object pllast(int pr). Get last object enqueued into lowest priority queue, down to the specified priority.

Method pllast removes the last process inserted to the queue with the lowest priority lower than the specified priority (i.e., the process at the tail of the lowest priority group with a priority lower than the specified priority). This is an abnormal queue operation. This method requires the specified priority as the only parameter. For example, the following Java code removes the last customer process with the lowest priority lower than ILprio that was inserted into queue cust-queue and assign it a reference cust-obj.

cust_obj = (Customer) cust_queue.pllast(ll_prio);

pback public void pback(java.lang.Object ps). Place the specified object (process) at the head of the queue. Parameters: ps - The object (pro­cess) to place into the queue.

Method pback inserts a process to the head of its priority group in a priority queue and requires a reference to the process as the only pa­rameter. This method uses the implicit priority of the process. This is an abnormal queue operation. For example, the following Java code inserts process cust-obj into the head of priority queue cust-queue.

II put back customer into cust_queue

Page 17: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 235

premov public void premov(java.lang.Object ps). Remove the specified ob­ject (process) from the priority queue. Parameters: ps - The object (process) to remove from the queue.

Method premov removes a specified process from a priority queue. This method requires the reference to the process as the only parameter. For example, the following Java code removes the process referenced by cusLobj from the priority queue cusLqueue.

cust_queue.premov(cust_obj); II remove process cust_obj

A.II CLASSES FOR RESOURCES

A.I1.1 General Description

The Psim-J library includes classes for the synchronization of processes that use resources. This library provides two classes:

1. The Res class for mutually exclusive resource synchronization;

2. The Bin class for producer consumer resource synchronization.

A.I1.2 Class Res

The description below includes the most relevant members of the resource class, Res.

Res public Res(java.lang.String name,int n). Constructor for the resurce pool object. Parameters: name - the title for the resource pool object; n -the number of resource items in the resource pool.

The constructor for creating a resource pool of this class requires the name of the resource pool and the pool size. This last parameter de­fines the initial number of available resource itemss in the resource pool. For example, the following Java code declares and creates a resource pool, chairs, with an assigned name "Customer Chairs" and a size of 30 resource items.

Res chairs; II declare resource pool

II create resource pool chairs = new Res("Customer Chairs", 30);

num-B.vail public int num_availO. This method gets the number of available resource items available in the resource pool.

Page 18: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

236 Classes for Resources

Method num_avail requires no parameters and returns an integer value that corresponds to the number of currently available resource items found in the resource pool. For example, the following Java code gets the current number of available resource items in the resource pool chairs, which was defined above.

II number of resource items

acquire public void acquire(int num). This method allows the requesting process to acquire a number of resource items. If the resource pool does not have all these requested resource items available, the requesting process is suspended. Parameters: num - the number of resource items requested.

Method acquire lets the process attempt to acquire the specified number of resource items from the resource pool. This method acquires a speci­fied number of resource items from a resource pool only when there are sufficient resources available. The number of requested resource items is specified as the only parameter. When the number of resource items is not sufficient, the process is suspended.

For example, The following Java code attempts to acquire 10 resource items from the resource pool chairs (defined above).

chairs.acquire(10); II execute instructions when resources are acquired

release public void release(int num). This method releases resources from the calling process, and makes them available in the resource pool. Then the function reactivates any waiting processes. Parameters: num, - the number of resource items released by the calling process.

Method release is invoked when a process needs to release resources. This deallocates a specified number of resource items that the process holds. This method requires a parameter that corresponds to the num­ber of resource items to release. The method has no return value. For example, the following Java code lets a process release 10 resource items from the resource pool chairs (defined above).

chairs.release(10);

A.l1.3 Relevant Features in the Bin Class

The description below includes the most relevant members of resource class, Bin.

Page 19: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 237

Bin public Bin(java.lang.String name,int n). Constructor initializes Bin ob­ject with a title and the number of available resource items. Parameters: name - title of Bin object created; n - initial number of Bin items.

The constructor for creating a Bin resource container requires the name of the resource container and the initial container size. This last param­eter defines the initial number of available resource items in the resource container. For example, the following Java code declares and creates a Bin resource container, cusLcont, with an assigned name "Parts" and a size of 10 resource items.

Bin cust_cont; II declare resource container

II create the resource container (bin pool) cust_cont = new Bin("Parts", 10);

num-.avail public int num_availO. Returns number of available resource items in Bin object.

Method num_avail gets the number of available resources in a Bin re­source container. This method requires no parameters and returns an integer value that corresponds to the number of available resource items found in the Bin resource container. For example, The following Java code gets the current number of available resource items in the resource container cusLcont, which was defined above.

int num_cont;

take public void take(int num). This method removes num resource items from the Bin object pool, if there are sufficient items in the pool it returns normally. If there are not sufficient resource items available, the calling process is suspended (to wait for available items). Parameters: num - number of items to wirhdraw from Bin pool.

Invoking method take lets a process to take a number of resource items from a Bin resource container. If the number of resource items in the Bin container is sufficient, the process can proceed otherwise, the process is suspended. When the operation completes, the number of resource items in the Bin container is decreased by the number of resource items taken by the process. For example, the following Java code lets a process take 10 resource items from the cusLcont container (defined above).

cust_cont.take(10) II execute when resource items taken

Page 20: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

238 Class Waitq

give public void give( int num). Current process deposits a number of resource items in the Bin object. Parameters: num - number of items to deposit in Bin object.

Method give is invoked when a process needs to place (or give) resource items to a Bin container. This places a specified number of resource items into the container. This method requires a parameter that corre­sponds to the number of resource items to place in the Bin container. The method has no return value. For example, the following Java code makes a process place 8 resource items in the cusLcont resource con­tainer (defined above).

cust_cont.give(8);

A.12 CLASS WAITQ

Class Waitq manipulates the cooperation of processes. Objects of this class are used as a synchronization mechanism for the processes to cooperate. This synchronization allows one process to dominate and is treated as the master process; the other processes are treated as slaves. The description below includes details of the relevant operations of class Waitq.

Waitq public Waitq(java.lang.String name,int maxprio). Initialize a Waitq object with its mane and the maximum priority to use. Parameters: name - title for the object created maxprio - maximum priority to use.

The constructor for creating a synchronization object for cooperation requires a name and an optional number of priorities. This last parame­ter is needed for the hidden priority queues, one for the master processes and one for the slave processes. For example, the following Java code creates a synchronization object, coopLcust, with name "Channel A", and with 8 priorities.

Waitq coopt_cust;

coopt_cust = new Waitq("Channel A", 8);

length public int lengthO. Return the length (number of processes) in the slave queue.

Method length gets the length of the slave queue (i.e., the number of slave processes waiting on the synchronization object). This method returns an integer value with the number of slave processes waiting. For example, the following Java code gets the number of slave processes waiting in the coopLcust object defined above.

int num_slaves;

Page 21: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 239

num_slaves = coopt_cust.length();

lengthm public int lengthmO. Return the length (number of processes) in the master queue.

Method lengthm gets the length of the master queue (i.e., the number of master processes waiting on the synchronization object). This method returns an integer value with the number of master processes waiting. For example, the following Java code gets the number of master pro­cesses waiting in object coopLcust defined above.

int num_master;

num_master = coopt_cust.lengthm();

qwait public void qwaitO. Places current process in the slave queue and passivates (suspends) waiting for a process in the master queue.

Method qwait allows a slave process to cooperate with a master process. This method returns no value and does not require a parameter. If there is not a master process available, the slave process invoking this method is suspended. For example, the following Java code allows a slave process attempt a cooperation with a master process using the synchronization object coopLcust (defined above).

coopt_cust.qwait(); II wait for master process

coopt public Process cooptO. This method returns a slave process from the slave queue. If slave queue is empty, this function passivates the current (master) process.

Invoking method coopt allows a master process to attempt cooperation with slave processes. This method returns a reference to the slave pro­cess retrieved from the slave queue. The method requires no parameters. If there is no slave process available in the slave queue, the master pro­cess invoking this method is suspended and placed in the master queue. For example, the following Java code lets a master process attempt cooperation with a slave process using the coopLcust synchronization object. When the cooperation becomes possible, the process continues otherwise, the process is suspended waiting.

Customer our_cust; our_cust = coopt_cust.coopt(); II execute when a slave was found

Page 22: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

240 The Condq Class

A.13 THE CONDQ CLASS

Class Condq handles the waiting of processes for a specified condition (also called conditional waiting). Objects of this class are used as a synchronization mechanism for the processes to evaluate the specified condition and wait if the condition is not true. This synchronization allows processes to wait in a conditional queue by priority. The description below includes details of relevant operations of class Condq.

Condq public Condq(java.lang.String name, int maxprio). The constructor initializes Condq object with title and maximum number of priorities to use. Parameters: name - title for the Condq object; maxprio - maximum number of priorities to use.

The constructor for creating a synchronization object for conditional waiting requires a name and the number of priorities. This last param­eter is needed for the hidden priority queue of processes. For example, the following Java code declares and creates a synchronization object with name "Customer Cond" and with 10 priorities.

Condq cond_cust;

cond_cust = new condq(IICustomer Cond", 10);

waituntil public boolean waituntil(boolean cond). The process evaluates the condition cond and if it evaluates to false, the process is passivated and enqueued. Parameters: cond - condition to be evaluated.

Method waituntil evaluates the specified condition and suspends the process if the condition is not true. The suspended process is placed in hidden priority queue. The function has only one parameter, the con­dition to evaluate. The method returns a boolean value, which is false if the condition evaluates to false, otherwise the function returns true. When the process is reactivated, it needs to re-evaluate the condition.

The condition specified in the parameter is a boolean expression. For example, the following Java code allows a process that references a con­dition cond_a and synchronizes with a Condq object cond_cust (created above).

boolean cond_a () { II method that evaluates the condition return ((attl > 3 ) && (att2 <= attl) );

}

boolean c_flag = false; II continuation flag while ( ! c_flag )

c_flag = cond_cust.waituntil(cond_a); II execute when cond_a is true

Page 23: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 241

signal public void signalO. Unblock (dequeue) the process or processes at the head of the queue, and reactivate them. When each processes become current, it will re-test the condition.

Method signal reactivates the processes at the head of the priority queue in the Condq object. The reactivated processes will evaluate their condi­tion and may be suspended again. This function requires no parameter and returns no value. For example, the following Java code allows a process to signal the Condq object cond_cust (created above).

cond_cust.signal();

set all public void setall(boolean flag). Set flag, if true test condition in all waiting processes.

Method setall sets the internal flag for the evaluation mode in the Condq object. If this flag is set to true, method signal allows all waiting pro­cesses to test their condition. This function requires one parameter, the boolean value for setting the flag. The method returns no parameter. For example, the following Java statement allows a process to set the flag so that all processes will be allowed to test their condition on the object cond_cust.

cond_cust.setall(true);

length public int lengthO. Return length of the condition queue (number of processes waiting on the given condition).

Method length returns the number of processes in the conditional queue of a Condq object. This function returns an integer value that corre­sponds to the conditional queue length. The method requires no pa­rameter. For example, the following Java statements allows a process to get the number of processes in the conditional queue in object cond_cust (defined above).

int cond_num; cond_num = cond_cust->length();

A.14 RANDOM NUMBER GENERATION IN PSIM-J

Psim-J provides several Java classes for random number generators that use different probability distributions. The following classes provide the most relevant random number generators:

• Randint, for uniformly distributed random numbers between 0.0 and 1.0;

Page 24: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

242 Random Number Generation in Psim-J

• Erand, for the generation of random numbers from an exponential dis­tribution (this class is called exponential in PsimL);

• Poisson, for the generation of random numbers from a Poisson distribu­tion;

• Normal, for the generation of random numbers from a normal distribu­tion;

• Urand, for the generation of random numbers within a specified range and using a uniform probability distribution.

For summary documentation of all classes, consult the Psim-J Web pages.

A.14.1 Class Randint

Class Randint provides the most basic type of random number generation. The class uses a uniform distribution. The description below gives some de­tails on the methods in class Randint.

Randint public Randint(long seed). Constructor for random number gener­ator objet Parameters: seed - to set the random number stream.

public RandintO. Overloaded constructor.

These constructors are used to create a random number generator ob­ject. For example, the following Java code declares and creates a random number generator object with 7 as the value of the seed.

Randint ran_genul; II declare reference to random generator

ran_genul = ney Randint(7); II create rand gen

If the seed argument is not specified when invoking the constructor, the random generator object uses the processor timer for the seed. This implies that there will be a different random stream of numbers for every simulation run.

seed public void seed (long useed). This function sets the seed for the random number stream. Parameters: useed - the value for the seed.

This method is used when the random generator object has already being created and there is to set a value for the seed. For example, the following Java code sets the seed to 13 for generator object ran_genul defined above.

ran_genul.seed(13);

Page 25: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 243

fdraw public float fdrawO. This method generates a random number be­tween 0.0 to 1.0, using a generator object already created. For example, the following Java code generates a random number from the genera­tor object ran_genul defined above, and stores the number in variable ran_value.

float ran_value;

A.14.2 Class Erand

Class Erand provides random number generation using an exponential dis­tribution. The description below gives some details of the methods in class Erand.

Erand public Erand(double emean, long eseed).

public Erand(double emean). Overloaded constructor.

Constructor for initializing the exponential random numbergenerator. Parameters: emean, - the mean value of the distribution; essed, - the seed value for selecting a random stream.

These constructors are used to create a random number generator ob­ject, the arguments to be supplied are the mean value of the samples, and the seed (optional argument). For example, the following Java code declares and creates a random number generator object ran_gen with mean of 34.5 and 7 as the value of the seed.

Erand ran_gen; II declare reference to random generator

ran_gen = new Erand(34.5, 7); II create rand gen

fdraw public double fdrawO. This method generates a random number using the exponential distribution with the mean value given in the construc­tor. For example, the following Java code generates a random number of type double using random generator ran_gen (created above) and stores the random number in variable ran_value.

Page 26: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

244 Random Number Generation in Psim-J

double ran_valuej

If the seed argument is not specified when invoking the constructor, the random generator object uses the processor timer for the seed. This implies that there will be a different random stream of numbers for every simulation run.

A.14.3 Class Normal

Class Normal provides random number generation using a normal distribu­tion. The description below presents details of the methods in class Normal.

Normal public Normal(long mean, long stdev, int seed). Constructor for random number generator object - Normal distribution. Parameters: mean - the mean value of the distribution; stdev - the value of the standard deviation; seed - the value to set the random stream.

public Normal(long mean, long stdev). Overloaded constructor.

public Normal(double rmean, double rstd, int seed). Overloaded con­structor.

public Normal(double rmean, double rstd). Overloaded constructor.

The constructor is used to create and initialize a random number gen­erator object with the given value of the mean, the standard deviation, and the value of the seed (optional argument). For example, the follow­ing Java code declares and creates a random number generator object norm_gen with mean 12.5 and standard deviation of 2.3.

Normal norm_genj II declare reference to random generator

norm_gen = new Normal(12.5, 2.3)j II create rand gen

fdraw public double fdrawO. This method generates a random number using the normal distribution with the mean value and the standard deviation given in the constructor. For example, the following Java code gener­ates a random number of type double using random generator norm_gen (created above) and stores the random number in variable ran_value.

double ran_valuej

ran_value = norm_gen.fdraw(); delay(ran_value)j II use random number

Page 27: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

A Short Manual For Psim-J 245

If the seed argument is not specified when invoking the constructor, the ran­dom generator object uses the processor timer for the seed. This implies that there will be a different random stream of numbers for every simulation run.

A.14.4 Class Poisson

Class Poisson provides random number generation using a Poisson distribu­tion. The description below presents details of the methods in class Poisson.

Poisson public Poisson(double prate, double pperiod, long seed). Construc­tor to initialize a random number generator using a Poisson distribution. Parameters: prate, - the rate of arrival (arrivals per unit time); pperiod, - period considered for arrivals; seed, - the seed for selecting an appro­priate random stream;

public Poisson(double prate, double pperiod). Overloaded constructor.

The constructor is used to create and initialize a random number gen­erator object with the given value of the arrival rate, the period for arrivals, and the value of the seed (optional argument). For example, the following Java code declares and creates a random number generator object poisson_gen with mean 18.45 (arrivals per time unit) and arrivals period of 10.5 time units.

Normal poisson_gen; II declare reference to random generator

poisson_gen = new Poisson(18.45, 10.5); II create rand gen

fdraw public double fdrawO. This method generates a random number using the Poisson distribution with the mean value and the standard deviation given in the constructor. For example, the following Java code generates a random number of type double using random generator poisson_gen (created above) and stores the random number in variable ran_value.

double ran_value;

ran_value = poisson_gen.fdraw(); delay(ran_value); II use random number

If the seed argument is not specified when invoking the constructor, the ran­dom generator object uses the processor timer for the seed. This implies that there will be a different random stream of numbers for every simulation run.

Page 28: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

246 Random Number Generation in Psim-J

A.14.5 Class Urand

Class Umnd provides random number generation using a uniform distribution. The description below presents details of the methods in class Urand.

Urand public Urand(long low, long high, long useed). Constructor for the random number generator with Uniform dist. Parameters: low, - low bound for the range of values; high, - upper bound for the range of values; useed, - the seed to set the random stream.

public Urand(double flow, double thigh, long useed). Constructor for random number generator with uniform dist using values of type double. Parameters: flow, - low bound for the range of values; thigh, - upper bound for the range of values.

public Urand(1ong low, long high). Overloaded constructor.

public Urand(double flow, double thigh). Overloaded constructor.

The constructor is used to create and initialize a random number gener­ator object with the given value of the low bound, high bound, and the value of the seed (optional argument). For example, the following Java code declares and creates a random number generator object unif-gen with low bound of 6.35 and high bound of 35.55.

Normal unif_gen; II declare reference to random generator

unif_gen = new Urand(6.35, 35.55); II create rand gen

fdraw public double fdrawO. This method generates a random number us­ing the uniform distribution with the low and high limits given in the constructor. For example, the following Java code generates a random number of type double using random generator unif_gen (created above) and stores the random number in variable ran_value.

double ran_value;

ran_value = unif_gen.fdraw(); delay(ran_value); II uSe random number

If the seed argument is not specified when invoking the constructor, the ran­dom generator object uses the processor timer for the seed. This implies that there will be a different random stream of numbers for every simulation run.

Page 29: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

Appendix B

BIBLIOGRAPHY

1. Almeida, V.A.F., D.A. Menasce, and D.W. Dowdy. Capacity Planning and Performance Modeling: from Mainframes to Client-server Systems, 1994. Englewood Cliffs: Prentice-Hall.

2. Ash, Carol. The Probability Tutoring Book, Piscataway, NJ: IEEE Press, 1993.

3. Banks, J. J. S. Carson, and B. Nelson Discrete-Event System Simulation. Second ed. Englewood Cliffs, NJ: Prentice-Hall, 1996.

4. Booch, Grady. Object-Oriented Analysis and Design, 2nd ed. Reading, MA: Addison-Wesley, 1994.

5. Budd, Timothy. Understanding Object-Oriented Programming With Java. Updated Edition. Reading: Addison Wesley Longman, 2000.

6. Davis, Alan M. Software Requirements Analysis and Specification. En­glewood Cliffs, NJ: Prentice-Hall, 1990.

7. Deitel, H. M. and P. J. Deitel. Java: How To Program. Third ed. Upper Saddle River: Prentice Hall, 1999.

8. Douglas, Bruce, P. Real- Time UML Second Edition Developing Efficient Objects For Embedded Systems. Reading: Addison Wesley Longman, 2000.

9. Fishwick, Paul A. Simulation Model Design and Execution Building Dig­ital Worlds. Englewood Cliffs, NJ: Prentice-Hall, 1995.

10. Garrido, J. M. Practical Process Simulation Using Object-Oriented Tech­niques and C++. Boston: Artech House, 1999.

247

Page 30: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

248

11. Goodman, Roe, Introduction to Stochastic Models, Reading, MA: Addison­Wesley, 1988.

12. Harrington, Brian E. and Paul A. Fishwick. "A portable Process­Oriented Compiler for Event Driven Simulation," Simulation, Vol. 60, No.6, June 1993, pp 393-409.

13. Hortstmann, Cay S. and Gary Cornell. Core Java 1.2 Volume 1 -Fundamentals. Upper Saddle River: Sun Microsystems Press, Prentice Hall, 1999.

14. Hortstmann, Cay S. and Gary Cornell. Core Java 1.2 Volume 2 - Ad­vanced Features. Upper Saddle River: Sun Microsystems Press, Prentice Hall, 1999.

15. Hyde, Paul. Java Thread Programming. Indianapolis: Sams Publishing, 1999.

16. Jain, Raj. The Art of Computer Systems Performance Analysis. New York: John Wiley, 1991.

17. Jia, Xiaoping. Object-Oriented Software Development Using Java. Prin­ciples, Patterns, and Frameworks. Reading: Addison Wesley Longman, 2000.

18. Kafura, Dennis. Object-Oriented Software Design & Construction with Java. Upper Saddle River: Prentice Hall, 2000.

19. Khoshafian, Setrag. Object Orientation. 2nd ed. New York: John Wiley & Sons, 1995.

20. Kleijnen, Jack P. C. Simulation: A Statistical Perspective. New York: Wiley, 1992.

21. King, Peter J. B. Computer and Communication Systems Performance Modelling. Hemel Hempstead: Prentice-Hall International (UK) Ltd., 1990.

22. Liang, Y. Daniel. Rapid Java Application Development Using Jbuilder 3. Upper Saddle River: Prentice Hall, 2000.

23. Martin, James, and James J. Odell. Object-Oriented Methods: A Foun­dation, UML Edition. 2nd ed. Englewood Cliffs, NJ: Prenticf)-Hall, 1998.

24. Medhi, J. Stochastic Processes. 2nd ed. New York: John Wiley, 1994.

25. Meyer, Bertran. Object-Oriented Software Construction. Hemel Hemp­stead, Herts: Prentice-Hall International (UK) Ltd., 1988.

Page 31: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

Bibliography 249

26. Mitrani, I. Simulation Techniques for Discrete Event Systems. Cam­bridge: Cambridge University Press, 1982 (Reprinted 1986).

27. Molloy, M.K. Fundamentals of Performance Modeling. 1st ed. 1989. New York: MacMillan.

28. Nelson, Barry L. Stochastic Modeling, Analysis and Simulation. New York: McGraw-Hill, 1995.

29. Norton, Scott J. and Dipasquale, Mark D. The Multithreaded Program­ming Guide: Threadtime. Upper Saddle River: Prentice Hall PTR, 1997.

30. Pohl, Ira and Charlie McDowell Java by Dissection: The Essentials of java programming. Reading: Addison Wesley Longman, 2000.

31. Piroumian, Vartan. Java GUI Development. Indianapolis: Sams Pub­lishing, 1999.

32. Rumbaugh, J., M. Blaha, W. Premerlani, F. Eddy, and W. Lorensen. Object-Oriented Modeling and Design. Englewood Cliffs, NJ: Prentice­Hall, 1991.

33. Savitch, Walter. Java: An Introduction To Computer Science fj Pro­gramming. Upper Saddle River: Prentice Hall, 1999.

34. Schwetman, Herb. "Using CSIM to Model Complex Systems." Pro­ceedings of the 1988 Winter Simulation Conference. San Diego, CA, December 1988, pp. 246-253.

35. Selic B., G. Gullekson and P. T. Ward. Real-Time Object-Oriented Modeling. New York: John Wiley, 1994.

36. Tanner, Mike. Practical Queuing Analysis. New York: McGraw-Hill, 1995.

37. Yourdon, Edward. Object-Oriented Systems Design: An Integrated Ap­proach. Englewood Cliffs, NJ: Yourdon Press Prentice-Hall, 1994.

Page 32: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

About the Author

Jose M. Garrido is an assistant professor of computer science at Kennesaw State University in Kennesaw, GA. He was previously in the Department of Computer Science and Mathematics at Davis and Elkins College. Dr. Gar­rido has also been a member of the adjunct faculty in computer science at George Mason University in Fairfax, VA. For more than 15 years, Dr. Gar­rido has been teaching courses related to information technology to students of science and engineering. He holds a Ph.D. in Information Technology and an MS in Computer Science from George Mason University's School of Infor­mation Technology and Engineering. He also holds a M.Sc. in Information Systems from the University of London, and a BS in Electrical Engineering from Universidad de Oriente.

Since the publication of his first book on object-oriented simulation, Dr. Garrido has updated and expanded the Psim simulation package and the PsimL language. He has been applying object-oriented simulation concepts in his courses of operating systems, object-oriented programming and simulation. Dr. Garrido is currently carrying out several applied research projects with simulation and modeling using Java technology. He has redesigned the Psim simulation package and re-implemented it in Java, as a set of software tools for teaching and training students in the modeling and simulation of large and complex systems. Since this is an ongoing project, he will continue to enhance and support Psim.

251

Page 33: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

INDEX

Abstract method, 42 Abstraction, 6, 19 Activities, 131, 181

independent, 151 joint, 151

Activity, 59 Aggregation, 24 Arrays, 38

elements, 38 Arrival time, 78 Arrivals, 203 Association, 23 Availability, 14 Average, 200 Behavior, 6 Black-box, 216 Breakdown, 168 Busy, 175 Capacit1;8 Capacity, 14 Class, 19, 32, 160

access, 32 attributes, 32 base, 40 Condq, 160 decomposition, 32 definitions, 32 derived,25 instantiation, 33 interface, 43 library, 160 members, 32 method,36 methods, 32 object, 160 Process, 71 relationship, 23 Vector, 40

Classification, 20 Collaboration diagram, 161

Collection classes, 40 Communication

channel, 150 Components, 127 Composition, 24 Conceptual model, 17 Condition, 160-161 Conditional waiting, 159 Confidence interval, 210 Constructor, 33 Consumer, 139, 142 Cooperation, 83, 149

period, 149, 156 Cumulative distribution, 199 Cycles, 136 DB,183 Deadlock, 136 Dequeue, 77 Discrete-event, 60 Distributed system, 183 Distribution functions, 200 Distribution, 101, 162 Distributions, 81, 115 Dynamic model, 26 Encapsulation, 19 Entities, 4, 71

active, 71 passive, 71

Entity conceptual, 74, 81 passive, 72 physical, 74, 81, 115

Environment, 74 Estimate, 123 Estimates, 209 Ethernet, 191 Evaluate, 161 Event list, 60-61 Event worldview, 59

253

Page 34: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

254 Index

Event, 27, 197 Events, 57, 75, 83, 205 Exception, 44 Experiment, 197 Experimenting, 6 Exponential, 98, 101, 162 Failure, 202 Fairness, 14 FIFO, 80, 100, 108, 113 Frequency, 198-199 Generalization, 25 Global variables, 37 Graphic model, 5 GUl,93 Histogram, 209 Implementation, 6, 105, 130 Information hiding, 19 Inheritance, 25-26, 40 Instance, 71 Instantiate, 160 Inter-arrival, 98 Interface, 19

graphical, 93 Internet, 3 Interrupt, 168

level, 168 routine, 168

Java, 1,31 applets, 3, 31 apps,31 AWT,93 beans, 3 byte-code, 2 garbage collection, 2 ("JI, 2 JVM,2 packages, 33 portable, 2 servlets, 3 Swing, 93 threads, 2, 45

Joint activity, 149-150 LAN, 183 Library class, 86 Main method, 34 Mathematical model, 5

objects, 5 Mean, 200 Memory-less, 202-203 Message, 27, 150 Method overriding, 41 Method

coopt, 151 signal, 160, 162 wait, 151 waituntil, 160

Model, 5, 55

conceptual, 6 continuous, 11 descriptive, 6 deterministic, 10 development, 11 discrete, 11, 55 implementing, 56 mathematical, 8 mul ti-server, 98 queuing, 73 simulation, 6 stochastic, 10, 75, 80 valid, 215

Modeling, 55 Models, 160 Modularity, 32 Multi-class, 113 Multi-queue, 108 Multi-tasking, 29 Multiple inheritance, 44 Multiple servers, 97 Mutual exclusion, 127 Normal, 162 Object, 19

active, 29, 85 create, 100 message, 19 passive, 85 suspend, 162 terminate, 101

Object-oriented, 1, 20, 72 class, 72 instance, 72

Objects, 32 active, 2, 62, 71 concurrent, 45 creation, 32 manipulation, 32 passive, 2, 62 references, 38

Operation length, 160

Output listing, 134 Performance measures, 108, 110 Performance, 8, 10, 13, 83-84, 116, 177,

184, 208 Physical model, 5 Polymorphism, 43 Preemptive, 168 Priorities, 123 Priority queue, 113 Priority, 113, 123, 167

high, 167 highest, 124 low, 167, 177 same, 124

Probability, 199

Page 35: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

conditional, 199 continuous, 200, 203 density, 200 discrete, 200 measure, 199

Process class, 63 J'rocess definitions, 73 Process interaction, 72 Process object, 60 Process worldview, 59 Process, 59, 71, 127

conceptual, 115 consume, 139 cooperation, 150 create, 101, 109 idle, 80, 83, 115-116 interact, 72 interaction, 127, 181 interrupted, 167 interrupting, 167 master, 149 priority, 168, 181 produce, 139, 141 reactivae, 109 reactivate, 80, 83, 100, 109, 115-116, 151,

162 slave, 149 states, 60 suspend, 81, 83, 100, 109, 116, 128, 142,

151 synchronize, 160 take, 142 terminate, 81, 83, 109, 116 wait, 100, 128, 151

Processes, 175 Procwess

wait, 109 Producer, 139 Producer-consumer, 139 Pseudo-random, 205 Psim-J, 4, 63, 67, 69, 85, 87, 89, 130 Queue discipline, 113 Queue size, 98 Queue, 72, 78, 81, 83, 106, 109, 113, 116,

151, 166 conditional, 160 head, 166 master, 151 priority, 113, 175 remove, 176 simple, 124 slave, 151

Queues, 175 R,80 Random number, 101

generation, 101 Random numbers, 63, 81, 115

Random variable, 199 Random variables, 201 Random, 175 Reliability, 14 Repair, 168 Representation, 4

abstract, 5 Resource pool, 141 Resources, 127, 162

acquire, 128 allocation graph, 128 allocation, 128, 130 available, 128 class, 128 deallocation, 130 held, 127, 129 passive, 127 pool, 127-128, 139 priorities, 136 release, 128-129 released, 160 request, 127-128 synchronization, 127 type, 127-128

Response time, 184 Sample point, 197 Sample space, 197 Seed, 205 Sequence, 76 Server, 73, 83, 116 Servers, 175 Service interval, 98

Index 255

Service period, 80-81, 115, 175 Service station, 110 Service, 176 Set, 198

complement, 198 empty, 198 intersection, 198 membership, 198 union, 198

Simulation clock, 80, 115 Simulation period, 91 Simulation run, 7 Simulation time, 57 Simulation, 3

executive, 129 language, 63 model, 4 package, 4, 63 period, 175

Single-server, 72 Sojourn time, 98, 177 Standard deviation, 162 State diagram, 27

transition, 27 State-transition, 207

Page 36: A SHORT MANUAL FOR PSIM-J - Home - Springer978-1-4615-1319-3/1.pdf · A Short Manual For Psim-J 221 A.3 DEFINING PROCESSES IN A SIMULATION MODEL A simulation model that applies the

256 Index

Static model, 22 description, 22

Stations, 108 Stereotype, 29 Stochastic matrices, 207 Stop, 181 Subclass, 40, 42

constructor, 42 Success, 202 Successive, 205 Synchronization, 83, 149, 157 Synchronize, 156 System factors, 13 System, 4

single server, 77 Thread notify, 52 Thread reeference, 47 Thread, 28, 49, 51, 150 Throughput, 98, 184

Timings, 162 Trace, 8, 10 Traces, 209 Transition, 206 UML, 6, 17-18, 20, 71, 75

actors, 21 diagrams, 20, 71 state, 27 stereotype, 21-22 use case, 21

Universe, 198 Utilization, 98 Validation, 213 Verification, 213 Waiting period, 123 Waiting time, 78, 177 Workload, 13, 85, 98, 184 Workstation, 183 World views, 58


Recommended