SystemC  Recoding Infrastructure for SystemC v0.6.2 derived from Accellera SystemC 2.3.1
Accellera SystemC proof-of-concept library
sc_mutex.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_mutex.h -- The sc_mutex primitive channel class.
21 
22  Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
23 
24  CHANGE LOG IS AT THE END OF THE FILE
25  *****************************************************************************/
26 
27 #ifndef SC_MUTEX_H
28 #define SC_MUTEX_H
29 
30 #include "sysc/kernel/sc_event.h"
31 #include "sysc/kernel/sc_object.h"
32 #include "sysc/kernel/sc_wait.h"
34 
35 // 02/24/2015 GL: to include the struct chnl_scoped_lock
37 
38 namespace sc_core {
39 
40 /**************************************************************************/
46 class sc_mutex
47 : public sc_mutex_if,
48  public sc_object
49 {
50 public:
51 
52  // constructors and destructor
53 
54  sc_mutex();
55  explicit sc_mutex( const char* name_ );
56  virtual ~sc_mutex();
57 
58 
59  // interface methods
60 
61  // blocks until mutex could be locked
62 
67  // 08/19/2015 GL: modified for the OoO simulation
68  virtual int lock( int = -1);
69 
70  // returns -1 if mutex could not be locked
71  virtual int trylock();
72 
73  // returns -1 if mutex was not locked by caller
74  virtual int unlock();
75 
76  virtual const char* kind() const
77  { return "sc_mutex"; }
78 
79 protected:
80 
81  // support methods
82 
83  bool in_use() const
84  { return ( m_owner != 0 ); }
85 
86 protected:
87 
90 
94  // 02/10/2015 GL.
96 
97 private:
98 
99  // disabled
100  sc_mutex( const sc_mutex& );
101  sc_mutex& operator = ( const sc_mutex& );
102 };
103 
104 } // namespace sc_core
105 
106 //$Log: sc_mutex.h,v $
107 //Revision 1.4 2011/08/26 20:45:41 acg
108 // Andy Goodrich: moved the modification log to the end of the file to
109 // eliminate source line number skew when check-ins are done.
110 //
111 //Revision 1.3 2011/02/18 20:23:45 acg
112 // Andy Goodrich: Copyright update.
113 //
114 //Revision 1.2 2010/11/02 16:31:01 acg
115 // Andy Goodrich: changed object derivation to use sc_object rather than
116 // sc_prim_channel as the parent class.
117 //
118 //Revision 1.1.1.1 2006/12/15 20:20:04 acg
119 //SystemC 2.3
120 //
121 //Revision 1.2 2006/01/03 23:18:26 acg
122 //Changed copyright to include 2006.
123 //
124 //Revision 1.1.1.1 2005/12/19 23:16:43 acg
125 //First check in of SystemC 2.1 into its own archive.
126 //
127 //Revision 1.10 2005/09/15 23:01:51 acg
128 //Added std:: prefix to appropriate methods and types to get around
129 //issues with the Edison Front End.
130 //
131 //Revision 1.9 2005/06/10 22:43:55 acg
132 //Added CVS change log annotation.
133 //
134 
135 #endif
136 
137 // Taf!
#define CHNL_MTX_TYPE_
Definition: sc_process.h:66
sc_event m_free
Definition: sc_mutex.h:89
virtual int unlock()
User initiated dynamic process support.
Definition: sc_process.h:558
virtual ~sc_mutex()
virtual int lock(int=-1)
A new parameter segment ID is added for the out-of-order simulation.
The sc_mutex_if interface class.
Definition: sc_mutex_if.h:40
The event class.
Definition: sc_event.h:260
virtual int trylock()
sc_process_b * m_owner
Definition: sc_mutex.h:88
CHNL_MTX_TYPE_ m_mutex
A lock to protect concurrent communication through sc_mutex.
Definition: sc_mutex.h:95
The sc_mutex primitive channel class.
Definition: sc_mutex.h:46
virtual const char * kind() const
Definition: sc_mutex.h:76
Abstract base class of all SystemC `simulation' objects.
Definition: sc_object.h:51
bool in_use() const
Definition: sc_mutex.h:83