Diff
Not logged in

Differences From Artifact [45358e1e63]:

To Artifact [c8a4006ec8]:


473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
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
525
526
527
528
529
530
531
532
533
534
535
536
537
538
473
474
475
476
477
478
479




















































480
481
482
483
484
485
486







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







#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:
598
599
600
601
602
603
604
605

606
607
608

609
610
611
612

613
614
615

616
617
618
619
620
621
622
546
547
548
549
550
551
552

553
554
555

556
557
558
559

560
561
562

563
564
565
566
567
568
569
570







-
+


-
+



-
+


-
+







	    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.