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 namespace sc_core {
36 
37 // ----------------------------------------------------------------------------
38 // CLASS : sc_mutex
39 //
40 // The sc_mutex primitive channel class.
41 // ----------------------------------------------------------------------------
42 
43 class sc_mutex
44 : public sc_mutex_if,
45  public sc_object
46 {
47 public:
48 
49  // constructors and destructor
50 
51  sc_mutex();
52  explicit sc_mutex( const char* name_ );
53  virtual ~sc_mutex();
54 
55 
56  // interface methods
57 
58  // blocks until mutex could be locked
59  virtual int lock();
60 
61  // returns -1 if mutex could not be locked
62  virtual int trylock();
63 
64  // returns -1 if mutex was not locked by caller
65  virtual int unlock();
66 
67  virtual const char* kind() const
68  { return "sc_mutex"; }
69 
70 protected:
71 
72  // support methods
73 
74  bool in_use() const
75  { return ( m_owner != 0 ); }
76 
77 protected:
78 
81 
82 private:
83 
84  // disabled
85  sc_mutex( const sc_mutex& );
86  sc_mutex& operator = ( const sc_mutex& );
87 };
88 
89 } // namespace sc_core
90 
91 //$Log: sc_mutex.h,v $
92 //Revision 1.4 2011/08/26 20:45:41 acg
93 // Andy Goodrich: moved the modification log to the end of the file to
94 // eliminate source line number skew when check-ins are done.
95 //
96 //Revision 1.3 2011/02/18 20:23:45 acg
97 // Andy Goodrich: Copyright update.
98 //
99 //Revision 1.2 2010/11/02 16:31:01 acg
100 // Andy Goodrich: changed object derivation to use sc_object rather than
101 // sc_prim_channel as the parent class.
102 //
103 //Revision 1.1.1.1 2006/12/15 20:20:04 acg
104 //SystemC 2.3
105 //
106 //Revision 1.2 2006/01/03 23:18:26 acg
107 //Changed copyright to include 2006.
108 //
109 //Revision 1.1.1.1 2005/12/19 23:16:43 acg
110 //First check in of SystemC 2.1 into its own archive.
111 //
112 //Revision 1.10 2005/09/15 23:01:51 acg
113 //Added std:: prefix to appropriate methods and types to get around
114 //issues with the Edison Front End.
115 //
116 //Revision 1.9 2005/06/10 22:43:55 acg
117 //Added CVS change log annotation.
118 //
119 
120 #endif
121 
122 // Taf!
virtual const char * kind() const
Definition: sc_mutex.h:67
virtual int trylock()
virtual int lock()
sc_process_b * m_owner
Definition: sc_mutex.h:79
sc_event m_free
Definition: sc_mutex.h:80
virtual int unlock()
virtual ~sc_mutex()
bool in_use() const
Definition: sc_mutex.h:74