futex_wait(): support for FUTEX_CLOCK_REALTIME
This commit is contained in:
@ -96,6 +96,7 @@ static char *syscall_name[] MCKERNEL_UNUSED = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static ihk_spinlock_t tod_data_lock = SPIN_LOCK_UNLOCKED;
|
static ihk_spinlock_t tod_data_lock = SPIN_LOCK_UNLOCKED;
|
||||||
|
static void calculate_time_from_tsc(struct timespec *ts);
|
||||||
|
|
||||||
void check_signal(unsigned long, void *, int);
|
void check_signal(unsigned long, void *, int);
|
||||||
void do_signal(long rc, void *regs, struct thread *thread, struct sig_pending *pending, int num);
|
void do_signal(long rc, void *regs, struct thread *thread, struct sig_pending *pending, int num);
|
||||||
@ -3419,6 +3420,7 @@ SYSCALL_DECLARE(futex)
|
|||||||
{
|
{
|
||||||
uint64_t timeout = 0; // No timeout
|
uint64_t timeout = 0; // No timeout
|
||||||
uint32_t val2 = 0;
|
uint32_t val2 = 0;
|
||||||
|
int futex_clock_realtime = 0;
|
||||||
|
|
||||||
uint32_t *uaddr = (uint32_t *)ihk_mc_syscall_arg0(ctx);
|
uint32_t *uaddr = (uint32_t *)ihk_mc_syscall_arg0(ctx);
|
||||||
int op = (int)ihk_mc_syscall_arg1(ctx);
|
int op = (int)ihk_mc_syscall_arg1(ctx);
|
||||||
@ -3429,6 +3431,9 @@ SYSCALL_DECLARE(futex)
|
|||||||
|
|
||||||
/* Mask off the FUTEX_PRIVATE_FLAG,
|
/* Mask off the FUTEX_PRIVATE_FLAG,
|
||||||
* assume all futexes are address space private */
|
* assume all futexes are address space private */
|
||||||
|
if (op & FUTEX_CLOCK_REALTIME) {
|
||||||
|
futex_clock_realtime = 1;
|
||||||
|
}
|
||||||
op = (op & FUTEX_CMD_MASK);
|
op = (op & FUTEX_CMD_MASK);
|
||||||
|
|
||||||
dkprintf("futex op=[%x, %s],uaddr=%lx, val=%x, utime=%lx, uaddr2=%lx, val3=%x, []=%x\n",
|
dkprintf("futex op=[%x, %s],uaddr=%lx, val=%x, utime=%lx, uaddr2=%lx, val3=%x, []=%x\n",
|
||||||
@ -3478,9 +3483,20 @@ SYSCALL_DECLARE(futex)
|
|||||||
}
|
}
|
||||||
/* Compute timeout based on TSC/nanosec ratio */
|
/* Compute timeout based on TSC/nanosec ratio */
|
||||||
else {
|
else {
|
||||||
unsigned long nsec_timeout = ((long)utime->tv_sec * 1000000000ULL)
|
unsigned long nsec_timeout;
|
||||||
+ utime->tv_nsec;
|
|
||||||
|
|
||||||
|
if (!(futex_clock_realtime)) {
|
||||||
|
nsec_timeout = ((long)utime->tv_sec * NS_PER_SEC)
|
||||||
|
+ utime->tv_nsec;
|
||||||
|
}
|
||||||
|
else { /* FUTEX_CLOCK_REALTIME denotes absolute time */
|
||||||
|
struct timespec ats;
|
||||||
|
calculate_time_from_tsc(&ats);
|
||||||
|
|
||||||
|
nsec_timeout = (utime->tv_sec * NS_PER_SEC + utime->tv_nsec) -
|
||||||
|
(ats.tv_sec * NS_PER_SEC + ats.tv_nsec);
|
||||||
|
}
|
||||||
|
|
||||||
timeout = nsec_timeout * 1000 / ihk_mc_get_ns_per_tsc();
|
timeout = nsec_timeout * 1000 / ihk_mc_get_ns_per_tsc();
|
||||||
dkprintf("futex timeout: %lu\n", timeout);
|
dkprintf("futex timeout: %lu\n", timeout);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
#define dkprintf(...) do { if (0) kprintf(__VA_ARGS__); } while (0)
|
#define dkprintf(...) do { if (0) kprintf(__VA_ARGS__); } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LOOP_TIMEOUT 10
|
#define LOOP_TIMEOUT 500
|
||||||
|
|
||||||
struct list_head timers;
|
struct list_head timers;
|
||||||
ihk_spinlock_t timers_lock;
|
ihk_spinlock_t timers_lock;
|
||||||
|
|||||||
Reference in New Issue
Block a user