psimjava
Class Bin

java.lang.Object
  extended by psimjava.Bin

public class Bin
extends java.lang.Object

This class controls the declaration, allocation and deallocation resources.

Psim-J Object-oriented simulation, process interaction approach.

(C)Jose M. Garrido. June 2000, 2003, 2004, 2007

If a process requesting a certain number of resource items in the resource pool (of type 'Bin') are not available, then the process is enqueued into the corresponding priority queue. When a process releases a number of resource items, then the queues are examined for waiting process.

File: Bin.java


Constructor Summary
Bin(java.lang.String name, int n)
          Constructor initializes Bin object with a title and the number of available resource items.
 
Method Summary
 void give(int num)
          Current process deposits a number of resource items in the Bin object
 int length()
          Returns number of of processes waiting on the Bin object
 int num_avail()
          Returns number of available resource items in Bin object
 void report()
          Internal method for the actual reporting of Bin object usage, called by the executive.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bin

public Bin(java.lang.String name,
           int n)
Constructor initializes Bin object with a title and the number of available resource items.

Parameters:
name - title of Bin object created
n - initial number of Bin items
Method Detail

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.

num_avail

public int num_avail()
Returns number of available resource items in Bin object


length

public int length()
Returns number of of processes waiting on the Bin object


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

report

public void report()
Internal method for the actual reporting of Bin object usage, called by the executive.