Sunday, March 22, 2009

Ch8, Ex11

Only definition of method Trans(inside class TMClass) needs to be modified. I've changed ExcT to check whether T already has a lock on the cell in question before doing getlock.
meth Trans(P ?R TS)
Halt={NewName}
T=trans(stamp:TS save:{NewDictionary} body:P
state:{NewCell running} result:R)
proc {ExcT C X Y}
if {Not {Dictionary.member T.save C.name}}
then S1 S2 in
{@tm getlock(T C S1)}
if S1==halt then raise Halt end end
{@tm savestate(T C S2)} {Wait S2}
end
{Exchange C.state X Y}
end
proc {AccT C ?X}
{ExcT C X X}
end
proc {AssT C X}
{ExcT C _ X}
end
proc {AboT} {@tm abort(T)} R=abort raise Halt end end
in
thread try Res={T.body t(access:AccT assign:AssT
exchange:ExcT abort:AboT)}
in {@tm commit(T)} R=commit(Res)
catch E then
if E\=Halt then {@tm abort(T)} R=abort(E) end
end end
end

No comments:

Post a Comment