00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2006 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 Version 2.4 (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.systemc.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 *****************************************************************************/ 00025 00026 /***************************************************************************** 00027 00028 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00029 changes you are making here. 00030 00031 Name, Affiliation, Date: 00032 Description of Modification: 00033 00034 *****************************************************************************/ 00035 00036 // $Log: sc_cor_qt.h,v $ 00037 // Revision 1.1.1.1 2006/12/15 20:31:37 acg 00038 // SystemC 2.2 00039 // 00040 // Revision 1.3 2006/01/13 18:44:29 acg 00041 // Added $Log to record CVS changes into the source. 00042 // 00043 00044 #ifndef SC_COR_QT_H 00045 #define SC_COR_QT_H 00046 00047 00048 #if !defined(WIN32) && !defined(SC_USE_PTHREADS) 00049 00050 #include "sysc/kernel/sc_cor.h" 00051 #include "sysc/qt/qt.h" 00052 00053 namespace sc_core { 00054 00055 class sc_cor_pkg_qt; 00056 00057 00058 // ---------------------------------------------------------------------------- 00059 // CLASS : sc_cor_qt 00060 // 00061 // Coroutine class implemented with QuickThreads. 00062 // ---------------------------------------------------------------------------- 00063 00064 class sc_cor_qt 00065 : public sc_cor 00066 { 00067 public: 00068 00069 // constructor 00070 sc_cor_qt() 00071 : m_stack_size( 0 ), m_stack( 0 ), m_sp( 0 ), m_pkg( 0 ) 00072 {} 00073 00074 // destructor 00075 virtual ~sc_cor_qt() 00076 { if( m_stack != 0 ) { delete[] (char*) m_stack; } } 00077 00078 // switch stack protection on/off 00079 virtual void stack_protect( bool enable ); 00080 00081 public: 00082 00083 std::size_t m_stack_size; // stack size 00084 void* m_stack; // stack 00085 qt_t* m_sp; // stack pointer 00086 00087 sc_cor_pkg_qt* m_pkg; // the creating coroutine package 00088 00089 private: 00090 00091 // disabled 00092 sc_cor_qt( const sc_cor_qt& ); 00093 sc_cor_qt& operator = ( const sc_cor_qt& ); 00094 }; 00095 00096 00097 // ---------------------------------------------------------------------------- 00098 // CLASS : sc_cor_pkg_qt 00099 // 00100 // Coroutine package class implemented with QuickThreads. 00101 // ---------------------------------------------------------------------------- 00102 00103 class sc_cor_pkg_qt 00104 : public sc_cor_pkg 00105 { 00106 public: 00107 00108 // constructor 00109 sc_cor_pkg_qt( sc_simcontext* simc ); 00110 00111 // destructor 00112 virtual ~sc_cor_pkg_qt(); 00113 00114 // create a new coroutine 00115 virtual sc_cor* create( std::size_t stack_size, sc_cor_fn* fn, void* arg ); 00116 00117 // yield to the next coroutine 00118 virtual void yield( sc_cor* next_cor ); 00119 00120 // abort the current coroutine (and resume the next coroutine) 00121 virtual void abort( sc_cor* next_cor ); 00122 00123 // get the main coroutine 00124 virtual sc_cor* get_main(); 00125 00126 private: 00127 00128 static int instance_count; 00129 00130 private: 00131 00132 // disabled 00133 sc_cor_pkg_qt(); 00134 sc_cor_pkg_qt( const sc_cor_pkg_qt& ); 00135 sc_cor_pkg_qt& operator = ( const sc_cor_pkg_qt& ); 00136 }; 00137 00138 } // namespace sc_core 00139 00140 #endif 00141 00142 00143 #endif 00144 00145 // Taf!