|
From: Vitor S. C. <vs...@us...> - 2001-06-27 13:22:34
|
Update of /cvsroot/yap/m4
In directory usw-pr-cvs1:/tmp/cvs-serv21951/m4
Modified Files:
Yap.h.m4
Log Message:
More interrupt handling cleanups!
Index: Yap.h.m4
===================================================================
RCS file: /cvsroot/yap/m4/Yap.h.m4,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Yap.h.m4 2001/06/22 17:53:36 1.5
+++ Yap.h.m4 2001/06/27 13:22:30 1.6
@@ -754,14 +754,16 @@
/********* Prolog may be in several modes *******************************/
-#define BootMode 1 /* if booting or restoring */
-#define UserMode 2 /* Normal mode */
-#define CritMode 4 /* If we are meddling with the heap */
-#define FullLMode 8 /* to access the hidden atoms chain */
-#define AbortMode 16 /* expecting to abort */
-#define InterruptMode 32 /* under an interrupt */
+typedef enum {
+ BootMode = 1, /* if booting or restoring */
+ UserMode = 2, /* Normal mode */
+ CritMode = 4, /* If we are meddling with the heap */
+ AbortMode = 8, /* expecting to abort */
+ InterruptMode = 16 /* under an interrupt */
+} prolog_exec_mode;
-extern int PrologMode;
+extern prolog_exec_mode PrologMode;
+extern int CritLocks;
#if SIZEOF_INT_P==4
#if defined(YAPOR) || defined(TABLING)
@@ -802,17 +804,46 @@
GLOBAL_LOCKS_who_locked_heap = worker_id; \
} \
PrologMode |= CritMode; \
+ CritLocks++; \
}
#define YAPLeaveCriticalSection() \
{ \
- if ((PrologMode ^= CritMode) & AbortMode) Abort((char *)NIL); \
- GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS; \
- UNLOCK(GLOBAL_LOCKS_heap_access); \
+ CritLocks--; \
+ if (!CritLocks) { \
+ PrologMode &= ~CritMode; \
+ if (PrologMode & InterruptMode) { \
+ PrologMode &= ~InterruptMode; \
+ ProcessSIGINT(); \
+ } \
+ if (PrologMode & AbortMode) { \
+ PrologMode &= ~AbortMode; \
+ Abort(""); \
+ } \
+ GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS; \
+ UNLOCK(GLOBAL_LOCKS_heap_access); \
+ } \
}
#else
-#define YAPEnterCriticalSection() PrologMode |= CritMode;
-#define YAPLeaveCriticalSection() \
- if((PrologMode ^= CritMode) & AbortMode) Abort((char *)NIL);
+#define YAPEnterCriticalSection() \
+ { \
+ PrologMode |= CritMode; \
+ CritLocks++; \
+ }
+#define YAPLeaveCriticalSection() \
+ { \
+ CritLocks--; \
+ if (!CritLocks) { \
+ PrologMode &= ~CritMode; \
+ if (PrologMode & InterruptMode) { \
+ PrologMode &= ~InterruptMode; \
+ ProcessSIGINT(); \
+ } \
+ if (PrologMode & AbortMode) { \
+ PrologMode &= ~AbortMode; \
+ Abort(""); \
+ } \
+ } \
+ }
#endif /* YAPOR */
/* when we are calling the InitStaff procedures */
|