eus_thr.h
Go to the documentation of this file.
1 /*
2  * EusLisp multithread support
3  *
4  * EusLisp is written using Solaris2's thread library.
5  * This file is provided to emulate the library in other environment.
6  *
7  * alpha porting team (APT) Jan.1996
8  */
9 
10 #include <errno.h>
11 
12 #if Solaris2
13 #include <synch.h>
14 #include <thread.h>
15 #endif
16 
17 #if SunOS4_1
18 #include <lwp/lwp.h>
19 #include <lwp/lwpmachdep.h>
20 #include <lwp/stackdep.h>
21 #define USYNC_THREAD 0
22 #endif
23 
24 #if alpha || PTHREAD
25 #include <pthread.h>
26 #undef CATCH
27 #define USYNC_THREAD 0
28 #endif
29 
30 struct thread_arg {
35 
36 
37 /*
38  * MT-library specific parts
39  */
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 /* SunOS4.1.x specific part */
45 
46 #if SunOS4_1
47 /* mthread type for SunOS 4.1.x added by H.Nakagaki */
48 typedef mon_t mutex_t;
49 typedef cv_t cond_t;
50 
51 /* lwp functions are redefined to mthread functions by H.Nakagaki */
52 #define USYNC_THREAD 0
53 #define THR_SUSPENDED LWPSUSPEND
54 #define thr_exit(x) pod_exit(x)
55 #define thr_join(x,y,z) lwp_join(x)
56 #define mutex_init(x,y,z) mon_create(x)
57 #define mutex_destroy(x) mon_destroy(*(x))
58 #define mutex_lock(x) mon_enter(*(x))
59 #define mutex_unlock(x) mon_exit(*(x))
60 #define mutex_trylock(x) mon_cond_enter(*(x))
61 #define cond_init(x,y) cv_create(x,*(y))
62 #define cond_destroy(x) cv_destroy(*(x))
63 #define cond_wait(x,y) cv_wait(*(x))
64 #define cond_signal(x) cv_notify(*(x))
65 #define cond_broadcast(x) cv_broadcast(*(x))
66 #endif /* SunOS4_1 */
67 
68 
69 /* Alpha specific part */
70 
71 #if alpha || PTHREAD
72 #ifndef __COLLECTOR_H /* R.Hanai */
73 typedef pthread_t thread_t;
74 typedef pthread_mutex_t mutex_t;
75 typedef pthread_cond_t cond_t;
76 #define thr_exit(x) pthread_exit(x)
77 #define thr_join(x,y,z) pthread_join(x,z)
78 #define mutex_init(x,y,z) pthread_mutex_init(x,y)
79 #define mutex_lock pthread_mutex_lock
80 #define mutex_trylock pthread_mutex_trylock
81 #define mutex_unlock pthread_mutex_unlock
82 #define cond_wait pthread_cond_wait
83 #define cond_signal pthread_cond_signal
84 #define cond_broadcast pthread_cond_broadcast
85 #endif
86 #endif /* alpha */
87 
88 
89 /*
90  * common part (for environment other than Solaris2)
91  */
92 
93 #if !Solaris2
94 
95 /* type definition */
96 typedef struct _sema {
97  unsigned int count;
98  mutex_t lock;
99  cond_t cond;
100  } sema_t;
101 typedef struct _rwlock {
102  unsigned int readers;
103  mutex_t lock;
104  cond_t r_cond;
105  cond_t w_cond;
106  } rwlock_t;
107 
108 /* function prototype */
109 /* lwp functions are redefined to mthread functions by H.Nakagaki */
110 extern unsigned int thr_self();
111 extern int thr_getprio(int tid, int *prio);
112 extern int thr_create(void *, size_t, void (*)(), void *, long, int *);
113 extern int thr_setprio(int, int);
114 extern int thr_continue(int);
115 extern int thr_suspend(int);
116 extern int thr_kill(int, int);
117 
118 /* readers/writer lock function definition added by H.Nakagaki */
119 extern int rwlock_init(rwlock_t *, int, void *);
120 extern int rwlock_destroy(rwlock_t *);
121 extern int rw_rdlock(rwlock_t *);
122 extern int rw_wrlock(rwlock_t *);
123 extern int rw_unlock(rwlock_t *);
124 
125 /* semaphore function defined at mthread.c added by H.Nakagaki */
126 extern int sema_init(sema_t *, unsigned int, int, void *);
127 extern int sema_destroy(sema_t *);
128 extern int sema_port(sema_t *);
129 extern int sema_wait(sema_t *);
130 extern int sema_trywait(sema_t *);
131 
132 extern int mthread(context *ctx, pointer mod);
133 #endif /* !Solaris2 */
134 #if PTHREAD
135 extern int sema_post(sema_t *sem);
136 extern void mthread_init( context *mainctx );
137 #endif
138 
139 /*
140  * EusLisp variables
141  */
142 
143 /* mutex locks*/
144 extern mutex_t mark_lock;
145 extern char *mark_locking;
146 extern int mark_lock_thread;
147 //extern mutex_t p_mark_lock;
148 extern rwlock_t gc_lock;
149 
150 extern mutex_t alloc_lock;
151 extern mutex_t free_thread_lock;
152 extern mutex_t qthread_lock;
153 extern mutex_t qsort_lock;
154 extern sema_t free_thread_sem;
155 #ifdef __cplusplus
156 }
157 #endif
pointer form
Definition: eus_thr.h:32
struct _sema sema_t
Definition: eus.h:522
int rwlock_destroy(rwlock_t *)
Definition: pthreads.c:172
int mthread(context *ctx, pointer mod)
Definition: mthread.c:536
int thr_continue(int)
Definition: pthreads.c:58
int thr_setprio(int, int)
Definition: pthreads.c:30
cond_t w_cond
Definition: eus_thr.h:105
int sema_init(sema_t *, unsigned int, int, void *)
Definition: pthreads.c:111
cond_t cond
Definition: eus_thr.h:99
context * mainctx
Definition: eus.c:57
mutex_t mark_lock
Definition: mthread.c:25
unsigned int count
Definition: eus_thr.h:97
int sema_port(sema_t *)
pointer arg
Definition: eus_thr.h:34
rwlock_t gc_lock
Definition: mthread.c:18
int mark_lock_thread
Definition: mthread.c:27
Definition: eus_thr.h:96
int thr_kill(int, int)
Definition: pthreads.c:70
int rwlock_init(rwlock_t *, int, void *)
Definition: pthreads.c:164
mutex_t qsort_lock
Definition: mthread.c:21
thread_t tid
Definition: collector.c:50
context * newctx
Definition: eus_thr.h:31
int thr_suspend(int)
Definition: pthreads.c:64
Definition: eus.h:379
mutex_t free_thread_lock
Definition: mthread.c:13
unsigned int thr_self()
Definition: eus.c:25
int rw_wrlock(rwlock_t *)
Definition: pthreads.c:188
int sema_wait(sema_t *)
Definition: pthreads.c:124
mutex_t alloc_lock
Definition: memory.mutex.c:42
cond_t r_cond
Definition: eus_thr.h:104
int sema_destroy(sema_t *)
Definition: pthreads.c:118
int thr_create(void *, size_t, void(*)(), void *, long, int *)
Definition: pthreads.c:43
int rw_rdlock(rwlock_t *)
Definition: pthreads.c:179
int sema_trywait(sema_t *)
Definition: pthreads.c:133
mutex_t qthread_lock
Definition: mthread.c:14
int rw_unlock(rwlock_t *)
Definition: pthreads.c:197
int thr_getprio(int tid, int *prio)
Definition: pthreads.c:21
unsigned int readers
Definition: eus_thr.h:102
int sema_post(sema_t *sem)
Definition: pthreads.c:148
mutex_t lock
Definition: eus_thr.h:98
struct _rwlock rwlock_t
pointer func
Definition: eus_thr.h:33
mutex_t lock
Definition: eus_thr.h:103
sema_t free_thread_sem
Definition: mthread.c:11
char * mark_locking
Definition: mthread.c:26


euslisp
Author(s): Toshihiro Matsui
autogenerated on Fri Feb 21 2020 03:20:54