src/sysc/communication/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-2005 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 
00036 #ifndef SC_MUTEX_H
00037 #define SC_MUTEX_H
00038 
00039 #include "sysc/kernel/sc_event.h"
00040 #include "sysc/communication/sc_prim_channel.h"
00041 #include "sysc/communication/sc_mutex_if.h"
00042 
00043 namespace sc_core {
00044 
00045 // ----------------------------------------------------------------------------
00046 //  CLASS : sc_mutex
00047 //
00048 //  The sc_mutex primitive channel class.
00049 // ----------------------------------------------------------------------------
00050 
00051 class sc_mutex
00052 : public sc_mutex_if,
00053   public sc_prim_channel
00054 {
00055 public:
00056 
00057     // constructors
00058 
00059     sc_mutex();
00060     explicit sc_mutex( const char* name_ );
00061 
00062 
00063     // interface methods
00064 
00065     // blocks until mutex could be locked
00066     virtual int lock();
00067 
00068     // returns -1 if mutex could not be locked
00069     virtual int trylock();
00070 
00071     // returns -1 if mutex was not locked by caller
00072     virtual int unlock();
00073 
00074     virtual const char* kind() const
00075         { return "sc_mutex"; }
00076 
00077 protected:
00078 
00079     // support methods
00080 
00081     bool in_use() const
00082         { return ( m_owner != 0 ); }
00083 
00084 protected:
00085 
00086     sc_process_b* m_owner;
00087     sc_event      m_free;
00088 
00089 private:
00090 
00091     // disabled
00092     sc_mutex( const sc_mutex& );
00093     sc_mutex& operator = ( const sc_mutex& );
00094 };
00095 
00096 } // namespace sc_core
00097 
00098 #endif
00099 
00100 // Taf!

Generated on Wed Apr 25 13:53:25 2007 for SystemC by  doxygen 1.5.1