On Tue, May 5, 2015 at 9:35 AM, Mike Belopuhov <[email protected]> wrote:
...
> Here's a diff to remedy this.  This is the same chunk as in the
> tsleep, except it uses semantics of msleep.  IPL dance is there
> to negate the IPL changing effect of mtx_enter/mtx_leave so that
> splx(safepri) operation is actually changing IPL level from HIGH
> to "safepri" and then back to the mutex IPL level.
...
> +               spl = MUTEX_OLDIPL(mtx);
> +               MUTEX_OLDIPL(mtx) = splhigh();
> +               mtx_leave(mtx);
> +
> +               splx(safepri);

Hmm, since mtx_leave() effectively ends with
"splx(MUTEX_OLDIPL(mtx));", can't we just say:

              spl = MUTEX_OLDIPL(mtx);
              MUTEX_OLDIPL(mtx) = safepri;
              mtx_leave(mtx);

(The tsleep() version needs splhigh() because that's the only safe way
to get the current spl level so that it can be restored before
returning.  Here in msleep() the mutex's MUTEX_OLDIPL() already has
the value we need.)


Philip Guenther

Reply via email to