comparison Python/thread.c @ 1179:9ae65ee09735 legacy-trunk

Various changes. * Makefile: svmodule.c.proto and svgen.py are gone, svmodule.c came in their stead. Also, pass -DUSE_DL flag to thread.c and give the user a possibility to add the -DDEBUG to just thread.c. * ceval.c: init_save_thread() can be called more than once now. * svgen.py, svmodule.c.proto, svmodule.c: Removed prototype file and replaced it by the generated file. * thread.c: Added some more checks; added call to DL library when it is also used to tell it where the shared arena is so that DL can use some other area. * threadmodule.c: Call init_save_thread from another place. Also, added new function getlocklock() which does to lock objects what getfilefile does to file objects.
author Sjoerd Mullender <sjoerd@acm.org>
date Wed, 06 Jan 1993 13:36:38 +0000
parents 6b5a34db21fe
children cf8ddb29e26e
comparison
equal deleted inserted replaced
1178:f9bbb01388d5 1179:9ae65ee09735
21 static ulock_t count_lock; /* protection for some variables */ 21 static ulock_t count_lock; /* protection for some variables */
22 static ulock_t wait_lock; /* lock used to wait for other threads */ 22 static ulock_t wait_lock; /* lock used to wait for other threads */
23 static int waiting_for_threads; /* protected by count_lock */ 23 static int waiting_for_threads; /* protected by count_lock */
24 static int nthreads; /* protected by count_lock */ 24 static int nthreads; /* protected by count_lock */
25 static int exit_status; 25 static int exit_status;
26 static int do_exit; 26 static int do_exit; /* indicates that the program is to exit */
27 static int exiting; /* we're already exiting (for maybe_exit) */ 27 static int exiting; /* we're already exiting (for maybe_exit) */
28 static pid_t my_pid; /* PID of main thread */ 28 static pid_t my_pid; /* PID of main thread */
29 static pid_t pidlist[MAXPROC]; /* PIDs of other threads */ 29 static pid_t pidlist[MAXPROC]; /* PIDs of other threads */
30 static int maxpidindex; /* # of PIDs in pidlist */ 30 static int maxpidindex; /* # of PIDs in pidlist */
31 #endif 31 #endif
104 #endif 104 #endif
105 105
106 #ifdef DEBUG 106 #ifdef DEBUG
107 thread_debug = getenv("THREADDEBUG") != 0; 107 thread_debug = getenv("THREADDEBUG") != 0;
108 #endif 108 #endif
109 dprintf(("init_thread called\n"));
110 if (initialized) 109 if (initialized)
111 return; 110 return;
112 initialized = 1; 111 initialized = 1;
113 112 dprintf(("init_thread called\n"));
114 #ifdef __sgi 113
114 #ifdef __sgi
115 if (usconfig(CONF_INITUSERS, 16) < 0)
116 perror("usconfig - CONF_INITUSERS");
115 my_pid = getpid(); /* so that we know which is the main thread */ 117 my_pid = getpid(); /* so that we know which is the main thread */
116 atexit(maybe_exit); 118 atexit(maybe_exit);
117 s.sa_handler = exit_sig; 119 s.sa_handler = exit_sig;
118 sigemptyset(&s.sa_mask); 120 sigemptyset(&s.sa_mask);
119 /*sigaddset(&s.sa_mask, SIGUSR1);*/ 121 /*sigaddset(&s.sa_mask, SIGUSR1);*/
120 s.sa_flags = 0; 122 s.sa_flags = 0;
121 sigaction(SIGUSR1, &s, 0); 123 sigaction(SIGUSR1, &s, 0);
122 prctl(PR_SETEXITSIG, SIGUSR1); 124 if (prctl(PR_SETEXITSIG, SIGUSR1) < 0)
123 usconfig(CONF_ARENATYPE, US_SHAREDONLY); 125 perror("prctl - PR_SETEXITSIG");
126 if (usconfig(CONF_ARENATYPE, US_SHAREDONLY) < 0)
127 perror("usconfig - CONF_ARENATYPE");
124 /*usconfig(CONF_LOCKTYPE, US_DEBUGPLUS);*/ 128 /*usconfig(CONF_LOCKTYPE, US_DEBUGPLUS);*/
125 shared_arena = usinit(tmpnam(0)); 129 if ((shared_arena = usinit(tmpnam(0))) == 0)
130 perror("usinit");
126 count_lock = usnewlock(shared_arena); 131 count_lock = usnewlock(shared_arena);
127 (void) usinitlock(count_lock); 132 (void) usinitlock(count_lock);
128 wait_lock = usnewlock(shared_arena); 133 wait_lock = usnewlock(shared_arena);
134 dprintf(("arena start: %lx, arena size: %ld\n", (long) shared_arena, (long) usconfig(CONF_GETSIZE, shared_arena)));
135 #ifdef USE_DL /* for python */
136 dl_setrange((long) shared_arena, (long) shared_arena + 64 * 1024);
137 #endif
129 #endif 138 #endif
130 #ifdef sun 139 #ifdef sun
131 lwp_setstkcache(STACKSIZE, NSTACKS); 140 lwp_setstkcache(STACKSIZE, NSTACKS);
132 #endif 141 #endif
133 #ifdef C_THREADS 142 #ifdef C_THREADS