[RTEMS Project] #4207: PZERO define in newlib is wrong

RTEMS trac trac at rtems.org
Wed Dec 23 19:07:30 UTC 2020


#4207: PZERO define in newlib is wrong
-----------------------------+--------------------
  Reporter:  Chris Johns     |      Owner:  (none)
      Type:  defect          |     Status:  new
  Priority:  normal          |  Milestone:  6.1
 Component:  network/libbsd  |    Version:  6
  Severity:  normal          |   Keywords:
Blocked By:                  |   Blocking:
-----------------------------+--------------------
 Our newlib support defines `PZERO` to be zero. FreeBSD defines `PZERO` to
 be `(PRI_MIN_KERN + 20)` and `PRI_MIN_KERN` is `80`.

 The `__sleep()` call uses bits allocated above the bits used to hold the
 highest priority to signal things to do. The `PDROP` (`0x200`) bit causes
 a lock to be dropped before sleeping and not reclaimed after.

 Setting `PZERO` to `0` breaks FreeBSD code in libbsd because calls that
 end up in `__sleep()` can incorrectly have the `PDROP` bit set. A grep of
 FreeBSD shows how this happens:

 {{{
    (void) nfsmsleep(&lp->nfslock_lock, mutex,
       PZERO - 1, "nfsv4gr", NULL);
 }}}
 {{{
    error = msleep(msqkptr, &msq_mtx, (PZERO - 4) | PCATCH,
      msgsnd", hz);

 }}}
 This examples shows how either side is used...
 {{{
    selwakeuppri(&tp->tun_rsel, PZERO + 1);
 }}}

--
Ticket URL: <http://devel.rtems.org/ticket/4207>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list