Changeset 5070


Ignore:
Timestamp:
Sep 2, 2006, 10:06:43 AM (18 years ago)
Author:
Gary Byers
Message:

Define some things in terms of USE_MACH_SEMAPHORES or USE_POSIX_SEMAPHORES.

sem_wait_forever() does repeated timed waits, since I thought that
Darwin was having trouble interrpting things that waited indefinitely.
(That might just be a GDB bug. Who can tell ?)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lisp-kernel/thread_manager.c

    r5005 r5070  
    180180
    181181  do {
    182     status = SEM_WAIT(s);
     182#ifdef USE_MACH_SEMAPHORES
     183    mach_timespec_t q = {1,0};
     184    status = SEM_TIMEDWAIT(s,q);
     185#endif
     186#ifdef USE_POSIX_SEMAPHORES
     187    struct timespec q;
     188    gettimeofday((struct timeval *)&q, NULL);
     189    q.tv_sec += 1;
     190    status = SEM_TIMEDWAIT(s,&q);
     191#endif
    183192  } while (status != 0);
    184193}
     
    207216  return status;
    208217#endif
    209 #ifdef DARWIN 
     218#ifdef USE_MACH_SEMAPHORES
    210219  mach_timespec_t q = {seconds, nanos};
    211220  int status = SEM_TIMEDWAIT(s, q);
     
    342351new_semaphore(int count)
    343352{
    344 #if defined(LINUX) || defined(FREEBSD)
     353#ifdef USE_POSIX_SEMAPHORES
    345354  sem_t *s = malloc(sizeof(sem_t));
    346355  sem_init(s, 0, count);
    347356  return s;
    348357#endif
    349 #ifdef DARWIN
     358#ifdef USE_MACH_SEMAPHORES
    350359  semaphore_t s = (semaphore_t)0;
    351360  semaphore_create(mach_task_self(),&s, SYNC_POLICY_FIFO, count);
     
    384393{
    385394  if (*s) {
    386 #if defined(LINUX) || defined(FREEBSD)
     395#ifdef USE_POSIX_SEMAPHORES
    387396    sem_destroy((sem_t *)*s);
    388397#endif
    389 #ifdef DARWIN
     398#ifdef USE_MACH_SEMAPHORES
    390399    semaphore_destroy(mach_task_self(),((semaphore_t)(natural) *s));
    391400#endif
     
    948957         to a dead thread by setting tcr->osid to 0.
    949958      */
    950 #ifdef DARWIN
    951       if (mach_suspend_tcr(tcr)) {
    952         SET_TCR_FLAG(tcr,TCR_FLAG_BIT_ALT_SUSPEND);
    953         return true;
    954       }
    955 #endif
    956959      tcr->osid = 0;
    957960      return false;
Note: See TracChangeset for help on using the changeset viewer.