psimjava
Class Res

java.lang.Object
  extended by psimjava.Res

public class Res
extends java.lang.Object

PsimJ Java package for OO simulation

Object-oriented simulation package, process interaction approach.

(C) J. M. Garrido. June 2000, 2003, 2004, 2007 Resource pools (containers).

The class 'Res' controls the declaration, allocation and deallocation of resource pools. If a process requesting a certain number of resource items from an object of type 'Res' and are not available, then the process is enqueued into the resource's priority queue. When a process releases a number of resource items, the queue is examined for the waiting processes. A process dequeued is checked if its request can be granted.

File: Res.java


Constructor Summary
Res(java.lang.String name, int n)
          Constructor for the resurce pool object
 
Method Summary
 void acquire(int num)
          This method allows the requesting process to acquire a number of resource items.
 int length()
          This method gets the number of waiting processes.
 int num_avail()
          This method gets the number of available resource items available in the resource pool.
 void release(int num)
          This dunction releases resources from the calling process, and makes them available in the resource pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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
Method Detail

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.

num_avail

public int num_avail()
This method gets the number of available resource items available in the resource pool.

Returns:
int a number that represents the number of available resource items.

length

public int length()
This method gets the number of waiting processes. These processes have been suspended because of their previuos resource requests.

Returns:
int Number of Waiting processes

release

public void release(int num)
This dunction releases resources from the calling process, and makes them available in the resource pool. Then the method reactivates any waiting processes.

Parameters:
num - int, the number of resource items released by the calling process.