00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT! -*- c++ -*- 00002 00003 #ifndef thread_lock_h 00004 #define thread_lock_h 00005 00006 #include "switch_lock.h" 00007 #include "context.h" // Switch_hint 00008 #include "panic.h" 00009 00010 // 00011 // INTERFACE definition follows 00012 // 00013 00014 00015 enum Switch_hint 00016 { 00017 SWITCH_ACTIVATE_HIGHER = 0, // Activate thread with higher priority 00018 SWITCH_ACTIVATE_LOCKEE, // Activate thread that was locked 00019 }; 00020 00036 class Thread_lock 00037 { 00038 private: 00039 Switch_lock _switch_lock; 00040 Switch_hint _switch_hint; 00041 00042 void lock_utcb(); 00043 void unlock_utcb(); 00044 00045 00046 public: 00050 inline void set_switch_hint(Switch_hint const hint); 00051 00055 bool const test_and_set(); 00056 00061 inline void lock(); 00062 00069 void clear(); 00070 00074 inline Context * const lock_owner() const; 00075 00079 inline bool const test(); 00080 00081 private: 00085 inline Context * const context() const; 00086 }; 00087 00088 // 00089 // IMPLEMENTATION includes follow (for use by inline functions) 00090 // 00091 00092 00093 #include "globals.h" 00094 00095 // 00096 // IMPLEMENTATION of inline functions (and needed classes) 00097 // 00098 00099 00100 00105 inline void 00106 Thread_lock::set_switch_hint(Switch_hint const hint) 00107 { 00108 _switch_hint = hint; 00109 } 00110 00111 00117 inline void 00118 Thread_lock::lock() 00119 { 00120 check (test_and_set() == false); 00121 } 00122 00123 00128 inline Context * const 00129 Thread_lock::lock_owner() const 00130 { 00131 return _switch_lock.lock_owner(); 00132 } 00133 00134 00139 inline bool const 00140 Thread_lock::test() 00141 { 00142 return _switch_lock.test(); 00143 } 00144 00145 00149 inline void 00150 Thread_lock::lock_utcb() {} 00151 00152 00156 inline void 00157 Thread_lock::unlock_utcb() {} 00158 00159 #endif // thread_lock_h