guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: threads & gc


From: Mikael Djurfeldt
Subject: Re: threads & gc
Date: 16 Sep 2000 19:06:36 +0200
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

Michael Livshin <address@hidden> writes:

>   * either a way to enumerate all threads in the process or a
>     requirement that all Guile-using threads are started with a
>     Guile-specific "pthread_create" wrapper.

I really should read this thread soon.  For now, just a short comment:

The plan is that libguile will have a "plug in" interface for threads
so that libguile can be used together with different thread libraries
without recompilation.

Dirk has already implemented most of this on the dirk thread branch in
CVS.

I mention this, because everything we need in the thread interface
needs to be represented in the plug in interface.

Regarding the wrapper you talk about above, something like that
already exists----there is a primitive for creating scheme level
threads, and that invokes a scheme specific bootstrap routine.  Anyone
of these two can record any administrative information we need for
scheme level threads.

For your reference, here's the current version of the thread
interface:


struct scm_threads {
  /* Threads */
  /* Dirk:FIXME:: What is the start_routine expected to return? */
  scm_thread_t (*make_thread) (scm_threadattr_t * attr, void * (*start_routine) 
(void *), void * arg);
  void (*thread_exit) (void * retval);
  int (*thread_cancel) (scm_thread_t thread);
  /* Dirk:FIXME:: What is the retval supposed to be? */
  int (*thread_join) (scm_thread_t thread, void ** retval);
  size_t (*thread_free) (scm_thread_t thread); /* returns freed amount of 
memory */

  /* Cooperative threads (optional) */
  void (*thread_yield) (void);
  /* Dirk:FIXME:: Should the name be changed to select? */
  /* Dirk:FIXME:: Is this interface OK? */
  int (*thread_select) 
    (int fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, struct 
timeval *timeout);

  /* Mutecis */
  scm_mutex_t * (*make_mutex) (const scm_mutexattr_t * mutexattr);
  /* Dirk:FIXME:: What is the return value needed for? */
  int (*mutex_lock) (scm_mutex_t * mutex);
  int (*mutex_trylock) (scm_mutex_t * mutex);
  /* Dirk:FIXME:: What is the return value needed for? */
  int (*mutex_unlock) (scm_mutex_t * mutex);
  size_t (*mutex_free) (scm_mutex_t * mutex); /* returns freed amount of memory 
*/

  /* Condition variables */
  scm_cond_t * (*make_cond) (const scm_condattr_t * cond_attr);
  /* Dirk:FIXME:: What is the return value needed for? */
  int (*cond_signal) (scm_cond_t * cond);
  /* Dirk:FIXME:: What is the return value needed for? */
  int (*cond_broadcast) (scm_cond_t * cond);
  /* Dirk:FIXME:: What is the return value needed for? */
  int (*cond_wait) (scm_cond_t * cond, scm_mutex_t * mutex);
  /* Dirk:FIXME:: What is the return value needed for? */
  int (*cond_timedwait) (scm_cond_t * cond, scm_mutex_t * mutex, const struct 
timespec * abstime);
  size_t (*cond_free) (scm_cond_t * cond); /* returns freed amount of memory */

  /* Keys */
  /* Dirk:FIXME:: What is the return value needed for? */
  /* Dirk:FIXME:: What does the parameter destr_function do? */
  /* Dirk:FIXME:: Shouldn't there rather be functions make-key, key_delete, 
key_free? */
  int (*key_create) (scm_key_t * key, void (*destr_function) (void *));
  /* Dirk:FIXME:: What is the return value needed for? */
  int (*key_delete) (scm_key_t key);

  /* Thread specific data */
  /* Dirk:FIXME:: Neither implemented nor used yet: */
  /* Dirk:FIXME:: What is the return value needed for? */
  int (*set_thread_specific_data) (scm_key_t key, const void *);
  /* Dirk:FIXME:: Neither implemented nor used yet: */
  void * (*thread_specific_data) (scm_key_t key);
  /* Dirk:FIXME:: shouldn't the parameter be a scm_root_state* ? */
  void (*set_thread_local_data) (void * data);
  void * (*thread_local_data) (void);

  /* Garbage collection */
  void (*threads_mark_stacks) (void);

  /* Parameters */
  void (*set_threads_stack_size) (size_t size);
};


reply via email to

[Prev in Thread] Current Thread [Next in Thread]