eus_thr.h
Go to the documentation of this file.
00001 /*
00002  * EusLisp multithread support
00003  *
00004  *      EusLisp is written using Solaris2's thread library.
00005  *      This file is provided to emulate the library in other environment.
00006  *
00007  *      alpha porting team (APT)                Jan.1996
00008  */
00009 
00010 #include <errno.h>
00011 
00012 #if Solaris2
00013 #include <synch.h>
00014 #include <thread.h>
00015 #endif
00016 
00017 #if SunOS4_1
00018 #include <lwp/lwp.h>
00019 #include <lwp/lwpmachdep.h>
00020 #include <lwp/stackdep.h>
00021 #define USYNC_THREAD    0
00022 #endif
00023 
00024 #if alpha || PTHREAD
00025 #include <pthread.h>
00026 #undef CATCH
00027 #define USYNC_THREAD    0
00028 #endif
00029 
00030 struct thread_arg {
00031   context *newctx;
00032   pointer form;
00033   pointer func;
00034   pointer arg;};
00035 
00036 
00037 /*
00038  *  MT-library specific parts
00039  */
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 /* SunOS4.1.x specific part */
00045 
00046 #if SunOS4_1
00047 /* mthread type for SunOS 4.1.x added by H.Nakagaki */
00048 typedef mon_t mutex_t;
00049 typedef cv_t  cond_t;
00050 
00051 /* lwp functions are redefined to mthread functions by H.Nakagaki */
00052 #define USYNC_THREAD       0
00053 #define THR_SUSPENDED      LWPSUSPEND
00054 #define thr_exit(x)        pod_exit(x)
00055 #define thr_join(x,y,z)    lwp_join(x)
00056 #define mutex_init(x,y,z)  mon_create(x)
00057 #define mutex_destroy(x)   mon_destroy(*(x))
00058 #define mutex_lock(x)      mon_enter(*(x))
00059 #define mutex_unlock(x)    mon_exit(*(x))
00060 #define mutex_trylock(x)   mon_cond_enter(*(x))
00061 #define cond_init(x,y)     cv_create(x,*(y))
00062 #define cond_destroy(x)    cv_destroy(*(x))
00063 #define cond_wait(x,y)     cv_wait(*(x))
00064 #define cond_signal(x)     cv_notify(*(x))
00065 #define cond_broadcast(x)  cv_broadcast(*(x))
00066 #endif  /* SunOS4_1 */
00067 
00068 
00069 /* Alpha specific part */
00070 
00071 #if alpha || PTHREAD
00072 #ifndef __COLLECTOR_H /* R.Hanai */
00073 typedef pthread_t       thread_t;
00074 typedef pthread_mutex_t mutex_t;
00075 typedef pthread_cond_t  cond_t;
00076 #define thr_exit(x)     pthread_exit(x)
00077 #define thr_join(x,y,z) pthread_join(x,z)
00078 #define mutex_init(x,y,z)       pthread_mutex_init(x,y)
00079 #define mutex_lock      pthread_mutex_lock
00080 #define mutex_trylock   pthread_mutex_trylock
00081 #define mutex_unlock    pthread_mutex_unlock
00082 #define cond_wait       pthread_cond_wait
00083 #define cond_signal     pthread_cond_signal
00084 #define cond_broadcast  pthread_cond_broadcast
00085 #endif
00086 #endif  /* alpha */
00087 
00088 
00089 /*
00090  * common part (for environment other than Solaris2)
00091  */
00092 
00093 #if !Solaris2
00094 
00095 /* type definition */
00096 typedef struct _sema {
00097         unsigned int count;
00098         mutex_t      lock;
00099         cond_t       cond;
00100       } sema_t;
00101 typedef struct _rwlock {
00102         unsigned int readers;
00103         mutex_t      lock;
00104         cond_t       r_cond;
00105         cond_t       w_cond;
00106       } rwlock_t;
00107 
00108 /* function prototype */
00109 /* lwp functions are redefined to mthread functions by H.Nakagaki */
00110 extern unsigned int thr_self();
00111 extern int thr_getprio(int tid, int *prio);
00112 extern int thr_create(void *, size_t, void (*)(), void *, long, int *);
00113 extern int thr_setprio(int, int);
00114 extern int thr_continue(int);
00115 extern int thr_suspend(int);
00116 extern int thr_kill(int, int);
00117 
00118 /* readers/writer lock function definition added by H.Nakagaki */
00119 extern int rwlock_init(rwlock_t *, int, void *);
00120 extern int rwlock_destroy(rwlock_t *);
00121 extern int rw_rdlock(rwlock_t *);
00122 extern int rw_wrlock(rwlock_t *);
00123 extern int rw_unlock(rwlock_t *);
00124 
00125 /* semaphore function defined at mthread.c added by H.Nakagaki */
00126 extern int sema_init(sema_t *, unsigned int, int, void *);
00127 extern int sema_destroy(sema_t *);
00128 extern int sema_port(sema_t *);
00129 extern int sema_wait(sema_t *);
00130 extern int sema_trywait(sema_t *);
00131 
00132 extern int mthread(context *ctx, pointer mod);
00133 #endif  /* !Solaris2 */
00134 #if PTHREAD
00135 extern int sema_post(sema_t *sem);
00136 extern void mthread_init( context *mainctx );
00137 #endif
00138 
00139 /*
00140  * EusLisp variables
00141  */
00142 
00143 /* mutex locks*/
00144 extern mutex_t  mark_lock;
00145 extern char     *mark_locking;
00146 extern int      mark_lock_thread;
00147 //extern mutex_t  p_mark_lock;
00148 extern rwlock_t gc_lock;
00149 
00150 extern mutex_t  alloc_lock;
00151 extern mutex_t  free_thread_lock;
00152 extern mutex_t  qthread_lock;
00153 extern mutex_t  qsort_lock;
00154 extern sema_t   free_thread_sem;
00155 #ifdef __cplusplus
00156 }
00157 #endif


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Jun 6 2019 18:05:53