From owner-freebsd-arch Mon Aug 26 17:57:54 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 68A2537B400 for ; Mon, 26 Aug 2002 17:57:51 -0700 (PDT) Received: from gull.mail.pas.earthlink.net (gull.mail.pas.earthlink.net [207.217.120.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0FB5343E3B for ; Mon, 26 Aug 2002 17:57:51 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0018.cvx21-bradley.dialup.earthlink.net ([209.179.192.18] helo=mindspring.com) by gull.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17jUfy-0003T9-00; Mon, 26 Aug 2002 17:57:47 -0700 Message-ID: <3D6ACE3A.3D17935B@mindspring.com> Date: Mon, 26 Aug 2002 17:56:26 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Archie Cobbs Cc: Julian Elischer , arch@FreeBSD.ORG Subject: Re: Process/thread states. References: <200208270040.g7R0ehu36981@arch20m.dellroad.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Archie Cobbs wrote: > Julian Elischer writes: > > #define TD_ST_SUSPQ 0x01 /* uses runq field */ > > #define TD_ST_RUNQ 0x02 /* uses runq field */ > > #define TD_ST_RUNNING 0x03 /* uses no (virtual) field */ > > #define TD_ST_MTX 0x04 /* uses mtx field */ > > #define TD_ST_RQ_MASK 0x07 /* mask of non sleep states */ > > #define TD_ST_SLPQ 0x08 /* uses slpq field */ > > enum thread_state { [ ... ] > I like your idea.. it makes things clearer because they are more > explicit. Whenever "implicit developer knowledge" is required to > do something correctly that's more opportunity for bugs. > > If you comment those flags in the header file(s) really well, > that's even better. Especially all of the cases where there is > any duplicate or inter-dependent state, which can be evil. > > E.g., if TDS_SLP always implies wchan != NULL, then that should be > commented somewhere. > > That is, any 'trickiness' in an object's state like depedence between > fields or special invariants should either be very clearly documented > or else hidden behind an object-like functional interface (like Alfred > suggested). The part that causes me a little bit of pain is that the compares will all end up having to be: if ( (x & VALUE) == VALUE) or if ( (x & VALUE) != VALUE) To get them out of the bitmaps. This makes the compares look a little cleaner (I guess) but it doubles the number of cycles for each one, when the common case is/should be that only one bit is significant (e.g. the use of McCarthy operators like && and || save work on failure/success, respectively). I guess there is no way to refactor the code so that the depndencies don't have to be tested? -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message