00001 // EPOS-- Spin Lock Utility Declarations 00002 00003 // This work is licensed under the Creative Commons 00004 // Attribution-NonCommercial-NoDerivs License. To view a copy of this license, 00005 // visit http://creativecommons.org/licenses/by-nc-nd/2.0/ or send a letter to 00006 // Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. 00007 00008 #ifndef __spin_h 00009 #define __spin_h 00010 00011 #include <cpu.h> 00012 00013 __BEGIN_SYS 00014 00015 class Spin 00016 { 00017 public: 00018 Spin(): _lock(false) {} 00019 00020 void acquire() { while(CPU::tsl(_lock)); } 00021 void release() { _lock = false; } 00022 00023 private: 00024 volatile bool _lock; 00025 }; 00026 00027 __END_SYS 00028 00029 #endif 00030