sc_mutex.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2006 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.4 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_mutex.h -- The sc_mutex primitive channel class.
00021 
00022   Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033     
00034  *****************************************************************************/
00035 //$Log: sc_mutex.h,v $
00036 //Revision 1.1.1.1  2006/12/15 20:31:35  acg
00037 //SystemC 2.2
00038 //
00039 //Revision 1.2  2006/01/03 23:18:26  acg
00040 //Changed copyright to include 2006.
00041 //
00042 //Revision 1.1.1.1  2005/12/19 23:16:43  acg
00043 //First check in of SystemC 2.1 into its own archive.
00044 //
00045 //Revision 1.10  2005/09/15 23:01:51  acg
00046 //Added std:: prefix to appropriate methods and types to get around
00047 //issues with the Edison Front End.
00048 //
00049 //Revision 1.9  2005/06/10 22:43:55  acg
00050 //Added CVS change log annotation.
00051 //
00052 
00053 #ifndef SC_MUTEX_H
00054 #define SC_MUTEX_H
00055 
00056 #include "sysc/kernel/sc_event.h"
00057 #include "sysc/communication/sc_prim_channel.h"
00058 #include "sysc/communication/sc_mutex_if.h"
00059 
00060 namespace sc_core {
00061 
00062 // ----------------------------------------------------------------------------
00063 //  CLASS : sc_mutex
00064 //
00065 //  The sc_mutex primitive channel class.
00066 // ----------------------------------------------------------------------------
00067 
00068 class sc_mutex
00069 : public sc_mutex_if,
00070   public sc_prim_channel
00071 {
00072 public:
00073 
00074     // constructors and destructor
00075 
00076     sc_mutex();
00077     explicit sc_mutex( const char* name_ );
00078     virtual ~sc_mutex();
00079 
00080 
00081     // interface methods
00082 
00083     // blocks until mutex could be locked
00084     virtual int lock();
00085 
00086     // returns -1 if mutex could not be locked
00087     virtual int trylock();
00088 
00089     // returns -1 if mutex was not locked by caller
00090     virtual int unlock();
00091 
00092     virtual const char* kind() const
00093         { return "sc_mutex"; }
00094 
00095 protected:
00096 
00097     // support methods
00098 
00099     bool in_use() const
00100     { return ( m_owner != 0 ); }
00101 
00102 protected:
00103 
00104     sc_process_b* m_owner;
00105     sc_event      m_free;
00106 
00107 private:
00108 
00109     // disabled
00110     sc_mutex( const sc_mutex& );
00111     sc_mutex& operator = ( const sc_mutex& );
00112 };
00113 
00114 } // namespace sc_core
00115 
00116 #endif
00117 
00118 // Taf!

Generated on Wed Jan 21 15:32:06 2009 for SystemC by  doxygen 1.5.5