Changeset 2212 in Sophya for trunk/SophyaLib


Ignore:
Timestamp:
Oct 15, 2002, 5:48:53 PM (23 years ago)
Author:
ansari
Message:

Mise a jour de la documentation SysTools, Reza 15/10/2002

Location:
trunk/SophyaLib/SysTools
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SysTools/cxxcmplnk.cc

    r2190 r2212  
    3636
    3737/* --Methode-- */
     38/*!
     39  Constructor
     40  \param fglibsophya : if \c true libsophya.so is used when linking
     41  \param fglibextsophya : if \c true libextsophya.so is used when linking
     42  \param fglibpi : if \c true libPI.so is used when linking
     43*/
    3844CxxCompilerLinker::CxxCompilerLinker(bool fglibsophya, bool fglibextsophya, bool fglibpi)
    3945  : verbose(false)
     
    136142
    137143/* --Methode-- */
     144/*!
     145  Compiles the file \c name using the C++ compiler driver and produces
     146  the output object file \c oname. If no output name is specified,
     147  a default output file name is made from the input name, with the
     148  suffix .o , the in temporary directory.
     149  \param name : input C++ source file
     150  \param oname : output object file
     151*/
    138152int CxxCompilerLinker::Compile(string const & name, string & oname)
    139153{
     
    160174
    161175/* --Methode-- */
     176/*!
     177  Creates a shared library from the object file \c oname.
     178  If no output name \c soname is specified,
     179  a default output file name is made from the object name, with the
     180  suffix .so , in the temporary directory.
     181  \param oname : input object file
     182  \param soname : shared library name
     183*/
    162184int CxxCompilerLinker::BuildSO(string const & oname, string & soname)
    163185{
  • trunk/SophyaLib/SysTools/cxxcmplnk.h

    r1900 r2212  
    2323  virtual int           BuildSO(string const & oname, string & soname);
    2424
     25  //! Adds compilation options \c opt . Appended to the present option string.
    2526  inline void           AddCompileOptions(string const & opt)
    2627  { compOptions += " " + opt; }
     28  //! Sets the compilation options.
    2729  inline void           SetCompileOptions(string const & opt = "")
    2830  { compOptions = opt; }
     31  //! Returns the currently defined compilation options.
    2932  inline string         GetCompileOptions()
    3033  { return compOptions; }
    3134
     35  //! Adds link options \c opt . Appended to the present option string.
    3236  inline void           AddLinkOptions(string const & opt)
    3337  { linkOptions += " " + opt; }
     38  //! Sets the link options.
    3439  inline void           SetLinkOptions(string const & opt = "")
    3540  { linkOptions = opt; }
    3641  inline string         GetLinkOptions()
     42  //! Returns the currently defined link options.
    3743  { return linkOptions; }
    3844
     45  //! Sets the temporary directory path.
    3946  inline void           SetTmpDir(string const & tmpdir)
    4047  { tmpDir = tmpdir; }
     48  //! returns the currently defined temporary directory path.
    4149  inline string         GetTmpDir()
    4250  { return tmpDir; }
    43 
     51 
     52  //! Activate (or deactivate) the verbose mode.
    4453  inline void           SetVerbose(bool fg=false)
    4554  { verbose = fg; }
  • trunk/SophyaLib/SysTools/resusage.cc

    r2191 r2212  
    1616  The information should be updated through the call to the
    1717  Update() method.
     18  Note: The information is obtained through \c getrusage()   
     19  and \c getrlimit() system calls, and depending on the OS,
     20  not all of the memory usage values are correctly filled.
     21  \code
     22  // How to check resource usage for a given part of the program
     23  ResourceUsage res;
     24  // --- Part of the program to be checked : Start
     25  // ...
     26  res.Update();
     27  cout << " Memory size increase (KB):" << res.getDeltaMemorySize() << endl;
     28  cout << " Resource usage info : \n" << res << endl;
     29  \endcode
    1830*/
    19 
     31/*!
     32  Constructor. the \b Update() method is called.
     33*/
    2034ResourceUsage::ResourceUsage()
    2135{
     
    4761 
    4862}
    49 
     63/*!
     64   Destructor.
     65*/
    5066ResourceUsage::~ResourceUsage()
    5167{
     
    5874}
    5975
     76/*!
     77  Update the CPU and memory usage information.
     78*/
    6079int ResourceUsage::Update()
    6180{
     
    82101}
    83102
     103/*!
     104   Prints the CPU and memory usage information.
     105   \param os : The output stream
     106   \param lp : The print level (0 .. 2)
     107   \param upd : if \c true , the Update method is called.
     108*/
    84109void ResourceUsage::Print(ostream& os, int lp, bool upd)
    85110{
  • trunk/SophyaLib/SysTools/resusage.h

    r2159 r2212  
    2424  // Memory usage in kilo-bytes 
    2525  // NOTE: getDataSize() getStackSize() retournent des valeurs bizarres
     26  //! Returns the current memory (Resident) size (in kilo-bytes)
    2627  inline uint_8 getMemorySize() { return cur_rss; }
     28  //! Returns the maximum allowed memory size: Min( \c MaxResidentSize , \c MaxDataSize ))
    2729  inline uint_8 getMaxMemorySize()
    2830    { return((getMaxResidentSize()<getMaxDataSize()) ?
    2931             getMaxResidentSize() :getMaxDataSize() ); }
     32  //! Returns the increase in memory usage since the previous call to \b Update()
    3033  inline uint_8 getDeltaMemorySize() { return delta_rss; }
    3134
     35  //! Returns the maximum allowd data segment size (in kilo-bytes)
    3236  inline uint_8 getMaxDataSize() { return((max_datasz>0)?max_datasz:1024); }
     37  //! Returns the current data segment size (in kilo-bytes)
    3338  inline uint_8 getDataSize() { return cur_datasz; } 
     39  //! Returns the maximum allowed resident size (in kilo-bytes)
    3440  inline uint_8 getMaxResidentSize() { return((max_rss>0)?max_rss:1024); }
     41  //! Returns the current resident memory size (in kilo-bytes)
    3542  inline uint_8 getResidentSize() { return cur_rss; }
     43  //! Returns the maximum allowed stack size (in kilo-bytes)
    3644  inline uint_8 getMaxStackSize() { return max_stack; }
     45  //! Returns the current stack size (in kilo-bytes)
    3746  inline uint_8 getStackSize() { return cur_stack; }
    3847
    3948 
    4049  // Time in milli-second
     50  //! Returns the total CPU time used (in milli-second)
    4151  inline uint_8 getCPUTime() { return cur_tottm; }
     52  //! Returns the total elapsed time (in milli-second)
    4253  inline uint_8 getElapsedTime() { return elapsed_time; }
     54  //! Returns the average load ( CPU time / elapsed time)
    4355  inline double  getAverageCPULoad()
    4456    { return ((elapsed_time>1) ? (double)cur_tottm/(double)elapsed_time: 1.);}
    4557
     58  //! Returns the CPU time used since the previous call to \b Update() (in milli-second)
    4659  inline uint_8 getDeltaCPUTime() { return delta_tottm; }
     60  //! Returns the elapsed time since the previous call to \b Update() (in milli-second)
    4761  inline uint_8 getDeltaElapsedTime() { return delta_elapsed_time; }
     62  //! Returns the CPU load since the previous call to \b Update()
    4863  inline double  getCPULoad()
    4964    { return ((delta_elapsed_time>1) ? (double)delta_tottm/(double)delta_elapsed_time: 1.);}
    5065
    5166
     67  //! Returns the total CPU time (in milli-second)
    5268  inline uint_8 getTotalCPUTime() { return cur_tottm; }
     69  //! Returns the CPU time in user mode (in milli-second)
    5370  inline uint_8 getUserCPUTime() { return cur_usrtm; }
     71  //! Returns the CPU time in system mode (in milli-second)
    5472  inline uint_8 getSysCPUTime() { return cur_systm; }
    5573
    5674
    5775  void  Print(ostream& os, int lp=0, bool upd=true);
     76  //! Alias for the \b Print() method.
    5877  inline void print(ostream& os, int lp=0, bool upd=true){ Print(os,lp,upd); }
    5978
     
    81100};
    82101
     102//! Prints the resource usage information on the output stream
    83103inline ostream& operator << (ostream& os, ResourceUsage& ru)
    84104{ ru.Print(os,0,true); return(os); }
  • trunk/SophyaLib/SysTools/timing.c

    r1783 r2212  
    3737 
    3838/* Nouvelle-Fonction */
     39/*!
     40   \ingroup SysTools
     41   Initializes CPU and elapsed time timer (C function).
     42   The values of the CPU and elapsed time can then be printed
     43   using \b PrtTim()
     44*/
    3945void InitTim(void)
    4046{
     
    4551 
    4652/* Nouvelle-Fonction */
    47 void PrtTim(char *Comm)
     53/*!
     54   \ingroup SysTools
     55   Prints the values of the CPU and elapsed time, since call to \b InitTim().
     56*/
     57void PrtTim(const char * Comm)
    4858{
    4959float tcal,tcalt;
  • trunk/SophyaLib/SysTools/timing.h

    r219 r2212  
    1010
    1111void InitTim(void);                                                             
    12 void PrtTim(char *Comm);                                                       
     12void PrtTim(const char * Comm);                                                       
    1313                                                                               
    1414#ifdef __cplusplus
  • trunk/SophyaLib/SysTools/zthread.cc

    r1612 r2212  
    55#include <stdlib.h>
    66#include <stdio.h>
     7
     8/*!
     9  \class SOPHYA::ZThread
     10  \ingroup SysTools
     11  This class provides an interface for creating and controlling threads.
     12  The implementation uses the POSIX thread interface.
     13  The ZThread objects can be sub classed with the redefinition of
     14  the \c run() method which then performs the task.
     15  The default \c run() method of the base class can be used directly
     16  to perform computation through a function (see \b setAction() method)
     17  \sa SOPHYA::ZMutex
     18  The following sample code shows the usage of ZThread object
     19  to run simultaneously to functions to perform computation.
     20
     21  \code
     22  // The functions to perform computing
     23  void fun1(void *arg) { }
     24  void fun2(void *arg) { }
     25  // ...
     26  ZThread zt1;
     27  zt1.setAction(fun1, arg[1]);
     28  ZThread zt2;
     29  zt2.setAction(fun2, arg[1]);
     30  cout << " Starting threads ... " << endl;
     31  zt1.start();
     32  zt2.start();
     33  cout << " Waiting for threads to end ... " << endl; 
     34  zt1.join();
     35  zt2.join();
     36  \endcode
     37*/
    738
    839#define CheckSt(st_, strg_)  if (st_ != 0)  perror(strg_);
     
    2455
    2556/* ------ Classe ZThread  -------  */
    26 
     57/*!
     58  Constructor, with optional specification of the thread stack size.
     59*/
    2760ZThread::ZThread(size_t stacksize)
    2861{
     
    3972}
    4073
     74/*!
     75  Method which starts the thread.
     76*/
    4177void ZThread::start()
    4278{
     
    5490}
    5591
    56 
     92/*!
     93  Calls the pthread_cancel. Can be used to stop a running thread.
     94*/
    5795void ZThread::cancel()
    5896{
     
    64102
    65103
     104/*!
     105  Waits for the thread to terminate.
     106*/
    66107void ZThread::join()
    67108{
     
    73114}
    74115
     116/*!
     117  This virtual method can be redefined in the derived class, in order
     118  to perform the actual computation.
     119*/
    75120void ZThread::run()
    76121{
     
    82127
    83128/* ------ Classe ZMutex -------  */
     129/*!
     130  \class SOPHYA::ZMutex
     131  \ingroup SysTools
     132  This class implements an interface to the Mutual Exclusion objects
     133  of the POSIX threads.
     134  The ZMutex objects should be used to control acces from different threads
     135  to common objects through the \b lock() and \b unlock() methods. 
     136  \sa SOPHYA::ZSync
     137*/
    84138
     139/*!
     140  Constructor: Creates a associated pair of POSIX \c pthread_mutex_t
     141  and \c pthread_cond_t objects
     142*/
    85143ZMutex::ZMutex()
    86144{
     
    100158}
    101159
     160/*!
     161  \class SOPHYA::ZSync
     162  \ingroup SysTools
     163  This class can be used to insure that the execution of a given
     164  part of the code is synchronised, i.e. only a single thread
     165  goes through this at a given time.
     166  The constructor acquires a lock on given \b ZMutex object,
     167  which is released by the destructor.
     168  The ZSync object should then be instanciated at the beginning of
     169  the synchronised instruction bloc.
     170  \sa SOPHYA::ZMutex
     171*/
  • trunk/SophyaLib/SysTools/zthread.h

    r1612 r2212  
    1414
    1515typedef void (* ZThreadAction) (void *);
    16  
     16
     17/*!
     18  \class SOPHYA::ZThreadExc
     19  \ingroup SysTools
     20  This exception class is used by the classes implementing the interface
     21  to the POSIX threads (\b ZThread ...)
     22*/ 
    1723class ZThreadExc : public PException {
    1824public:
     
    3137  virtual void  run();
    3238
     39  //! Sets the return code for the thread object
    3340  inline void   setRC(int rc) { _rc = rc; }
     41  //! Return the value of the return code for the thread object
    3442  inline int    getRC(int rc) { return(_rc);
    3543 }
     
    6169  explicit      ZMutex();
    6270  virtual       ~ZMutex();
     71  //! Locks the mutex object
    6372  inline void   lock()
    6473    { pthread_mutex_lock(_mutx); }
     74  //! Unlocks the mutex object
    6575  inline void   unlock()
    66     { pthread_mutex_unlock(_mutx); }
     76    { pthread_mutex_unlock(_mutx); }
     77  //! Waits for a condition change
    6778  inline void   wait()
    6879    { pthread_cond_wait(_condv, _mutx); }
     80  //! Signal a condition change on the mutex object
    6981  inline void   signal()
    7082  { pthread_cond_signal(_condv); }
     83  //! Broadcasts a condition change on the mutex object
    7184  inline void   broadcast()
    7285  { pthread_cond_broadcast(_condv); }
     
    8194public:
    8295  explicit inline  ZSync(ZMutex & mtx) {_mtx = &mtx; mtx.lock(); }
    83   inline           ~ZSync() { _mtx->unlock(); }
     96  inline           ~ZSync() { if (_mtx) _mtx->unlock(); }
    8497
    8598private:
Note: See TracChangeset for help on using the changeset viewer.