comparison Python/thread.c @ 1004:5d7142ea01b7 legacy-trunk

adapted SV module to the new svideo library. update thread package.
author Sjoerd Mullender <sjoerd@acm.org>
date Wed, 02 Sep 1992 11:25:37 +0000
parents a31e07847063
children b33228e3c2c2
comparison
equal deleted inserted replaced
1003:17db059b29ba 1004:5d7142ea01b7
1 #include "thread.h" 1 #include "thread.h"
2
3 <<<<<<< thread.c
4 #ifndef DEBUG
5 #define DEBUG
6 #endif
2 7
3 #ifdef DEBUG 8 #ifdef DEBUG
4 #define dprintf(args) printf args 9 #define dprintf(args) printf args
5 #else 10 #else
6 #define dprintf(args) 11 #define dprintf(args)
7 #endif 12 #endif
8 13
14 =======
15 #ifdef DEBUG
16 #define dprintf(args) printf args
17 #else
18 #define dprintf(args)
19 #endif
20
21 >>>>>>> 2.3
9 #ifdef __sgi 22 #ifdef __sgi
10 #include <stdlib.h> 23 #include <stdlib.h>
11 #include <stdio.h> 24 #include <stdio.h>
12 #include <signal.h> 25 #include <signal.h>
13 #include <sys/types.h> 26 #include <sys/types.h>
57 #define _P2(v1,t1,v2,t2) (v1,v2) t1; t2; 70 #define _P2(v1,t1,v2,t2) (v1,v2) t1; t2;
58 #endif 71 #endif
59 72
60 static int initialized; 73 static int initialized;
61 74
75 <<<<<<< thread.c
62 #ifdef __sgi 76 #ifdef __sgi
63 /* 77 /*
64 * This routine is called as a signal handler when another thread 78 * This routine is called as a signal handler when another thread
65 * exits. When that happens, we must see whether we have to exit as 79 * exits. When that happens, we must see whether we have to exit as
66 * well (because of an exit_prog()) or whether we should continue on. 80 * well (because of an exit_prog()) or whether we should continue on.
77 exit_thread(); 91 exit_thread();
78 } 92 }
79 } 93 }
80 94
81 /* 95 /*
82 * This routune is called when a process calls exit(). If that wasn't 96 * This routine is called when a process calls exit(). If that wasn't
83 * done from the library, we do as if an exit_prog() was intended. 97 * done from the library, we do as if an exit_prog() was intended.
84 */ 98 */
85 static void maybe_exit _P0() 99 static void maybe_exit _P0()
86 { 100 {
87 dprintf(("maybe_exit called\n")); 101 dprintf(("maybe_exit called\n"));
132 } 146 }
133 147
134 /* 148 /*
135 * Thread support. 149 * Thread support.
136 */ 150 */
151 =======
152 #ifdef __sgi
153 /*
154 * This routine is called as a signal handler when another thread
155 * exits. When that happens, we must see whether we have to exit as
156 * well (because of an exit_prog()) or whether we should continue on.
157 */
158 static void exit_sig _P0()
159 {
160 dprintf(("exit_sig called\n"));
161 if (exiting && getpid() == my_pid) {
162 dprintf(("already exiting\n"));
163 return;
164 }
165 if (do_exit) {
166 dprintf(("exiting in exit_sig\n"));
167 exit_thread();
168 }
169 }
170
171 /*
172 * This routune is called when a process calls exit(). If that wasn't
173 * done from the library, we do as if an exit_prog() was intended.
174 */
175 static void maybe_exit _P0()
176 {
177 dprintf(("maybe_exit called\n"));
178 if (exiting) {
179 dprintf(("already exiting\n"));
180 return;
181 }
182 exit_prog(0);
183 }
184 #endif
185
186 /*
187 * Initialization.
188 */
189 void init_thread _P0()
190 {
191 #ifdef __sgi
192 struct sigaction s;
193 #endif
194
195 dprintf(("init_thread called\n"));
196 if (initialized)
197 return;
198 initialized = 1;
199
200 #ifdef __sgi
201 my_pid = getpid(); /* so that we know which is the main thread */
202 atexit(maybe_exit);
203 s.sa_handler = exit_sig;
204 sigemptyset(&s.sa_mask);
205 sigaddset(&s.sa_mask, SIGUSR1);
206 s.sa_flags = 0;
207 sigaction(SIGUSR1, &s, 0);
208 prctl(PR_SETEXITSIG, SIGUSR1);
209 usconfig(CONF_ARENATYPE, US_SHAREDONLY);
210 /*usconfig(CONF_LOCKTYPE, US_DEBUGPLUS);*/
211 shared_arena = usinit(tmpnam(0));
212 count_lock = usnewlock(shared_arena);
213 (void) usinitlock(count_lock);
214 wait_lock = usnewlock(shared_arena);
215 #endif
216 #ifdef sun
217 lwp_setstkcache(STACKSIZE, NSTACKS);
218 #endif
219 #ifdef C_THREADS
220 cthread_init();
221 #endif
222 }
223
224 /*
225 * Thread support.
226 */
227 >>>>>>> 2.3
137 int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg) 228 int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
138 { 229 {
139 #ifdef sun 230 #ifdef sun
140 thread_t tid; 231 thread_t tid;
141 #endif 232 #endif