Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages   Examples  

Bin Class Reference
[Synchronisation]

Inherits Observable< BinObserver >, DefLabeledObject, StatisticObject, TraceProducer, and ReportProducer.


Detailed Description

Bin is a single bounded (number of token greater or equal to zero) token abstract resource.

Author:
Ralf Gerstenberger

Note:
Bin supports Observation

Bin supports Trace

Bin supports Report

Bin is a low bounded (token number >= 0) token abstract resource for synchronising Process objects. A process is blocked in take() if the requested number of token is greater than the available number of token. It is reactivated when enough token are given (back) to the resource. If multiple processes are waiting for reactivation process-priority and FIFO-strategy are used to choose the process. Bin is generally used for producer and consumer synchronisation.

Since:
1.0


Public Member Functions

 Bin (Simulation *s, Label l, unsigned int startTokenNumber, BinObserver *o=0)
 Construction.

 ~Bin ()
 Destruction.

const std::list< Process * > & getWaitingProcessList () const
 Get list of blocked processes.

virtual TracegetTrace () const
 Get pointer to trace.

virtual void report (Report *r)
 Generate report.

Token management
unsigned int take (unsigned int n)
 Take n token.

void give (unsigned int n)
 Give n token.

unsigned getTokenNumber () const
 Number of tokens available.

Statistics
virtual void reset ()
 reset statistics

unsigned int getUsers () const
 Number of takes.

unsigned int getProviders () const
 Number of gives.

unsigned int getInitial () const
 Initial number of token.

unsigned int getMin () const
 Min number of token.

unsigned int getMax () const
 Max number of token.

double getAVFreeToken () const
 Average free token.

double getAVWaitTime () const
 Average waiting time.


Static Public Attributes

Trace MarkTypes
These MarkTypes and Tags are used to trace Bin events. A TraceConsumer can use these constants to identify trace events send by Bin.

const MarkTypeId baseMarkId = 1000
const MarkType markCreate = MarkType("create", baseMarkId+1, typeid(Bin))
const MarkType markDestroy = MarkType("destroy", baseMarkId+2, typeid(Bin))
const MarkType markTakeFail = MarkType("takeFail", baseMarkId+10, typeid(Bin))
const MarkType markTakeSucceed = MarkType("takeSucceed", baseMarkId+11, typeid(Bin))
const MarkType markGive = MarkType("give", baseMarkId+12, typeid(Bin))
const MarkType markChangeTokenNumber = MarkType("changeTokenNumber", baseMarkId+20, typeid(Bin))
const TagId baseTagId = 1000
const Tag tagCurrent = Tag(baseTagId+1)
const Tag tagTokenNumber = Tag(baseTagId+2)


Constructor & Destructor Documentation

Bin Simulation s,
Label  l,
unsigned int  startTokenNumber,
BinObserver o = 0
 

Construction.

Parameters:
s pointer to Simulation object
l label for this object
startTokenNumber initial number of token in Bin
o initial observer


Member Function Documentation

unsigned int take unsigned int  n  ) 
 

Take n token.

Takes n token from resource if possible. Otherwise the current process is blocked until enough token are available. If a blocked process is interrupted it is reactivated and the function returns 0. Without interruption take returns n.

void give unsigned int  n  ) 
 

Give n token.

Gives n token to resource. Blocked process objects could be activated by this call.


Generated on Mon Aug 11 10:36:07 2003 for ODEMx by doxygen1.3