mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
* continuations.c (scm_make_cont), debug.c (scm_make_memoized,
scm_make_debugobj), eval.c (scm_makprom): SCM_DEFER/ALLOW_INTS --> A section. * __scm.h: Start the long-term project of moving to POSIX threads. Phase 1: Classification of all critical sections. (SCM_ENTER_A_SECTION, SCM_EXIT_A_SECTION): New macros: Delimiters for A sections. (See comments in __scm.h for details.)
This commit is contained in:
parent
c3e09ef939
commit
f83e27370c
4 changed files with 53 additions and 15 deletions
|
@ -359,6 +359,44 @@ extern unsigned int scm_async_clock;
|
|||
|
||||
|
||||
|
||||
/* 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
|
||||
|
||||
|
||||
|
||||
/** SCM_ASSERT
|
||||
**
|
||||
**/
|
||||
|
|
|
@ -67,14 +67,14 @@ scm_make_cont (answer)
|
|||
#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;
|
||||
|
||||
|
@ -94,18 +94,18 @@ scm_make_cont (answer)
|
|||
|
||||
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 */
|
||||
|
|
|
@ -154,14 +154,14 @@ scm_make_memoized (exp, env)
|
|||
{
|
||||
/* *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;
|
||||
}
|
||||
|
||||
|
@ -570,11 +570,11 @@ scm_make_debugobj (frame)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -3128,10 +3128,10 @@ scm_makprom (code)
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue