375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
#endif
}
/*
*----------------------------------------------------------------------
*
* TclpMutexLock
*
* This procedure is used to grab a lock that serializes locking
* another mutex.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TclpMutexLock(void)
{
#ifdef TCL_THREADS
pthread_mutex_lock(&mutexLock);
#endif
}
/*
*----------------------------------------------------------------------
*
* TclpMutexUnlock
*
* This procedure is used to release a lock that serializes locking
* another mutex.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TclpMutexUnlock(void)
{
#ifdef TCL_THREADS
pthread_mutex_unlock(&mutexLock);
#endif
}
/*
*----------------------------------------------------------------------
*
* Tcl_GetAllocMutex
*
* This procedure returns a pointer to a statically initialized mutex for
* use by the memory allocator. The alloctor must use this lock, because
* all other locks are allocated...
*
* Results:
|
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
|
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
-
+
-
+
-
+
-
+
|
pthread_mutex_init(pmutexPtr, NULL);
*mutexPtr = (Tcl_Mutex)pmutexPtr;
TclRememberMutex(mutexPtr);
}
MASTER_UNLOCK;
}
while (1) {
TclpMutexLock();
pthread_mutex_lock(&mutexLock);
pmutexPtr = *((pthread_mutex_t **)mutexPtr);
if (pmutexPtr == NULL) {
TclpMutexUnlock();
pthread_mutex_unlock(&mutexLock);
goto retry;
}
if (pthread_mutex_trylock(pmutexPtr) == 0) {
TclpMutexUnlock();
pthread_mutex_unlock(&mutexLock);
return;
}
TclpMutexUnlock();
pthread_mutex_unlock(&mutexLock);
/*
* BUGBUG: All core and Thread package tests pass when usleep()
* is used; however, the Thread package tests hang at
* various places when Tcl_Sleep() is used, typically
* while running test "thread-17.8", "thread-17.9", or
* "thread-17.11a". Really, what we want here is just
* to yield to other threads for a while.
|