Changeset 665


Ignore:
Timestamp:
Mar 17, 2004, 4:19:52 PM (21 years ago)
Author:
Gary Byers
Message:

Foreign thread exit on first cleanup call. (Should all threads do so, after
all ?)

File:
1 edited

Legend:

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

    r622 r665  
    148148}
    149149
    150  
    151150int
    152151wait_on_semaphore(SEMAPHORE s, int seconds, int nanos)
     
    167166#ifdef DARWIN
    168167  mach_timespec_t q = {seconds, nanos};
    169   return SEM_TIMEDWAIT(s, q);
    170 #endif
    171 }
     168  do {
     169    clock_t start = clock();
     170
     171    int status = SEM_TIMEDWAIT(s, q);
     172    clock_t finish = clock();
     173
     174    if (status == KERN_ABORTED) {
     175      clock_t elapsed = (finish - start);
     176
     177      int elapsed_seconds = elapsed/CLOCKS_PER_SEC;
     178      int elapsed_nanos = (elapsed - (elapsed_seconds * CLOCKS_PER_SEC)) * 1000000000/CLOCKS_PER_SEC;
     179
     180      seconds = seconds - elapsed_seconds - (elapsed_nanos/1000000000);
     181      if (nanos  > 0) {
     182        nanos = 1000000000 - elapsed_nanos;
     183      }
     184
     185      if ((seconds <= 0) && (nanos <= 0)) {
     186        return 0;
     187      }
     188
     189      q.tv_sec = seconds;
     190      q.tv_nsec = nanos;
     191    } else {
     192      return status;
     193    }
     194  } while (1==1);
     195  // Possible limit on number of retries?
     196
     197#endif
     198}
     199
    172200
    173201void
     
    749777      current->vs_area->active -= 4;
    750778    }
     779    current->shutdown_count = 1;
    751780    ((void (*)())ptr_from_lispobj(callback_ptr))(0);
    752781
Note: See TracChangeset for help on using the changeset viewer.