The system call is only called from librthreads, and librthreads doesn't
use tickets.
There is a comment in librthreads that says:
/*
* tickets don't work yet? (or seem much slower, with lots of system time)
* until then, keep the struct around to avoid excessive changes going
* back and forth.
*/
It was added on 2013-06-01.
This diff is just the kernel part.
Index: sys/kern/kern_synch.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_synch.c,v
retrieving revision 1.133
diff -u -p -r1.133 kern_synch.c
--- sys/kern/kern_synch.c 6 Jul 2016 15:53:01 -0000 1.133
+++ sys/kern/kern_synch.c 3 Sep 2016 13:45:40 -0000
@@ -59,7 +59,7 @@
#endif
int thrsleep(struct proc *, struct sys___thrsleep_args *);
-int thrsleep_unlock(void *, int);
+int thrsleep_unlock(void *);
/*
* We're only looking at 7 bits of the address; everything is
@@ -454,26 +454,15 @@ sys_sched_yield(struct proc *p, void *v,
}
int
-thrsleep_unlock(void *lock, int lockflags)
+thrsleep_unlock(void *lock)
{
static _atomic_lock_t unlocked = _ATOMIC_LOCK_UNLOCKED;
_atomic_lock_t *atomiclock = lock;
- uint32_t *ticket = lock;
- uint32_t ticketvalue;
- int error;
if (!lock)
- return (0);
+ return 0;
- if (lockflags) {
- if ((error = copyin(ticket, &ticketvalue, sizeof(ticketvalue))))
- return (error);
- ticketvalue++;
- error = copyout(&ticketvalue, ticket, sizeof(ticketvalue));
- } else {
- error = copyout(&unlocked, atomiclock, sizeof(unlocked));
- }
- return (error);
+ return copyout(&unlocked, atomiclock, sizeof(unlocked));
}
static int globalsleepaddr;
@@ -493,15 +482,13 @@ thrsleep(struct proc *p, struct sys___th
void *lock = SCARG(uap, lock);
uint64_t to_ticks = 0;
int abort, error;
- clockid_t clock_id = SCARG(uap, clock_id) & 0x7;
- int lockflags = SCARG(uap, clock_id) & 0x8;
if (ident == 0)
return (EINVAL);
if (tsp != NULL) {
struct timespec now;
- if ((error = clock_gettime(p, clock_id, &now)))
+ if ((error = clock_gettime(p, SCARG(uap, clock_id), &now)))
return (error);
#ifdef KTRACE
if (KTRPOINT(p, KTR_STRUCT))
@@ -510,7 +497,7 @@ thrsleep(struct proc *p, struct sys___th
if (timespeccmp(tsp, &now, <)) {
/* already passed: still do the unlock */
- if ((error = thrsleep_unlock(lock, lockflags)))
+ if ((error = thrsleep_unlock(lock)))
return (error);
return (EWOULDBLOCK);
}
@@ -524,9 +511,8 @@ thrsleep(struct proc *p, struct sys___th
p->p_thrslpid = ident;
- if ((error = thrsleep_unlock(lock, lockflags))) {
+ if ((error = thrsleep_unlock(lock)))
goto out;
- }
if (SCARG(uap, abort) != NULL) {
if ((error = copyin(SCARG(uap, abort), &abort,
Index: sys/sys/_time.h
===================================================================
RCS file: /cvs/src/sys/sys/_time.h,v
retrieving revision 1.7
diff -u -p -r1.7 _time.h
--- sys/sys/_time.h 16 Oct 2014 15:50:49 -0000 1.7
+++ sys/sys/_time.h 3 Sep 2016 13:45:40 -0000
@@ -39,8 +39,6 @@
#define CLOCK_UPTIME 5
#if __BSD_VISIBLE
-#define __CLOCK_USE_TICKET_LOCKS 8 /* flag for
__thrsleep() */
-
/*
* Per-process and per-thread clocks encode the PID or TID into the
* high bits, with the type in the bottom bits
--
Michal Mazurek