DIRECTORY Process USING [GetCurrent], ProcessProps USING [], List USING [AList]; ProcessPropsImpl: CEDAR MONITOR IMPORTS Process EXPORTS ProcessProps = BEGIN AddPropList: PUBLIC PROC [propList: List.AList, inner: PROC] = TRUSTED { entry: ProcessEntry = GetProcessEntry[]; old: List.AList = entry.current; IF old # NIL THEN { tail: List.AList _ NIL; FOR each: List.AList _ propList, each.rest WHILE each # NIL DO new: List.AList = LIST[each.first]; IF tail = NIL THEN propList _ new ELSE tail.rest _ new; tail _ new; ENDLOOP; IF tail = NIL THEN propList _ old ELSE tail.rest _ old; }; entry.current _ propList; inner[! UNWIND => entry.current _ old]; entry.current _ old; }; PushPropList: PUBLIC PROC [propList: List.AList, inner: PROC] = { entry: ProcessEntry = GetProcessEntry[]; old: List.AList = entry.current; entry.current _ propList; inner[! UNWIND => entry.current _ old]; entry.current _ old; }; GetPropList: PUBLIC PROC RETURNS [propList: List.AList _ NIL] = TRUSTED { entry: ProcessEntry = GetProcessEntry[]; propList _ entry.current; }; GetSpecificPropList: PUBLIC PROC [process: PROCESS] RETURNS [propList: List.AList _ NIL] = TRUSTED { entry: ProcessEntry = GetProcessEntry[process]; IF entry # NIL THEN propList _ entry.current; }; GetNextPropList: PUBLIC ENTRY PROC [process: PROCESS _ NIL] RETURNS [next: PROCESS _ NIL, propList: List.AList _ NIL] = { ENABLE UNWIND => NULL; DO best: ProcessEntry _ NIL; FOR i: NAT IN [0..16) DO FOR each: ProcessEntry _ processVector[i], each.next UNTIL each = NIL DO eachProcess: CARDINAL = LOOPHOLE[each.process]; IF each.current = NIL THEN LOOP; IF eachProcess <= LOOPHOLE[process, CARDINAL] THEN LOOP; IF best = NIL OR eachProcess < LOOPHOLE[best.process, CARDINAL] THEN best _ each; ENDLOOP; ENDLOOP; IF best = NIL THEN EXIT; propList _ best.current; IF propList = NIL THEN {races _ races + 1; LOOP}; -- rats! a race occurred next _ best.process; EXIT; ENDLOOP; }; ProcessBits: TYPE = MACHINE DEPENDENT RECORD [ lead: [0..1024), hash: [0..16), spare: [0..4) ]; processVector: ProcessVector _ NEW[ProcessVectorRep _ ALL[NIL]]; entries: NAT _ 0; races: INT _ 0; -- I am curious, Jello ProcessVector: TYPE = REF ProcessVectorRep; ProcessVectorRep: TYPE = ARRAY [0..16) OF ProcessEntry; ProcessEntry: TYPE = REF ProcessEntryRep; ProcessEntryRep: TYPE = RECORD [ next: ProcessEntry _ NIL, process: PROCESS _ NIL, current: List.AList _ NIL ]; GetProcessEntry: PROC [process: PROCESS _ NIL] RETURNS [entry: ProcessEntry _ NIL] = TRUSTED { bits: ProcessBits = LOOPHOLE[process]; findEntry: ENTRY PROC = TRUSTED { ENABLE UNWIND => NULL; FOR each: ProcessEntry _ processVector[bits.hash], each.next UNTIL each = NIL DO IF each.process = process THEN {entry _ each; RETURN}; ENDLOOP; }; makeEntry: ENTRY PROC = TRUSTED { ENABLE UNWIND => NULL; first: ProcessEntry = processVector[bits.hash]; FOR each: ProcessEntry _ first, each.next UNTIL each = NIL DO IF each.process = process THEN {entry _ each; RETURN}; ENDLOOP; entry.next _ first; entry.process _ process; processVector[bits.hash] _ entry; entries _ entries + 1; }; IF process = NIL THEN process _ LOOPHOLE[Process.GetCurrent[]]; findEntry[]; IF entry # NIL THEN RETURN; entry _ NEW[ProcessEntryRep _ []]; makeEntry[]; }; END. ”ProcessPropsImpl.mesa Russ Atkinson, April 14, 1983 1:48 pm ... adds the given properties to the current process for the duration of the call of inner. The old property list for the process will not be altered, but will be found at the end of the propety list during the call to inner. The old property list will be restored after the call has completed. The new propList will be copied if an old property list exists. ... sets the property list for the current process for the duration of the call of inner. The old property list will be restored after the call has completed. The new propList will not be copied. Most applications should use AddPropList to properly inherit properties. ... returns the current property list for the current process. Although there is no prohibition from altering the returned list, users are encouraged to follow the style of adding new properties, rather than changing old associations. The following two operations are safe, but operations on PROCESS values are, in general, not safe, since processes are reused. These operations should be regarded as instantaneous samples, where the results are likely to change without notice. However, statistics-style applications and may find these operations useful despite these caveats. It is also OK to ask whether a process still has some property if that property will not be reused. ... returns the current property list for the specified process ... returns the next process with a non-NIL propList. Use GetNextPropList[NIL] to start the iteration. [NIL, NIL] will be returned if no more processes exist. The processes are produced in increasing order. There is a very small probability of a race with AddPropList and PushPropList, but it must result in a bounded number of retries. ... returns a non-NIL ProcessEntry for the specified process. We are only locked out for short bursts of time, and NOT while allocating! .. sets entry to be an existing ProcessEntry object (if any), for the process. .. sets entry to be an existing ProcessEntry object (if any), for the process. If there is no such entry, then the fields of entry are filled in, and the entry is placed in the hash table. Ê•˜Jšœ™Jšœ%™%J˜šÏk ˜ Jšœœ˜Jšœ œ˜Jšœœ ˜J˜—šœœ˜Jšœ˜Jšœ ˜Jšœ˜J˜—šÏn œ œœœ˜HJšœé™éJšœ(˜(Jšœ ˜ šœœœ˜Jšœœ˜šœ(œœ˜>Jšœœ ˜#Jšœœœœ˜7Jšœ ˜ Jšœ˜—Jšœœœœ˜7J˜—Jšœ˜Jšœœ˜'J˜J˜J˜—šž œœœœ˜AJšœ™Jšœ(˜(Jšœ ˜ Jšœ˜Jšœœ˜'J˜J˜J™—š ž œœœœœœ˜IJšœë™ëJšœ(˜(Jšœ˜J˜J˜—Jšœ9œý™½J™šžœœ˜ Jš œ œœœœ˜CJšœ?™?Jšœ/˜/Jšœ œœ˜-J˜J˜—šžœœœ˜"Jš œ œœœœœœ˜VJšœÔ™ÔJšœœœ˜š˜Jšœœ˜šœœœ ˜šœ2œœ˜HJšœ œœ˜/Jšœœœœ˜ Jš œœ œœœ˜8š œœœœœ˜?Jšœ ˜—Jšœ˜—Jšœ˜—Jšœœœœ˜Jšœ˜Jš œ œœœÏc˜KJšœ˜Jšœ˜Jšœ˜—J˜J˜—š œ œœ œœ˜.J˜-J˜J˜—Jšœœœœ˜@Jšœ œ˜šœœŸ˜'J˜—Jšœœœ˜+šœœœ œ˜7J˜—Jšœœœ˜)šœœœ˜ Jšœœ˜Jšœ œœ˜Jšœ˜J˜J˜—šžœ˜Jš œ œœœœœ˜HJšœœ_œ™‰Jšœœ ˜&šœ œœœ˜!JšœN™NJšœœœ˜šœ:œœ˜PJšœœœ˜6Jšœ˜—J˜—šœ œœœ˜!Jšœ½™½Jšœœœ˜Jšœ/˜/šœ'œœ˜=Jšœœœ˜6Jšœ˜—J˜J˜Jšœ!˜!Jšœ˜J˜—Jšœ œœ œ˜?J˜ Jšœ œœœ˜Jšœœ˜"J˜ J˜J˜—Jšœ˜J˜—…— ¬Õ