|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--simulator.Queue
This class implements a circular-shared-queue for string elements. The acesses to the queue are im mutual exclusion to prevent theads conflict. To prevent that the queue become full two semaphore array are required and are used as producer-consumer. So the initialization of this semaphores are made by user that can use for examples a queue of 10 elements, but 6 of one type, and 4 of another type. When one of this type is finished the process is suspend until the resources it needs become free.
Field Summary | |
protected Semaphore[] |
availableCells
This is the array of semaphore that contains the available resources of the index-array type |
(package private) int |
countElem
The actual number of elements that the queue contains |
(package private) int |
head
The pointer to head of queue |
protected Semaphore |
mutex
the mutex to prevent conflict in shared queue |
(package private) int |
numElem
This contain the dimansion of the queue |
protected Semaphore[] |
presentMessage
This is the array of semaphore that contains the occupied resources of the index-array type |
private java.lang.String[] |
Q
This is the array that contain the string values |
(package private) int |
tile
The pointer to tile of queue |
Constructor Summary | |
Queue(int numElem,
Semaphore[] availableCells,
Semaphore[] presentMessage)
Initialize the shared queue |
Method Summary | |
(package private) java.lang.String |
get(java.lang.String name,
int sorg)
Get a string from the sorg index of array in the queue |
(package private) void |
put(java.lang.String name,
java.lang.String s,
int dest)
Put the string s in the queue using the dest index of array |
Methods inherited from class java.lang.Object |
|
Field Detail |
private java.lang.String[] Q
int numElem
int countElem
int head
int tile
protected Semaphore[] availableCells
protected Semaphore[] presentMessage
protected Semaphore mutex
Constructor Detail |
public Queue(int numElem, Semaphore[] availableCells, Semaphore[] presentMessage)
numElem
- number of total element of the cellavailableCells
- the semaphore array (must be just initialized) for
available resourcespresentMessage
- the semaphore array (must be just initialized) for
occupied resourcesavailableCells
,
presentMessage
Method Detail |
void put(java.lang.String name, java.lang.String s, int dest)
name
- the name of process that call put (actual never used)s
- the string to insert in the queuedest
- the index of array (type of resources)java.lang.String get(java.lang.String name, int sorg)
name
- the name of process that call put (actual never used)sorg
- the index of array (type of resources)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |