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_qt.h -- Coroutine implementation with QuickThreads. 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_QT_H 00029 #define SC_COR_QT_H 00030 00031 00032 #if !defined(_WIN32) && !defined(WIN32) && !defined(WIN64) && !defined(SC_USE_PTHREADS) 00033 00034 #include "sysc/kernel/sc_cor.h" 00035 #include "sysc/qt/qt.h" 00036 00037 namespace sc_core { 00038 00039 class sc_cor_pkg_qt; 00040 typedef sc_cor_pkg_qt sc_cor_pkg_t; 00041 00042 // ---------------------------------------------------------------------------- 00043 // CLASS : sc_cor_qt 00044 // 00045 // Coroutine class implemented with QuickThreads. 00046 // ---------------------------------------------------------------------------- 00047 00048 class sc_cor_qt 00049 : public sc_cor 00050 { 00051 public: 00052 00053 // constructor 00054 sc_cor_qt() 00055 : m_stack_size( 0 ), m_stack( 0 ), m_sp( 0 ), m_pkg( 0 ) 00056 {} 00057 00058 // destructor 00059 virtual ~sc_cor_qt() 00060 { delete[] (char*) m_stack; } 00061 00062 // switch stack protection on/off 00063 virtual void stack_protect( bool enable ); 00064 00065 public: 00066 00067 std::size_t m_stack_size; // stack size 00068 void* m_stack; // stack 00069 qt_t* m_sp; // stack pointer 00070 00071 sc_cor_pkg_qt* m_pkg; // the creating coroutine package 00072 00073 private: 00074 00075 // disabled 00076 sc_cor_qt( const sc_cor_qt& ); 00077 sc_cor_qt& operator = ( const sc_cor_qt& ); 00078 }; 00079 00080 00081 // ---------------------------------------------------------------------------- 00082 // CLASS : sc_cor_pkg_qt 00083 // 00084 // Coroutine package class implemented with QuickThreads. 00085 // ---------------------------------------------------------------------------- 00086 00087 class sc_cor_pkg_qt 00088 : public sc_cor_pkg 00089 { 00090 public: 00091 00092 // constructor 00093 sc_cor_pkg_qt( sc_simcontext* simc ); 00094 00095 // destructor 00096 virtual ~sc_cor_pkg_qt(); 00097 00098 // create a new coroutine 00099 virtual sc_cor* create( std::size_t stack_size, sc_cor_fn* fn, void* arg ); 00100 00101 // yield to the next coroutine 00102 virtual void yield( sc_cor* next_cor ); 00103 00104 // abort the current coroutine (and resume the next coroutine) 00105 virtual void abort( sc_cor* next_cor ); 00106 00107 // get the main coroutine 00108 virtual sc_cor* get_main(); 00109 00110 private: 00111 00112 static int instance_count; 00113 00114 private: 00115 00116 // disabled 00117 sc_cor_pkg_qt(); 00118 sc_cor_pkg_qt( const sc_cor_pkg_qt& ); 00119 sc_cor_pkg_qt& operator = ( const sc_cor_pkg_qt& ); 00120 }; 00121 00122 } // namespace sc_core 00123 00124 #endif 00125 00126 // $Log: sc_cor_qt.h,v $ 00127 // Revision 1.6 2011/08/29 18:04:32 acg 00128 // Philipp A. Hartmann: miscellaneous clean ups. 00129 // 00130 // Revision 1.5 2011/08/26 20:46:09 acg 00131 // Andy Goodrich: moved the modification log to the end of the file to 00132 // eliminate source line number skew when check-ins are done. 00133 // 00134 // Revision 1.4 2011/02/18 20:27:14 acg 00135 // Andy Goodrich: Updated Copyrights. 00136 // 00137 // Revision 1.3 2011/02/13 21:47:37 acg 00138 // Andy Goodrich: update copyright notice. 00139 // 00140 // Revision 1.2 2008/05/22 17:06:25 acg 00141 // Andy Goodrich: updated copyright notice to include 2008. 00142 // 00143 // Revision 1.1.1.1 2006/12/15 20:20:05 acg 00144 // SystemC 2.3 00145 // 00146 // Revision 1.3 2006/01/13 18:44:29 acg 00147 // Added $Log to record CVS changes into the source. 00148 // 00149 00150 #endif 00151 00152 // Taf!