Subject: simplelocks in struct proc
To: None <tech-smp@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-smp
Date: 11/03/2003 21:24:13
struct proc currently has two simplelocks, p_lwplock and p_raslock.
However there are a few other fields that need locking, in particular
optimising find_stopped_child() requires a count of the number
of children in state SSTOP and SZOMB as well as the ability to
re-order the p_sibling list (to get the stopped ones at the front).

Rather than add yet another simplelock, it would actually make more
sense to have a single p_lock for quick(ish) operations on the
proc structure.

It is also worth adding a short comment to indicate which lock applies
to each field, eg:
        int             p_nrlwps;       /* L: Number of running LWPs */

I don't think any of our systems are likely to have contention
on two locks on the proc structure for a long time!
The chance of contention is roughly:
	'fraction of time with lock held' ** 'number of cpus'
(ignoring any program logic)

	David

-- 
David Laight: david@l8s.co.uk