00001 // See the end of this file for license information. 00002 00003 #ifndef TORSION_CRITICAL_H 00004 #define TORSION_CRITICAL_H 00005 00006 #include "asm.h" 00007 00008 static unsigned critical_count = 0; 00009 00011 inline void 00012 enter_critical() { 00013 if (critical_count <= 0) 00014 disable_interrupts(); 00015 00016 critical_count++; 00017 } 00018 00020 inline void 00021 leave_critical() { 00022 if (critical_count <= 0) 00023 return; 00024 00025 critical_count--; 00026 00027 if (critical_count <= 0) 00028 enable_interrupts(); 00029 } 00030 00031 #endif 00032 00033 /* Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman 00034 * 00035 * This program is free software; you can redistribute it and/or modify it 00036 * under the terms of the GNU General Public License as published by the 00037 * Free Software Foundation; either version 2 of the License, or (at your 00038 * option) any later version. 00039 * 00040 * This program is distributed in the hope that it will be useful, but 00041 * WITHOUT ANY WARRANTY; without even the implied warranty of 00042 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00043 * General Public License for more details (in the COPYING file). 00044 * 00045 * You should have received a copy of the GNU General Public License along 00046 * with this program; if not, write to the Free Software Foundation, Inc., 00047 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00048 */
Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman