Why mtx_sleep returning EWOUNDBLOCK?
- Reply: John Baldwin : "Re: Why mtx_sleep returning EWOUNDBLOCK?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 13 Mar 2022 20:02:05 UTC
Hi all, Summary: I am running mtx_sleep() but getting an EWOUNDBLOCK response code and do not understand why. I am looking at port code from the OpenBSD side to FreeBSD. I am assuming that tsleep_nsec()'s equivalent on FreeBSD is mtx_sleep(). To that end, I am running mtx_sleep as this: mtx_lock(&(sc)->sc_mtx); error = mtx_sleep(sc, &sc->sc_mtx, 0 , "athnfw", hz); mtx_unlock(&(sc)->sc_mtx); However, the error code returns a EWOUNDBLOCK. I would expect this to be 0. From reading the man page for sleep(9), this means "A non-zero timeout was specified and the timeout". But if I slept for 1 hz, isn't that exactly what I want and thus it should return 0 (no error)? The OpenBSD line in question is: error = tsleep_nsec(&usc->wait_msg_id, 0, "athnfw", SEC_TO_NSEC(1)); Perhaps there is something I am not understanding here? Please advise. Thanks! Farhan