setup_memory ((BLOCKS_TO_BYTES (option_heap_size)),
(BLOCKS_TO_BYTES (option_stack_size)),
(BLOCKS_TO_BYTES (option_constant_size)));
+#ifdef ENABLE_SMP
+ setup_processors (option_processor_count);
+#endif
initialize_primitives ();
compiler_initialize (option_fasl_file != 0);
[Support native compiled code if available [[yes]]]))
: ${enable_native_code='yes'}
+AC_ARG_ENABLE([smp],
+ AS_HELP_STRING([--enable-smp],
+ [Support multi-processing if available [[no]]]))
+: ${enable_smp='no'}
+
AC_ARG_WITH([openssl],
AS_HELP_STRING([--with-openssl],
[Use OpenSSL crypto library if available [[yes]]]))
M4_FLAGS="${M4_FLAGS} -P VALGRIND_MODE,1"
fi
+dnl Check for pthreads.
+if test "${enable_smp}" != no; then
+ AC_CHECK_HEADER([pthread.h],
+ [
+ AC_DEFINE([ENABLE_SMP], [1],
+ [Define to 1 for Symmetric Multiple Processor support.])
+ CFLAGS="-pthread ${CFLAGS}"
+ LDFLAGS="-pthread ${LDFLAGS}"
+ M4_FLAGS="${M4_FLAGS} -P ENABLE_SMP,1"
+ ],
+ AC_MSG_ERROR([SMP support requires <pthread.h>]))
+fi
+
OPTIONAL_BASES="${OPTIONAL_BASES} cmpint cmpintmd comutl"
case ${mit_scheme_native_code} in
# define HEAP_FREE(address)
#endif
+#ifndef ENABLE_SMP
+#define __thread
+#endif
+
#endif /* SCM_CONFSHARED_H */
#define D_TRACE_ON_ERROR 12
#define D_PER_FILE 13
#define D_BIGNUM 14
-
-#ifndef LAST_SWITCH
-#define LAST_SWITCH D_BIGNUM
+#ifdef ENABLE_SMP
+# define D_SMP 15
+# ifndef LAST_SWITCH
+# define LAST_SWITCH D_SMP
+# endif
+#else
+# ifndef LAST_SWITCH
+# define LAST_SWITCH D_BIGNUM
+# endif
#endif
static bool *
case D_TRACE_ON_ERROR: return (&Trace_On_Error);
case D_PER_FILE: return (&Per_File);
case D_BIGNUM: return (&Bignum_Debug);
+#ifdef ENABLE_SMP
+ case D_SMP: return (&smp_trace_p);
+#endif
MORE_DEBUG_FLAG_CASES ();
default: return (0);
}
case D_TRACE_ON_ERROR: return ("Trace_On_Error");
case D_PER_FILE: return ("Per_File");
case D_BIGNUM: return ("Bignum_Debug");
+#ifdef ENABLE_SMP
+ case D_SMP: return ("smp_trace_p");
+#endif
MORE_DEBUG_FLAG_NAMES ();
default: return ("Unknown Debug Flag");
}
"prosterm"
"prostty"
"pruxsock" ;Misnamed, should be "prossock".
+"prossmp"
static const char * option_raw_heap;
static const char * option_raw_constant;
static const char * option_raw_stack;
+static const char * option_raw_processor_count;
+static const char * option_raw_processor_heap;
/* Command-line arguments */
int option_saved_argc;
unsigned long option_heap_size;
unsigned long option_constant_size;
unsigned long option_stack_size;
+int option_processor_count;
+unsigned long option_processor_heap_size;
\f
void
print_help (void)
#ifndef STACK_SIZE_VARIABLE
# define STACK_SIZE_VARIABLE "MITSCHEME_STACK_SIZE"
#endif
+
+#ifndef PROCESSORS_VARIABLE
+# define PROCESSORS_VARIABLE "MITSCHEME_PROCESSORS"
+#endif
+
+#ifndef PROCESSOR_HEAP_SIZE_VARIABLE
+# define PROCESSOR_HEAP_SIZE_VARIABLE "MITSCHEME_PROCESSOR_HEAP_SIZE"
+#endif
\f
static int
string_compare_ci (const char * string1, const char * string2)
option_argument ("silent", false, (&option_batch_mode));
option_argument ("stack", true, (&option_raw_stack));
option_argument ("version", false, (&option_show_version));
+ option_argument ("processors", true, (&option_raw_processor_count));
+ option_argument ("processor-heap", true, (&option_raw_processor_heap));
/* These are deprecated: */
option_argument ("compiler", false, 0);
outf_fatal (" %s size: %d\n", name, value);
}
+static void
+describe_number_option (const char * name, unsigned int value)
+{
+ outf_fatal (" number of %s: %d\n", name, value);
+}
+
static void
describe_path_option (const char * name, const char ** value)
{
describe_boolean_option ("force interactive", option_force_interactive);
describe_boolean_option ("disable core dump", option_disable_core_dump);
describe_boolean_option ("suppress noise", option_batch_mode);
+ describe_number_option ("processors", option_processor_count);
+ describe_size_option ("processor heap", option_processor_heap_size);
if (option_unused_argc == 0)
outf_fatal (" no unused arguments\n");
else
option_raw_stack,
STACK_SIZE_VARIABLE,
DEFAULT_STACK_SIZE));
+ option_processor_count
+ = (standard_numeric_option ("processors",
+ option_raw_processor_count,
+ PROCESSORS_VARIABLE,
+ 1));
+ option_processor_heap_size
+ = (standard_numeric_option ("processor-heap",
+ option_raw_processor_heap,
+ PROCESSOR_HEAP_SIZE_VARIABLE,
+ 0));
if (option_show_version)
{
outf_console ("%s\n", PACKAGE_STRING);
extern unsigned long option_heap_size;
extern unsigned long option_constant_size;
extern unsigned long option_stack_size;
+extern int option_processor_count;
+extern unsigned long option_processor_heap_size;
extern void read_command_line_options (int argc, const char ** argv);
--- /dev/null
+/* -*-C-*-
+
+Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts
+ Institute of Technology
+
+This file is part of MIT/GNU Scheme.
+
+MIT/GNU Scheme is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+MIT/GNU Scheme is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with MIT/GNU Scheme; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+*/
+
+#ifndef SCM_OSSMP_H
+#define SCM_OSSMP_H
+
+#ifdef ENABLE_SMP
+
+#include <pthread.h>
+
+extern void setup_processors (int count);
+
+#ifdef ENABLE_DEBUGGING_TOOLS
+extern bool smp_trace_p;
+#endif
+
+#endif /* ENABLE_SMP */
+
+#endif /* SCM_OSSMP_H */
--- /dev/null
+/* -*-C-*-
+
+Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts
+ Institute of Technology
+
+This file is part of MIT/GNU Scheme.
+
+MIT/GNU Scheme is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+MIT/GNU Scheme is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with MIT/GNU Scheme; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+*/
+
+/* Primitives for "symmetric multi-processing". */
+
+#include "prims.h"
+
+#ifdef ENABLE_SMP
+
+#include "option.h"
+
+#ifdef ENABLE_DEBUGGING_TOOLS
+
+bool smp_trace_p = true;
+
+static void
+trace (const char * format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ if (smp_trace_p == true)
+ voutf_error_line (format, args);
+ va_end (args);
+}
+
+#else
+
+#define trace(...) do {} while (false)
+
+#endif
+
+void
+setup_processors (int count)
+{
+ trace ("; processor count: %d", option_processor_count);
+ trace ("; local heap size: %d", option_processor_heap_size);
+ trace ("; stack size: %d", option_stack_size);
+}
+
+#endif /* ENABLE_SMP */
#include "const.h" /* Various named constants */
#include "object.h" /* Scheme object representation */
#include "intrpt.h" /* Interrupt processing macros */
+#include "ossmp.h" /* Symmetric Multi-Processing declarations */
#include "critsec.h" /* Critical sections */
#include "gc.h" /* Memory management related macros */
#include "memmag.h"