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_cor.h -- Coroutine abstract base classes. 00021 00022 Original Author: Martin Janssen, Synopsys, Inc., 2001-12-18 00023 00024 CHANGE LOG AT THE END OF THE FILE 00025 *****************************************************************************/ 00026 00027 00028 #ifndef SC_COR_H 00029 #define SC_COR_H 00030 00031 00032 #include <cassert> 00033 #include <cstdlib> 00034 00035 //#define SC_LOCK_CHECK // 05/27/2015 GL: check the state of the kernel lock 00036 00037 namespace sc_core { 00038 00039 class sc_simcontext; 00040 00041 00042 /**************************************************************************/ 00048 typedef void (sc_cor_fn)( void* ); 00049 00050 00051 /**************************************************************************/ 00057 class sc_cor 00058 { 00059 protected: 00060 00061 // constructor 00062 sc_cor() {} 00063 00064 public: 00065 00066 // destructor 00067 virtual ~sc_cor() {} 00068 00069 // switch stack protection on/off 00070 virtual void stack_protect( bool /* enable */ ) {} 00071 00075 virtual void increment_counter() = 0; 00076 00080 virtual void decrement_counter() = 0; 00081 00085 virtual unsigned int get_counter() = 0; 00086 00087 private: 00088 00089 // disabled 00090 sc_cor( const sc_cor& ); 00091 sc_cor& operator = ( const sc_cor& ); 00092 }; 00093 00094 00095 /**************************************************************************/ 00101 class sc_cor_pkg 00102 { 00103 public: 00104 00105 // constructor 00106 sc_cor_pkg( sc_simcontext* simc ) 00107 : m_simc( simc ) { assert( simc != 0 ); } 00108 00109 // destructor 00110 virtual ~sc_cor_pkg() {} 00111 00112 // create a new coroutine 00113 virtual sc_cor* create( 00114 std::size_t stack_size, sc_cor_fn* fn, void* arg ) = 0; 00115 00116 // yield to the next coroutine 00117 virtual void yield( sc_cor* next_cor ) = 0; 00118 00122 virtual void wait( sc_cor* cur_cor ) = 0; 00123 00127 virtual void go( sc_cor* next_cor ) = 0; 00128 00129 // abort the current coroutine (and resume the next coroutine) 00130 virtual void abort( sc_cor* next_cor ) = 0; 00131 00132 // join another coroutine 00133 virtual void join( sc_cor* join_cor ) = 0; 00134 00135 // get the main coroutine 00136 virtual sc_cor* get_main() = 0; 00137 00141 virtual void acquire_sched_mutex() = 0; 00142 00146 virtual void release_sched_mutex() = 0; 00147 00151 virtual void set_thread_specific( void* process_b ) = 0; 00152 00156 virtual void* get_thread_specific() = 0; 00157 00161 virtual bool is_locked() = 0; 00162 00166 virtual bool is_unlocked() = 0; 00167 00171 virtual bool is_lock_owner() = 0; 00172 00176 virtual bool is_not_owner() = 0; 00177 00182 virtual bool is_locked_and_owner() = 0; 00183 00184 // get the simulation context 00185 sc_simcontext* simcontext() 00186 { return m_simc; } 00187 00188 private: 00189 00190 sc_simcontext* m_simc; 00191 00192 private: 00193 00194 // disabled 00195 sc_cor_pkg(); 00196 sc_cor_pkg( const sc_cor_pkg& ); 00197 sc_cor_pkg& operator = ( const sc_cor_pkg& ); 00198 }; 00199 00200 } // namespace sc_core 00201 00202 // $Log: sc_cor.h,v $ 00203 // Revision 1.7 2011/08/26 20:46:09 acg 00204 // Andy Goodrich: moved the modification log to the end of the file to 00205 // eliminate source line number skew when check-ins are done. 00206 // 00207 // Revision 1.6 2011/08/15 16:43:24 acg 00208 // Torsten Maehne: changes to remove unused argument warnings. 00209 // 00210 // Revision 1.5 2011/02/18 20:27:14 acg 00211 // Andy Goodrich: Updated Copyrights. 00212 // 00213 // Revision 1.4 2011/02/13 21:47:37 acg 00214 // Andy Goodrich: update copyright notice. 00215 // 00216 // Revision 1.3 2011/01/19 23:21:49 acg 00217 // Andy Goodrich: changes for IEEE 1666 2011 00218 // 00219 // Revision 1.2 2008/05/22 17:06:24 acg 00220 // Andy Goodrich: updated copyright notice to include 2008. 00221 // 00222 // Revision 1.1.1.1 2006/12/15 20:20:05 acg 00223 // SystemC 2.3 00224 // 00225 // Revision 1.3 2006/01/13 18:44:29 acg 00226 // Added $Log to record CVS changes into the source. 00227 // 00228 00229 #endif 00230 00231 // Taf!