RL02 version of UNIX6?
Warner Losh
imp at bsdimp.com
Thu Feb 2 13:15:34 CST 2017
On Thu, Feb 2, 2017 at 11:50 AM, Paul Koning <paulkoning at comcast.net> wrote:
>
>> On Feb 2, 2017, at 1:41 PM, Noel Chiappa <jnc at mercury.lcs.mit.edu> wrote:
>>
>>> From: Phil Blundell
>>
>>> I suspect it would probably not be all that hard to write some
>>> sort of preprocessor to convert such code
>>
>> Really? Check out:
>>
>> http://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/sys/ken/pipe.c
>>
>> (Needless to say, none of the 'int *' things are actually pointers to
>> integers!)
>>
>> In particular, what will lines like this:
>>
>> sleep(ip+2, PPIPE);
>>
>> do, depending on what 'ip' is declared as?
>
> If "ip" is an int *, it would pass the address in ip plus 2 * 2. If ip is actually the address of some struct, then hopefully that address offset by 4 is a meaningful address. I'm guessing that the 2 in there represents sizeof(foo)/sizeof(int). Right?
In this case it doesn't matter, so long as it is consistent. Some math
will happen and produce some number. The pointer is never
dereferenced.
sleep takes a sleep channel to sleep on. This channel is a unique
cookie that's implemented as the address of some struct (or some
offset into it in this case). Elsewhere in the code there's a
wakeup(ip+2) which will wakeup the sleeper. So long as ip+2 is the
same both places, we're good. Well, and so long as nothing else
accidentally evaluates to this same value.
This scheme is still used in at least modern BSDs, though it has grown
a bazillion variants.
Warner
More information about the cctalk
mailing list