class Fifo_system

Class Fifo_system: Class that comprises the individual fifos.

Public Methods

[more] Creation and removal of the fifo system and the fifos
[more] Read/write and control access to the fifos
[more] Access to information about the fifo system
[more] Access to information about the fifos


Documentation

Class Fifo_system: Class that comprises the individual fifos. The fifos themselves are objects that reside in shared memory. The Fifo_sytem itself is an object in the local address space of the process and regulates the access to the fifos. This is necessary as different processes attach the same shared memory at different address locations.
The class Fifo_sytem allows to create and delete fifos, coordinates the read/write operations and can return various status information about the fifo system.
Note: This class (and not the Fifo class) controls all the shared resources that controls the access to the fifos.

Modifications:

o Creation and removal of the fifo system and the fifos

o Fifo_system(char* filename, int nfifos, int fifo_depth)
Creates the Fifo system. Creates/attaches to the shared memory and semaphores and (possibly) initialises them.
Parameters:
filename - : project file for the shared resources (see package otools)
nfifos - : maximum number of fifos.
fifo_depth - : default depth of the fifos.

o ~Fifo_system()
Destructor

oint remove_fifo_system()
Removes the fifo system. The destructor only deletes the fifo system for the calling process and deletes the shared resources only if the calling process is the last one to detach. remove_fifo_system in contrast forces the removal of the system.

oFifo* create_fifo(const char* name, const char* type, Fifo::sFifo_mode mode, int slot_nb = -1)
Creates a fifo in the fifo system. Checks whether the fifo already exists or has to be created. If we attach to an existing fifo, check the mode.
Parameters:
name - : name of the fifo - see constructor of class fifo for details.
type - : type of the fifo - see constructor of class fifo for details.
mode - : mode of the fifo - see constructor of class fifo for details.
slot_nb - : index of the fifo in the array of fifos - see constructor of class fifo for details.
Returns:
Pointer fo the fifo or NULL.

oint delete_fifo( Fifo* pFifo )
Delete the fifo pointed to by pFifo. Note that the INPUT fifo cannot be deleted.

oint delete_fifo(const char* name )
Delete the fifo with the name name

oint remove_fifo(const char* name)
Removes the fifo - same of delete - do not use - will become obsolte

oint empty_fifo( Fifo* pFifo )
Empties a fifo. It reads all remaining fifo_entries in the fifo and releases them, i.e. they are put back into the INPUT fifo.

oint empty_fifo( const char* pcFifoName )
Empties a fifo. It reads all remaining fifo_entries in the fifo and releases them, i.e. they are put back into the INPUT fifo.

o Read/write and control access to the fifos

oint write_fifo(const char* fifo_name, Fifo_entry &fev)
Write the fifo entry fev into the fifo named name.
Returns:
0 if success, -1 if error.

oint write_fifo(Fifo* fifo, Fifo_entry &fev)
Write the fifo entry fev into the fifo pointed to by fifo.
Returns:
0 if success, -1 if error.

oint read_fifo(const char* fifo_name, Fifo_entry &fev, int mode = -1 )
Read the fifo given by the string name.
Parameters:
- fifo_name name of the fifo
fev - reference to the fifo entry
mode - (optional) if not given then the default mode from the fifo header will be taken.
Returns:
0 if success, -1 if error.

oint read_fifo(Fifo* fifo, Fifo_entry &fev, int mode = -1 )
Overloaded read_fifo to allow reading a fifo pointed to by a pointer

oint unblock_fifo( const Fifo* fifo ) const
Unlocks the fifo pointed to by fifo

oint unblock_fifo( const char* fifo_name ) const
Unlocks the named fifo

oint lock()
Locks the entire fifo system.

oint unlock()
Unlocks the entire fifo system.

o Access to information about the fifo system

ovoid print()
Prints system information to cout

oint get_status() const
Returns the status of the system.
Returns:
unused, in_use, locking, locked, error

oconst char* get_name() const
Returns the name of the fifo system

opid_t get_creator() const
Returns the PID of the process that originally created the system

oint get_nb_fifos() const
Returns the maximum number of fifos.

oint get_fifo_depth() const
Returns the depth of the fifos.

oint get_nproc_att() const
Returns the number of processes that are currently attached to the fifo.

oFifo* find_fifo(const char* name) const
Given the name of a fifo, return a pointer to it.

o Access to information about the fifos

oint get_nproc_waiting(const Fifo* fifo) const
Return the number of processes that are waiting on the fifo *fifo for events.

oint get_nproc_waiting(const char* Fifo_name ) const
Return the number of processes that are waiting on the fifo Fifo_name for events.

oint get_fifo_cnt( Fifo* fifo ) const
Return the number of events in the fifo *fifo.

oint get_fifo_cnt( const char* Fifo_name ) const
Return the number of events in the fifo named Fifo_name.

oint get_fifo_cnts( int &nFifos, int* &addr ) const
Get the number of events in every fifo. This member function returns the exact number of all the fifos at a given point (they are the semaphore counts of the system).
Parameters:
nFifos - reference to the number of fifos.
addr - reference to the address of the array with the values
Returns:
0 if success, -1 otherwise. Note: The client is responsible for deleting the array *addr.

oint get_fifo_locks( int &nFifos, int* &addr ) const
Returns the lock semaphores for every fifo. The same note as get_fifo_cnts applies here.


This class has no child classes.
Friends:
class Fifo
class Fifo_iterator
Author:
C.Witzig
Date: Nov 20, 1997
Version:
Last update: Dec 7, 1999

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.