00001 // vim:set et sts=4 ts=4 tw=75 sw=4 ai ci cin cino=g0,t0: 00002 /* 00003 * Copyright (C) 2007, Technical Computer Science Group, 00004 * University of Bonn 00005 * 00006 * This file is part of the ReChannel library. 00007 * 00008 * The ReChannel library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License as 00010 * published by the Free Software Foundation; either version 2 of the 00011 * License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be 00014 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this library; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 00021 * Boston, MA 02110-1301, USA. 00022 * 00023 * Authors: Andreas Raabe and Armin Felke. Implementation by Armin Felke. 00024 * {raabe, felke}@cs.uni-bonn.de 00025 */ 00037 #ifndef RC_MUTEX_OBJECT_H_ 00038 #define RC_MUTEX_OBJECT_H_ 00039 00040 #include <systemc.h> 00041 00042 namespace ReChannel { 00043 00050 class rc_mutex_object 00051 { 00052 public: 00053 rc_mutex_object(); 00054 00061 bool trylock(); 00062 00067 void lock(); 00068 00075 bool lock(sc_time timeout); 00076 00083 bool unlock(); 00084 00088 bool has_lock() const; 00089 00093 inline bool is_locked() const 00094 { return (m_lock_count > 0); } 00095 00099 inline const sc_event& get_lock_release_event() const 00100 { return m_lock_release_event; } 00101 00102 protected: 00107 inline bool is_lock_owner(const sc_process_handle& hproc) const; 00108 00109 protected: 00111 sc_process_handle m_lock_owner; 00113 int m_lock_count; 00115 sc_event m_lock_release_event; 00116 00117 private: 00118 // disabled 00119 rc_mutex_object(const rc_mutex_object& orig); 00120 const rc_mutex_object& operator=(const rc_mutex_object& orig); 00121 }; 00122 00123 inline bool rc_mutex_object::is_lock_owner( 00124 const sc_process_handle& hproc) const 00125 { 00126 return (m_lock_owner == hproc 00127 || (!hproc.valid() && !m_lock_owner.valid())); 00128 } 00129 00130 } // namespace ReChannel 00131 00132 #endif //RC_MUTEX_OBJECT_H_ 00133 00134 // 00135 // $Id: rc_mutex_object.h,v 1.7 2007/12/06 11:42:43 felke Exp $ 00136 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/util/rc_mutex_object.h,v $ 00137 //
1.5.3