tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Error in comment in sys/mutex.h



On Thu, 12 Jan 2017, Taylor R Campbell wrote:

  Date: Thu, 12 Jan 2017 09:19:09 +0800 (PHT)
  From: Paul Goyette <paul%whooppee.com@localhost>

  Currently, there's a long comment in src/sys/sys/mutex.h which reads in
  part:

  ...
    *
    *      MUTEX_OWNER(owner)
    *              Returns the owner of the adaptive mutex (LWP address).
    *
    *      MUTEX_OWNED(owner)
    *              Returns non-zero if an adaptive mutex is currently
    *              held by an LWP.
    *
  ...

  It seems to me that the arguments of these two macros should be (mtx)
  rather than (owner).

  Am I misunderstanding something?  Or should I fix it?   :)

Actually, `owner' is correct.  Specifically, these pick apart the bits
of the struct kmutex::mtx_owner field.  Some of the bits make up a
pointer, either struct lwp * or struct cpu_info *, but in an aligned
pointer some bits are always zero, and those bits are used for other
purposes.  See, e.g., the definition of mutex_owned in kern_mutex.c.

Ah, OK, got it!  Thanks!


+------------------+--------------------------+------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+


Home | Main Index | Thread Index | Old Index