[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Thread Plug-in Support #4
From: |
NIIBE Yutaka |
Subject: |
[PATCH] Thread Plug-in Support #4 |
Date: |
Thu, 12 Apr 2001 09:56:18 +0900 (JST) |
Patch piece #4.
This is (almost) same patch I've sent in April 2. One change is a bug fix
of SCM_REALLOW_INTS. We should not allow thread switching at there.
Applying patch pieses #1-#4, no regression with "make check".
(Note that patch pieses #1-#4 can be applied independently.)
libguile/ChangeLog
* srcprop.c (scm_make_srcprops): Added SCM_ALLOW_INTS which
matches SCM_DEFER_INTS at the beginning of the function.
* mallocs.c (scm_malloc_obj): Remove un-matched SCM_ALLOW_INTS.
* gc.c (scm_igc): Unconditionally call
SCM_THREAD_CRITICAL_SECTION_START/END.
* fluids.c (next_fluid_num): Unconditionally call
SCM_THREAD_CRITICAL_SECTION_START/END.
(s_scm_make_fluid): Remove un-matched SCM_DEFER_INTS.
* coop-defs.h (SCM_THREAD_DEFER, SCM_THREAD_ALLOW,
SCM_THREAD_REDEFER, SCM_THREAD_REALLOW_1, SCM_THREAD_REALLOW_2):
Removed.
* __scm.h (SCM_THREAD_CRITICAL_SECTION_START,
SCM_THREAD_CRITICAL_SECTION_END): Defined as nothing
for the case of !defined(USE_THREADS).
(SCM_THREAD_DEFER, SCM_THREAD_ALLOW, SCM_THREAD_REDEFER): Removed.
(<stdio.h>): Include when defined(SCM_CAREFUL_INTS).
(SCM_CHECK_NOT_DISABLED, SCM_CHECK_NOT_ENABLED): Print FILE and
LINE.
(SCM_DEFER_INTS, SCM_ALLOW_INTS_ONLY, SCM_ALLOW_INTS,
SCM_REDEFER_INTS, SCM_REALLOW_INTS): Don't use
SCM_THREAD_DEFER/SCM_THREAD_ALLOW. Instead, use
SCM_THREAD_CRITICAL_SECTION_START/END.
(SCM_REALLOW_INTS: Bug fix. Don't call SCM_THREAD_SWITCHING_CODE.
(SCM_TICK): Don't use SCM_DEFER_INTS/SCM_ALLOW_INTS. Instead,
use SCM_THREAD_SWITCHING_CODE directly.
(SCM_ENTER_A_SECTION): Unconditionally use
SCM_THREAD_CRITICAL_SECTION_START/END.
(was: SCM_DEFER_INTS/SCM_ALLOW_INTS when SCM_POSIX_THREADS defined).
Index: libguile/__scm.h
===================================================================
RCS file: /cvs/guile/guile-core/libguile/__scm.h,v
retrieving revision 1.65
diff -u -p -r1.65 __scm.h
--- libguile/__scm.h 2001/03/17 13:34:21 1.65
+++ libguile/__scm.h 2001/04/12 00:38:24
@@ -319,9 +319,8 @@ typedef long SCM_STACKITEM;
#ifndef USE_THREADS
-#define SCM_THREAD_DEFER
-#define SCM_THREAD_ALLOW
-#define SCM_THREAD_REDEFER
+#define SCM_THREAD_CRITICAL_SECTION_START
+#define SCM_THREAD_CRITICAL_SECTION_END
#define SCM_THREAD_SWITCHING_CODE
#endif
@@ -344,13 +343,18 @@ do { \
#endif
#ifdef SCM_CAREFUL_INTS
+#include <stdio.h>
#define SCM_CHECK_NOT_DISABLED \
+do { \
if (scm_ints_disabled) \
- fputs("ints already disabled\n", stderr); \
+ fprintf(stderr, "ints already disabled (at %s:%d)\n", __FILE__, __LINE__);
\
+} while (0)
#define SCM_CHECK_NOT_ENABLED \
+do { \
if (!scm_ints_disabled) \
- fputs("ints already enabled\n", stderr); \
+ fprintf(stderr, "ints already enabled (at %s:%d)\n", __FILE__, __LINE__); \
+} while (0)
#else
#define SCM_CHECK_NOT_DISABLED
@@ -383,7 +387,7 @@ do { \
do { \
SCM_FENCE; \
SCM_CHECK_NOT_DISABLED; \
- SCM_THREAD_DEFER; \
+ SCM_THREAD_CRITICAL_SECTION_START; \
SCM_FENCE; \
scm_ints_disabled = 1; \
SCM_FENCE; \
@@ -392,7 +396,7 @@ do { \
#define SCM_ALLOW_INTS_ONLY \
do { \
- SCM_THREAD_ALLOW; \
+ SCM_THREAD_CRITICAL_SECTION_END; \
scm_ints_disabled = 0; \
} while (0)
@@ -401,11 +405,11 @@ do { \
do { \
SCM_FENCE; \
SCM_CHECK_NOT_ENABLED; \
- SCM_THREAD_SWITCHING_CODE; \
+ SCM_THREAD_CRITICAL_SECTION_END; \
SCM_FENCE; \
scm_ints_disabled = 0; \
SCM_FENCE; \
- SCM_THREAD_ALLOW; \
+ SCM_THREAD_SWITCHING_CODE; \
SCM_FENCE; \
} while (0)
@@ -413,7 +417,7 @@ do { \
#define SCM_REDEFER_INTS \
do { \
SCM_FENCE; \
- SCM_THREAD_REDEFER; \
+ SCM_THREAD_CRITICAL_SECTION_START; \
++scm_ints_disabled; \
SCM_FENCE; \
} while (0)
@@ -422,7 +426,7 @@ do { \
#define SCM_REALLOW_INTS \
do { \
SCM_FENCE; \
- SCM_THREAD_SWITCHING_CODE; \
+ SCM_THREAD_CRITICAL_SECTION_END; \
SCM_FENCE; \
--scm_ints_disabled; \
SCM_FENCE; \
@@ -431,9 +435,8 @@ do { \
#define SCM_TICK \
do { \
- SCM_DEFER_INTS; \
- SCM_ALLOW_INTS; \
SCM_ASYNC_TICK; \
+ SCM_THREAD_SWITCHING_CODE; \
} while (0)
@@ -466,13 +469,8 @@ do { \
* at all times.
*/
-#ifdef SCM_POSIX_THREADS
-#define SCM_ENTER_A_SECTION
-#define SCM_EXIT_A_SECTION
-#else
-#define SCM_ENTER_A_SECTION SCM_DEFER_INTS
-#define SCM_EXIT_A_SECTION SCM_ALLOW_INTS
-#endif
+#define SCM_ENTER_A_SECTION SCM_THREAD_CRITICAL_SECTION_START
+#define SCM_EXIT_A_SECTION SCM_THREAD_CRITICAL_SECTION_END
Index: libguile/coop-defs.h
===================================================================
RCS file: /cvs/guile/guile-core/libguile/coop-defs.h,v
retrieving revision 1.18
diff -u -p -r1.18 coop-defs.h
--- libguile/coop-defs.h 2000/10/02 21:32:57 1.18
+++ libguile/coop-defs.h 2001/04/12 00:38:24
@@ -245,12 +245,6 @@ extern coop_t *coop_wait_for_runnable_th
-#define SCM_THREAD_DEFER
-#define SCM_THREAD_ALLOW
-#define SCM_THREAD_REDEFER
-#define SCM_THREAD_REALLOW_1
-#define SCM_THREAD_REALLOW_2
-
#if 0
#define SCM_THREAD_SWITCHING_CODE \
do { \
Index: libguile/fluids.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/fluids.c,v
retrieving revision 1.32
diff -u -p -r1.32 fluids.c
--- libguile/fluids.c 2001/04/03 13:19:04 1.32
+++ libguile/fluids.c 2001/04/12 00:38:24
@@ -107,13 +107,9 @@ static int
next_fluid_num ()
{
int n;
-#ifdef USE_THREADS
SCM_THREAD_CRITICAL_SECTION_START;
-#endif
n = n_fluids++;
-#ifdef USE_THREADS
SCM_THREAD_CRITICAL_SECTION_END;
-#endif
return n;
}
@@ -130,7 +126,6 @@ SCM_DEFINE (scm_make_fluid, "make-fluid"
{
int n;
- SCM_DEFER_INTS;
n = next_fluid_num ();
SCM_RETURN_NEWSMOB (scm_tc16_fluid, n);
}
Index: libguile/gc.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/gc.c,v
retrieving revision 1.191
diff -u -p -r1.191 gc.c
--- libguile/gc.c 2001/04/03 13:19:04 1.191
+++ libguile/gc.c 2001/04/12 00:38:24
@@ -1001,10 +1001,8 @@ scm_igc (const char *what)
? "*"
: (SCM_NULLP (scm_freelist2) ? "o" : "m"));
#endif
-#ifdef USE_THREADS
/* During the critical section, only the current thread may run. */
SCM_THREAD_CRITICAL_SECTION_START;
-#endif
/* fprintf (stderr, "gc: %s\n", what); */
@@ -1102,9 +1100,7 @@ scm_igc (const char *what)
--scm_gc_heap_lock;
gc_end_stats ();
-#ifdef USE_THREADS
SCM_THREAD_CRITICAL_SECTION_END;
-#endif
scm_c_hook_run (&scm_after_gc_c_hook, 0);
--scm_gc_running_p;
}
Index: libguile/mallocs.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/mallocs.c,v
retrieving revision 1.22
diff -u -p -r1.22 mallocs.c
--- libguile/mallocs.c 2001/03/09 23:33:40 1.22
+++ libguile/mallocs.c 2001/04/12 00:38:24
@@ -64,10 +64,7 @@ scm_malloc_obj (scm_sizet n)
{
scm_bits_t mem = n ? (scm_bits_t) malloc (n) : 0;
if (n && !mem)
- {
- SCM_ALLOW_INTS;
- return SCM_BOOL_F;
- }
+ return SCM_BOOL_F;
SCM_RETURN_NEWSMOB (scm_tc16_malloc, mem);
}
Index: libguile/srcprop.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/srcprop.c,v
retrieving revision 1.45
diff -u -p -r1.45 srcprop.c
--- libguile/srcprop.c 2001/03/10 16:56:07 1.45
+++ libguile/srcprop.c 2001/04/12 00:38:24
@@ -148,6 +148,7 @@ scm_make_srcprops (int line, int col, SC
ptr->fname = filename;
ptr->copy = copy;
ptr->plist = plist;
+ SCM_ALLOW_INTS;
SCM_RETURN_NEWSMOB (scm_tc16_srcprops, ptr);
}
--
- [PATCH] Thread Plug-in Support #4,
NIIBE Yutaka <=