/* * 'park' an LWP waiting on a user-level synchronisation object. The LWP * will remain parked until another LWP in the same process calls in and * requests that it be unparked. */ int sys____lwp_park60(struct lwp *l, const struct sys____lwp_park60_args *uap, register_t *retval) { /* { syscallarg(clockid_t) clock_id; syscallarg(int) flags; syscallarg(const struct timespec *) ts; syscallarg(lwpid_t) unpark; syscallarg(const void *) hint; syscallarg(const void *) unparkhint; } */ struct timespec ts, *tsp; int error; if (SCARG(uap, ts) == NULL) tsp = NULL; else { error = copyin(SCARG(uap, ts), &ts, sizeof(ts)); if (error != 0) return error; tsp = &ts; } if (SCARG(uap, unpark) != 0) { error = lwp_unpark(SCARG(uap, unpark), SCARG(uap, unparkhint)); if (error != 0) return error; } return lwp_park(SCARG(uap, clock_id), SCARG(uap, flags), tsp, SCARG(uap, hint)); }
int compat_60_netbsd32__lwp_park(struct lwp *l, const struct compat_60_netbsd32__lwp_park_args *uap, register_t *retval) { /* { syscallarg(const netbsd32_timespecp) ts; syscallarg(lwpid_t) unpark; syscallarg(netbsd32_voidp) hint; syscallarg(netbsd32_voidp) unparkhint; } */ struct timespec ts, *tsp; struct netbsd32_timespec ts32; int error; if (SCARG_P32(uap, ts) == NULL) tsp = NULL; else { error = copyin(SCARG_P32(uap, ts), &ts32, sizeof ts32); if (error != 0) return error; tsp = &ts; } if (SCARG(uap, unpark) != 0) { error = lwp_unpark(SCARG(uap, unpark), SCARG_P32(uap, unparkhint)); if (error != 0) return error; } return lwp_park(CLOCK_REALTIME, TIMER_ABSTIME, tsp, SCARG_P32(uap, hint)); }
int sys__lwp_unpark(struct lwp *l, const struct sys__lwp_unpark_args *uap, register_t *retval) { /* { syscallarg(lwpid_t) target; syscallarg(const void *) hint; } */ return lwp_unpark(SCARG(uap, target), SCARG(uap, hint)); }
void runtime·semawakeup(M *mp) { uint32 ret; // spin-mutex lock while(runtime·xchg(&mp->waitsemalock, 1)) runtime·osyield(); mp->waitsemacount++; // TODO(jsing) - potential deadlock, see semasleep() for details. // Confirm that LWP is parked before unparking... ret = runtime·lwp_unpark(mp->procid, &mp->waitsemacount); if(ret != 0 && ret != ESRCH) runtime·printf("thrwakeup addr=%p sem=%d ret=%d\n", &mp->waitsemacount, mp->waitsemacount, ret); // spin-mutex unlock runtime·atomicstore(&mp->waitsemalock, 0); }
int netbsd32____lwp_park60(struct lwp *l, const struct netbsd32____lwp_park60_args *uap, register_t *retval) { /* { syscallarg(const netbsd32_clockid_t) clock_id; syscallarg(int) flags; syscallarg(const netbsd32_timespec50p) ts; syscallarg(netbsd32_lwpid_t) unpark; syscallarg(netbsd32_voidp) hint; syscallarg(netbsd32_voidp) unparkhint; } */ struct timespec ts, *tsp; struct netbsd32_timespec ts32; int error; if (SCARG_P32(uap, ts) == NULL) tsp = NULL; else { error = copyin(SCARG_P32(uap, ts), &ts32, sizeof ts32); if (error != 0) return error; netbsd32_to_timespec(&ts32, &ts); tsp = &ts; } if (SCARG(uap, unpark) != 0) { error = lwp_unpark(SCARG(uap, unpark), SCARG_P32(uap, unparkhint)); if (error != 0) return error; } return lwp_park(SCARG(uap, clock_id), SCARG(uap, flags), tsp, SCARG_P32(uap, hint)); }