Date: Sun, 17 Apr 2011 15:49:48 -0400 (EDT) From: Rick Macklem <rmacklem@uoguelph.ca> To: freebsd-hackers@freebsd.org Subject: SMP question w.r.t. reading kernel variables Message-ID: <397135152.167477.1303069788579.JavaMail.root@erie.cs.uoguelph.ca>
next in thread | raw e-mail | index | archive | help
Hi, I should know the answer to this, but... When reading a global kernel variable, where its modifications are protected by a mutex, is it necessary to get the mutex lock to just read its value? For example: A if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) return (EPERM); versus B MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) { MNT_IUNLOCK(mp); return (EPERM); } MNT_IUNLOCK(mp); My hunch is that B is necessary if you need an up-to-date value for the variable (mp->mnt_kern_flag in this case). Is that correct? Thanks in advance for help with this, rick
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?397135152.167477.1303069788579.JavaMail.root>