Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

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

Generated on Fri Jan 14 08:29:03 2005 for SystemC2.1beta11(excludingMSLib)(IncludingSCV)\nProvidedby:www.openverificationfoundation.org by doxygen1.2.18