00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2014 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 (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.accellera.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 CHANGE LOG IS AT THE END OF THE FILE 00025 *****************************************************************************/ 00026 00027 #ifndef SC_MUTEX_H 00028 #define SC_MUTEX_H 00029 00030 #include "sysc/kernel/sc_event.h" 00031 #include "sysc/kernel/sc_object.h" 00032 #include "sysc/kernel/sc_wait.h" 00033 #include "sysc/communication/sc_mutex_if.h" 00034 00035 // 02/24/2015 GL: to include the struct chnl_scoped_lock 00036 #include "sysc/communication/sc_prim_channel.h" 00037 00038 namespace sc_core { 00039 00040 /**************************************************************************/ 00046 class sc_mutex 00047 : public sc_mutex_if, 00048 public sc_object 00049 { 00050 public: 00051 00052 // constructors and destructor 00053 00054 sc_mutex(); 00055 explicit sc_mutex( const char* name_ ); 00056 virtual ~sc_mutex(); 00057 00058 00059 // interface methods 00060 00061 // blocks until mutex could be locked 00062 00067 // 08/19/2015 GL: modified for the OoO simulation 00068 virtual int lock( int ); 00069 00070 // returns -1 if mutex could not be locked 00071 virtual int trylock(); 00072 00073 // returns -1 if mutex was not locked by caller 00074 virtual int unlock(); 00075 00076 virtual const char* kind() const 00077 { return "sc_mutex"; } 00078 00079 protected: 00080 00081 // support methods 00082 00083 bool in_use() const 00084 { return ( m_owner != 0 ); } 00085 00086 protected: 00087 00088 sc_process_b* m_owner; 00089 sc_event m_free; 00090 00094 // 02/10/2015 GL. 00095 mutable CHNL_MTX_TYPE_ m_mutex; 00096 00097 private: 00098 00099 // disabled 00100 sc_mutex( const sc_mutex& ); 00101 sc_mutex& operator = ( const sc_mutex& ); 00102 }; 00103 00104 } // namespace sc_core 00105 00106 //$Log: sc_mutex.h,v $ 00107 //Revision 1.4 2011/08/26 20:45:41 acg 00108 // Andy Goodrich: moved the modification log to the end of the file to 00109 // eliminate source line number skew when check-ins are done. 00110 // 00111 //Revision 1.3 2011/02/18 20:23:45 acg 00112 // Andy Goodrich: Copyright update. 00113 // 00114 //Revision 1.2 2010/11/02 16:31:01 acg 00115 // Andy Goodrich: changed object derivation to use sc_object rather than 00116 // sc_prim_channel as the parent class. 00117 // 00118 //Revision 1.1.1.1 2006/12/15 20:20:04 acg 00119 //SystemC 2.3 00120 // 00121 //Revision 1.2 2006/01/03 23:18:26 acg 00122 //Changed copyright to include 2006. 00123 // 00124 //Revision 1.1.1.1 2005/12/19 23:16:43 acg 00125 //First check in of SystemC 2.1 into its own archive. 00126 // 00127 //Revision 1.10 2005/09/15 23:01:51 acg 00128 //Added std:: prefix to appropriate methods and types to get around 00129 //issues with the Edison Front End. 00130 // 00131 //Revision 1.9 2005/06/10 22:43:55 acg 00132 //Added CVS change log annotation. 00133 // 00134 00135 #endif 00136 00137 // Taf!