Changeset 15289


Ignore:
Timestamp:
Mar 29, 2012, 8:11:02 AM (7 years ago)
Author:
gb
Message:

In sem_wait_forever(), don't try to do repeated 1-second timed waits.
(While trying to debug something presumably unrelated on FreeBSD 9.0,
I kept seeing the old implementation return 0 before the semaphore
was raised and got a bit nervous about the assumption that timevals
and timespecs were identical, etc.)

When doing a timed semaphore wait on a platform that uses POSIX
semaphores, use clock_gettime(CLOCK_REALTIME,...) instead of
gettimeofday() to get the current time and avoid any timval/timespec
issues.

This requires linking against librt on Linux; change the affected
Makefiles to do so.

Location:
trunk/source/lisp-kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/linuxarm/Makefile

    r15277 r15289  
    8383# all:  ../../ppccl ../../subprims.so
    8484
    85 OSLIBS = -ldl -lm -lpthread
     85OSLIBS = -ldl -lm -lpthread -lrt
    8686
    8787
  • trunk/source/lisp-kernel/linuxppc/Makefile

    r15198 r15289  
    8888# all:  ../../ppccl ../../subprims.so
    8989
    90 OSLIBS = -ldl -lm -lpthread
     90OSLIBS = -ldl -lm -lpthread -lrt
    9191
    9292
  • trunk/source/lisp-kernel/linuxppc64/Makefile

    r15198 r15289  
    7676# all:  ../../ppccl64 ../../subprims.so
    7777
    78 OSLIBS = -ldl -lm -lpthread
     78OSLIBS = -ldl -lm -lpthread -lrt
    7979
    8080
  • trunk/source/lisp-kernel/linuxx8632/Makefile

    r15198 r15289  
    7070
    7171
    72 OSLIBS = -ldl -lm -lpthread
     72OSLIBS = -ldl -lm -lpthread -lrt
    7373LINK_SCRIPT = # ./elf_x86_32.x
    7474USE_LINK_SCRIPT = # -T $(LINK_SCRIPT)
  • trunk/source/lisp-kernel/linuxx8664/Makefile

    r15198 r15289  
    7070
    7171
    72 OSLIBS = -ldl -lm -lpthread
     72OSLIBS = -ldl -lm -lpthread -lrt
    7373LINK_MAP = ./elf_x86_64.x
    7474USE_LINK_MAP = # -T ./elf_x86_64.x
  • trunk/source/lisp-kernel/thread_manager.c

    r15202 r15289  
    455455  do {
    456456#ifdef USE_MACH_SEMAPHORES
    457     mach_timespec_t q = {1,0};
    458     status = SEM_TIMEDWAIT(s,q);
     457    status = SEM_WAIT(s);
    459458#endif
    460459#ifdef USE_POSIX_SEMAPHORES
    461     struct timespec q;
    462     gettimeofday((struct timeval *)&q, NULL);
    463     q.tv_sec += 1;
    464     status = SEM_TIMEDWAIT(s,&q);
     460    status = SEM_WAIT(s);
    465461#endif
    466462#ifdef USE_WINDOWS_SEMAPHORES
    467     status = (WaitForSingleObject(s,1000L) == WAIT_TIMEOUT) ? 1 : 0;
     463    status = (WaitForSingleObject(s,INFINITE) == WAIT_OBJECT_0) ? 0 : 1;
    468464#endif
    469465  } while (status != 0);
     
    478474
    479475  struct timespec q;
    480   gettimeofday((struct timeval *)&q, NULL);
    481   q.tv_nsec *= 1000L;  /* microseconds -> nanoseconds */
     476  clock_gettime(CLOCK_REALTIME,&q);
    482477   
    483478  q.tv_nsec += nanos;
Note: See TracChangeset for help on using the changeset viewer.