From dfed77639ae434c50eb1b5823bdf7a6751faf576 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 15 Dec 2015 22:58:15 -0500 Subject: [PATCH] Adding thread application stubs --- gc.c | 5 +++-- include/cyclone/types.h | 2 +- scheme/base.sld | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gc.c b/gc.c index e1137c01..82fa9971 100644 --- a/gc.c +++ b/gc.c @@ -70,7 +70,7 @@ void gc_initialize() } // Add data for a new mutator -void gc_add_mutator(gc_thread_data *thd) +int gc_add_mutator(gc_thread_data *thd) { // TODO: need to sync access to these static variables. both here and // elsewhere in the module!! @@ -78,12 +78,13 @@ void gc_add_mutator(gc_thread_data *thd) for (i = 0; i < Cyc_num_mutators; i++) { if (!Cyc_mutators[i]) { Cyc_mutators[i] = thd; - return; + return i; } } // TODO: unable to create any more mutators. what to do??? fprintf(stderr, "Unable to create a new thread, exiting\n"); exit(1); + return -1; } gc_heap *gc_heap_create(size_t size, size_t max_size, size_t chunk_size) diff --git a/include/cyclone/types.h b/include/cyclone/types.h index 1c375c81..9ba3b8da 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -159,7 +159,7 @@ void vpbuffer_free(void **buf); /* GC prototypes */ void gc_initialize(); -void gc_add_mutator(gc_thread_data *thd); +int gc_add_mutator(gc_thread_data *thd); gc_heap *gc_heap_create(size_t size, size_t max_size, size_t chunk_size); int gc_grow_heap(gc_heap *h, size_t size, size_t chunk_size); char *gc_copy_obj(object hp, char *obj, gc_thread_data *thd); diff --git a/scheme/base.sld b/scheme/base.sld index 2f5d1b6f..a86286f1 100644 --- a/scheme/base.sld +++ b/scheme/base.sld @@ -1,5 +1,8 @@ (define-library (scheme base) (export + ;; Thread functions. these are not standard, and may be relocated + make-thread + ;; END threads ; TODO: need filter for the next two. also, they really belong in SRFI-1, not here ;delete ;delete-duplicates @@ -95,6 +98,13 @@ quasiquote ) (begin + ;; Threading + (define (make-thread thunk . name) + (let ((name-str (if (pair? name) + (car name) + ""))) + (list 'cyc-thread-obj thunk name-str))) + ;; Features implemented by this Scheme (define (features) '(cyclone r7rs exact-closed))