\f
+/* Classification of critical sections
+ *
+ * When Guile moves to POSIX threads, it won't be possible to prevent
+ * context switching. In fact, the whole idea of context switching is
+ * bogus if threads are run by different processors. Therefore, we
+ * must ultimately eliminate all critical sections or enforce them by
+ * use of mutecis.
+ *
+ * All instances of SCM_DEFER_INTS and SCM_ALLOW_INTS should therefore
+ * be classified and replaced by one of the delimiters below. If you
+ * understand what this is all about, I'd like to encourage you to
+ * help with this task. The set of classes below must of course be
+ * incrementally augmented.
+ *
+ * MDJ 980419 <djurfeldt@nada.kth.se>
+ */
+
+/* A sections
+ *
+ * Allocation of a cell with type tag in the CAR.
+ *
+ * With POSIX threads, each thread will have a private pool of free
+ * cells. Therefore, this type of section can be removed. But! It
+ * is important that the CDR is initialized first (with the CAR still
+ * indicating a free cell) so that we can guarantee a consistent heap
+ * 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
+
+\f
+
/** SCM_ASSERT
**
**/
#ifdef CHEAP_CONTINUATIONS
SCM_NEWCELL (cont);
*answer = cont;
- SCM_DEFER_INTS;
+ SCM_ENTER_A_SECTION;
SCM_SETJMPBUF (cont, scm_must_malloc ((long) sizeof (scm_contregs), s_cont));
- SCM_SETCAR (cont, scm_tc7_contin);
SCM_DYNENV (cont) = scm_dynwinds;
SCM_THROW_VALUE = SCM_EOL;
SCM_BASE (cont) = SCM_BASE (rootcont);
SCM_SEQ (cont) = SCM_SEQ (rootcont);
- SCM_ALLOW_INTS;
+ SCM_SETCAR (cont, scm_tc7_contin);
+ SCM_EXIT_A_SECTION;
#else
register SCM_STACKITEM *src, *dst;
SCM_NEWCELL (cont);
*answer = cont;
- SCM_DEFER_INTS;
+ SCM_ENTER_A_SECTION;
SCM_FLUSH_REGISTER_WINDOWS;
j = scm_stack_size (SCM_BASE (scm_rootcont));
SCM_SETJMPBUF (cont,
scm_must_malloc ((long) (sizeof (scm_contregs) + j * sizeof (SCM_STACKITEM)),
s_cont));
- SCM_SETLENGTH (cont, j, scm_tc7_contin);
SCM_DYNENV (cont) = scm_dynwinds;
SCM_THROW_VALUE (cont) = SCM_EOL;
src = SCM_BASE (cont) = SCM_BASE (scm_rootcont);
SCM_SEQ (cont) = SCM_SEQ (scm_rootcont);
- SCM_ALLOW_INTS;
+ SCM_SETLENGTH (cont, j, scm_tc7_contin);
+ SCM_EXIT_A_SECTION;
#ifndef SCM_STACK_GROWS_UP
src -= SCM_LENGTH (cont);
#endif /* ndef SCM_STACK_GROWS_UP */
{
/* *fixme* Check that env is a valid environment. */
register SCM z, ans;
- SCM_DEFER_INTS;
+ SCM_ENTER_A_SECTION;
SCM_NEWCELL (z);
- SCM_SETCAR (z, exp);
SCM_SETCDR (z, env);
+ SCM_SETCAR (z, exp);
SCM_NEWCELL (ans);
- SCM_SETCAR (ans, scm_tc16_memoized);
SCM_SETCDR (ans, z);
- SCM_ALLOW_INTS;
+ SCM_SETCAR (ans, scm_tc16_memoized);
+ SCM_EXIT_A_SECTION;
return ans;
}
scm_debug_frame *frame;
{
register SCM z;
- SCM_DEFER_INTS;
SCM_NEWCELL (z);
- SCM_SETCAR (z, scm_tc16_debugobj);
+ SCM_ENTER_A_SECTION;
SCM_SET_DEBUGOBJ_FRAME (z, (SCM) frame);
- SCM_ALLOW_INTS;
+ SCM_SETCAR (z, scm_tc16_debugobj);
+ SCM_EXIT_A_SECTION;
return z;
}
{
register SCM z;
SCM_NEWCELL (z);
- SCM_DEFER_INTS;
+ SCM_ENTER_A_SECTION;
SCM_SETCDR (z, code);
SCM_SETCAR (z, scm_tc16_promise);
- SCM_ALLOW_INTS;
+ SCM_EXIT_A_SECTION;
return z;
}