Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | 6d023c9 | 1995-01-04 19:12:13 +0000 | [diff] [blame] | 2 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 3 | The Netherlands. |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 4 | |
| 5 | All Rights Reserved |
| 6 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 9 | provided that the above copyright notice appear in all copies and that |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 10 | both that copyright notice and this permission notice appear in |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 11 | supporting documentation, and that the names of Stichting Mathematisch |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 12 | Centrum or CWI or Corporation for National Research Initiatives or |
| 13 | CNRI not be used in advertising or publicity pertaining to |
| 14 | distribution of the software without specific, written prior |
| 15 | permission. |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 16 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 17 | While CWI is the initial source for this software, a modified version |
| 18 | is made available by the Corporation for National Research Initiatives |
| 19 | (CNRI) at the Internet address ftp://ftp.python.org. |
| 20 | |
| 21 | STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
| 22 | REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 23 | MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
| 24 | CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 25 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 26 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 27 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 28 | PERFORMANCE OF THIS SOFTWARE. |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 29 | |
| 30 | ******************************************************************/ |
| 31 | |
Guido van Rossum | 6602099 | 1996-06-11 18:32:18 +0000 | [diff] [blame] | 32 | /* Posix threads interface */ |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 33 | |
Guido van Rossum | 6602099 | 1996-06-11 18:32:18 +0000 | [diff] [blame] | 34 | #include <stdlib.h> |
| 35 | #include <pthread.h> |
| 36 | |
Guido van Rossum | 1a62311 | 1996-08-08 18:53:41 +0000 | [diff] [blame] | 37 | #ifdef _AIX |
| 38 | |
| 39 | #ifndef SCHED_BG_NP |
| 40 | /* SCHED_BG_NP is defined if using AIX DCE pthreads |
| 41 | * but it is unsupported by AIX 4 pthreads. Default |
| 42 | * attributes for AIX 4 pthreads equal to NULL. For |
| 43 | * AIX DCE pthreads they should be left unchanged. |
| 44 | */ |
| 45 | #define pthread_attr_default NULL |
| 46 | #define pthread_mutexattr_default NULL |
| 47 | #define pthread_condattr_default NULL |
| 48 | #endif |
| 49 | |
| 50 | #else |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 51 | #define pthread_attr_default ((pthread_attr_t *)0) |
| 52 | #define pthread_mutexattr_default ((pthread_mutexattr_t *)0) |
| 53 | #define pthread_condattr_default ((pthread_condattr_t *)0) |
Guido van Rossum | 1a62311 | 1996-08-08 18:53:41 +0000 | [diff] [blame] | 54 | #endif |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 55 | |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 56 | /* A pthread mutex isn't sufficient to model the Python lock type |
| 57 | * because, according to Draft 5 of the docs (P1003.4a/D5), both of the |
| 58 | * following are undefined: |
| 59 | * -> a thread tries to lock a mutex it already has locked |
| 60 | * -> a thread tries to unlock a mutex locked by a different thread |
| 61 | * pthread mutexes are designed for serializing threads over short pieces |
| 62 | * of code anyway, so wouldn't be an appropriate implementation of |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 63 | * Python's locks regardless. |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 64 | * |
| 65 | * The pthread_lock struct implements a Python lock as a "locked?" bit |
| 66 | * and a <condition, mutex> pair. In general, if the bit can be acquired |
| 67 | * instantly, it is, else the pair is used to block the thread until the |
| 68 | * bit is cleared. 9 May 1994 tim@ksr.com |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 69 | */ |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 70 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 71 | typedef struct { |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 72 | char locked; /* 0=unlocked, 1=locked */ |
| 73 | /* a <cond, mutex> pair to handle an acquire of a locked lock */ |
| 74 | pthread_cond_t lock_released; |
| 75 | pthread_mutex_t mut; |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 76 | } pthread_lock; |
| 77 | |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 78 | #define CHECK_STATUS(name) if (status < 0) { perror(name); error=1; } |
| 79 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 80 | /* |
| 81 | * Initialization. |
| 82 | */ |
| 83 | static void _init_thread _P0() |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | /* |
| 88 | * Thread support. |
| 89 | */ |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 90 | |
| 91 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 92 | int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg) |
| 93 | { |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 94 | pthread_t th; |
Guido van Rossum | e944da8 | 1994-05-23 12:43:41 +0000 | [diff] [blame] | 95 | int success; |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 96 | dprintf(("start_new_thread called\n")); |
| 97 | if (!initialized) |
| 98 | init_thread(); |
Guido van Rossum | 6602099 | 1996-06-11 18:32:18 +0000 | [diff] [blame] | 99 | success = pthread_create(&th, pthread_attr_default, |
| 100 | (void* (*) _P((void *)))func, arg); |
Guido van Rossum | f4806c2 | 1997-04-30 19:59:22 +0000 | [diff] [blame^] | 101 | if (success >= 0) |
| 102 | pthread_detach(th); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 103 | return success < 0 ? 0 : 1; |
| 104 | } |
| 105 | |
Guido van Rossum | e944da8 | 1994-05-23 12:43:41 +0000 | [diff] [blame] | 106 | long get_thread_ident _P0() |
| 107 | { |
Guido van Rossum | 2565bff | 1995-01-09 17:50:47 +0000 | [diff] [blame] | 108 | pthread_t threadid; |
Guido van Rossum | e944da8 | 1994-05-23 12:43:41 +0000 | [diff] [blame] | 109 | if (!initialized) |
| 110 | init_thread(); |
Guido van Rossum | 2565bff | 1995-01-09 17:50:47 +0000 | [diff] [blame] | 111 | /* Jump through some hoops for Alpha OSF/1 */ |
| 112 | threadid = pthread_self(); |
| 113 | return (long) *(long *) &threadid; |
Guido van Rossum | e944da8 | 1994-05-23 12:43:41 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 116 | static void do_exit_thread _P1(no_cleanup, int no_cleanup) |
| 117 | { |
| 118 | dprintf(("exit_thread called\n")); |
| 119 | if (!initialized) |
| 120 | if (no_cleanup) |
| 121 | _exit(0); |
| 122 | else |
| 123 | exit(0); |
| 124 | } |
| 125 | |
| 126 | void exit_thread _P0() |
| 127 | { |
| 128 | do_exit_thread(0); |
| 129 | } |
| 130 | |
| 131 | void _exit_thread _P0() |
| 132 | { |
| 133 | do_exit_thread(1); |
| 134 | } |
| 135 | |
| 136 | #ifndef NO_EXIT_PROG |
| 137 | static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup) |
| 138 | { |
| 139 | dprintf(("exit_prog(%d) called\n", status)); |
| 140 | if (!initialized) |
| 141 | if (no_cleanup) |
| 142 | _exit(status); |
| 143 | else |
| 144 | exit(status); |
| 145 | } |
| 146 | |
| 147 | void exit_prog _P1(status, int status) |
| 148 | { |
| 149 | do_exit_prog(status, 0); |
| 150 | } |
| 151 | |
| 152 | void _exit_prog _P1(status, int status) |
| 153 | { |
| 154 | do_exit_prog(status, 1); |
| 155 | } |
| 156 | #endif /* NO_EXIT_PROG */ |
| 157 | |
| 158 | /* |
| 159 | * Lock support. |
| 160 | */ |
| 161 | type_lock allocate_lock _P0() |
| 162 | { |
| 163 | pthread_lock *lock; |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 164 | int status, error = 0; |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 165 | |
| 166 | dprintf(("allocate_lock called\n")); |
| 167 | if (!initialized) |
| 168 | init_thread(); |
| 169 | |
| 170 | lock = (pthread_lock *) malloc(sizeof(pthread_lock)); |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 171 | if (lock) { |
| 172 | lock->locked = 0; |
| 173 | |
| 174 | status = pthread_mutex_init(&lock->mut, |
| 175 | pthread_mutexattr_default); |
| 176 | CHECK_STATUS("pthread_mutex_init"); |
| 177 | |
| 178 | status = pthread_cond_init(&lock->lock_released, |
| 179 | pthread_condattr_default); |
| 180 | CHECK_STATUS("pthread_cond_init"); |
| 181 | |
| 182 | if (error) { |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 183 | free((void *)lock); |
| 184 | lock = 0; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | dprintf(("allocate_lock() -> %lx\n", (long)lock)); |
| 189 | return (type_lock) lock; |
| 190 | } |
| 191 | |
| 192 | void free_lock _P1(lock, type_lock lock) |
| 193 | { |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 194 | pthread_lock *thelock = (pthread_lock *)lock; |
| 195 | int status, error = 0; |
| 196 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 197 | dprintf(("free_lock(%lx) called\n", (long)lock)); |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 198 | |
| 199 | status = pthread_mutex_destroy( &thelock->mut ); |
| 200 | CHECK_STATUS("pthread_mutex_destroy"); |
| 201 | |
| 202 | status = pthread_cond_destroy( &thelock->lock_released ); |
| 203 | CHECK_STATUS("pthread_cond_destroy"); |
| 204 | |
| 205 | free((void *)thelock); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag) |
| 209 | { |
| 210 | int success; |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 211 | pthread_lock *thelock = (pthread_lock *)lock; |
| 212 | int status, error = 0; |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 213 | |
| 214 | dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 215 | |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 216 | status = pthread_mutex_lock( &thelock->mut ); |
| 217 | CHECK_STATUS("pthread_mutex_lock[1]"); |
| 218 | success = thelock->locked == 0; |
| 219 | if (success) thelock->locked = 1; |
| 220 | status = pthread_mutex_unlock( &thelock->mut ); |
| 221 | CHECK_STATUS("pthread_mutex_unlock[1]"); |
| 222 | |
| 223 | if ( !success && waitflag ) { |
| 224 | /* continue trying until we get the lock */ |
| 225 | |
| 226 | /* mut must be locked by me -- part of the condition |
| 227 | * protocol */ |
| 228 | status = pthread_mutex_lock( &thelock->mut ); |
| 229 | CHECK_STATUS("pthread_mutex_lock[2]"); |
| 230 | while ( thelock->locked ) { |
| 231 | status = pthread_cond_wait(&thelock->lock_released, |
| 232 | &thelock->mut); |
| 233 | CHECK_STATUS("pthread_cond_wait"); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 234 | } |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 235 | thelock->locked = 1; |
| 236 | status = pthread_mutex_unlock( &thelock->mut ); |
| 237 | CHECK_STATUS("pthread_mutex_unlock[2]"); |
| 238 | success = 1; |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 239 | } |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 240 | if (error) success = 0; |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 241 | dprintf(("acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); |
| 242 | return success; |
| 243 | } |
| 244 | |
| 245 | void release_lock _P1(lock, type_lock lock) |
| 246 | { |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 247 | pthread_lock *thelock = (pthread_lock *)lock; |
| 248 | int status, error = 0; |
| 249 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 250 | dprintf(("release_lock(%lx) called\n", (long)lock)); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 251 | |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 252 | status = pthread_mutex_lock( &thelock->mut ); |
| 253 | CHECK_STATUS("pthread_mutex_lock[3]"); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 254 | |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 255 | thelock->locked = 0; |
| 256 | |
| 257 | status = pthread_mutex_unlock( &thelock->mut ); |
| 258 | CHECK_STATUS("pthread_mutex_unlock[3]"); |
| 259 | |
| 260 | /* wake up someone (anyone, if any) waiting on the lock */ |
| 261 | status = pthread_cond_signal( &thelock->lock_released ); |
| 262 | CHECK_STATUS("pthread_cond_signal"); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | /* |
| 266 | * Semaphore support. |
| 267 | */ |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 268 | |
| 269 | struct semaphore { |
| 270 | pthread_mutex_t mutex; |
| 271 | pthread_cond_t cond; |
| 272 | int value; |
| 273 | }; |
Guido van Rossum | b98b1b3 | 1994-05-11 08:42:04 +0000 | [diff] [blame] | 274 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 275 | type_sema allocate_sema _P1(value, int value) |
| 276 | { |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 277 | struct semaphore *sema; |
| 278 | int status, error = 0; |
| 279 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 280 | dprintf(("allocate_sema called\n")); |
| 281 | if (!initialized) |
| 282 | init_thread(); |
| 283 | |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 284 | sema = (struct semaphore *) malloc(sizeof(struct semaphore)); |
| 285 | if (sema != NULL) { |
| 286 | sema->value = value; |
| 287 | status = pthread_mutex_init(&sema->mutex, |
| 288 | pthread_mutexattr_default); |
| 289 | CHECK_STATUS("pthread_mutex_init"); |
| 290 | status = pthread_cond_init(&sema->cond, |
| 291 | pthread_condattr_default); |
| 292 | CHECK_STATUS("pthread_cond_init"); |
| 293 | if (error) { |
| 294 | free((void *) sema); |
| 295 | sema = NULL; |
| 296 | } |
| 297 | } |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 298 | dprintf(("allocate_sema() -> %lx\n", (long) sema)); |
| 299 | return (type_sema) sema; |
| 300 | } |
| 301 | |
| 302 | void free_sema _P1(sema, type_sema sema) |
| 303 | { |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 304 | int status, error = 0; |
| 305 | struct semaphore *thesema = (struct semaphore *) sema; |
| 306 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 307 | dprintf(("free_sema(%lx) called\n", (long) sema)); |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 308 | status = pthread_cond_destroy(&thesema->cond); |
| 309 | CHECK_STATUS("pthread_cond_destroy"); |
| 310 | status = pthread_mutex_destroy(&thesema->mutex); |
| 311 | CHECK_STATUS("pthread_mutex_destroy"); |
| 312 | free((void *) thesema); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 313 | } |
| 314 | |
Guido van Rossum | cf1474b | 1996-10-08 14:17:53 +0000 | [diff] [blame] | 315 | int down_sema _P2(sema, type_sema sema, waitflag, int waitflag) |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 316 | { |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 317 | int status, error = 0, success; |
| 318 | struct semaphore *thesema = (struct semaphore *) sema; |
| 319 | |
Guido van Rossum | cf1474b | 1996-10-08 14:17:53 +0000 | [diff] [blame] | 320 | dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag)); |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 321 | status = pthread_mutex_lock(&thesema->mutex); |
| 322 | CHECK_STATUS("pthread_mutex_lock"); |
| 323 | if (waitflag) { |
| 324 | while (!error && thesema->value <= 0) { |
| 325 | status = pthread_cond_wait(&thesema->cond, |
| 326 | &thesema->mutex); |
| 327 | CHECK_STATUS("pthread_cond_wait"); |
| 328 | } |
| 329 | } |
| 330 | if (error) |
| 331 | success = 0; |
| 332 | else if (thesema->value > 0) { |
| 333 | thesema->value--; |
| 334 | success = 1; |
| 335 | } |
| 336 | else |
| 337 | success = 0; |
| 338 | status = pthread_mutex_unlock(&thesema->mutex); |
| 339 | CHECK_STATUS("pthread_mutex_unlock"); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 340 | dprintf(("down_sema(%lx) return\n", (long) sema)); |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 341 | return success; |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | void up_sema _P1(sema, type_sema sema) |
| 345 | { |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 346 | int status, error = 0; |
| 347 | struct semaphore *thesema = (struct semaphore *) sema; |
| 348 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 349 | dprintf(("up_sema(%lx)\n", (long) sema)); |
Guido van Rossum | 7af8130 | 1997-01-17 21:06:41 +0000 | [diff] [blame] | 350 | status = pthread_mutex_lock(&thesema->mutex); |
| 351 | CHECK_STATUS("pthread_mutex_lock"); |
| 352 | thesema->value++; |
| 353 | status = pthread_cond_signal(&thesema->cond); |
| 354 | CHECK_STATUS("pthread_cond_signal"); |
| 355 | status = pthread_mutex_unlock(&thesema->mutex); |
| 356 | CHECK_STATUS("pthread_mutex_unlock"); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 357 | } |