This commit is contained in:
Justin Ethier 2019-06-24 19:02:30 -04:00
parent 5cb5540d2e
commit a14d3efe80

View file

@ -212,7 +212,6 @@
}
return_thread_runnable(data, boolean_t); ")
;; TODO: WIP, this is broken right now!
(define-c %mutex-timedlock!
"(void *data, int argc, closure _, object k, object obj, object timeout)"
" mutex m = (mutex) obj;
@ -221,17 +220,14 @@
Cyc_check_mutex(data, obj);
Cyc_check_num(data, timeout);
value = unbox_number(timeout);
printf(\"tv_sec = %ld\\n\", tim.tv_sec);
printf(\"tv_nsec = %ld\\n\", tim.tv_nsec);
set_thread_blocked(data, k);
// clock_gettime(CLOCK_REALTIME, &tim);
// clock_gettime(CLOCK_MONOTONIC, &tim);
gettimeofday(&tim, NULL);
clock_gettime(CLOCK_REALTIME, &tim);
//clock_gettime(CLOCK_MONOTONIC, &tim);
//gettimeofday(&tim, NULL);
tim.tv_sec += (long)value;
tim.tv_nsec += (long)((value - tim.tv_sec) * 1000 * NANOSECONDS_PER_MILLISECOND);
tim.tv_nsec += (long)((value - ((long)value)) * 1000 * NANOSECONDS_PER_MILLISECOND);
int result = pthread_mutex_timedlock(&(m->lock), &tim);
if (result != 0) {
printf(\"result = %d\\n\", result);
return_thread_runnable(data, boolean_f);
}
return_thread_runnable(data, boolean_t); ")