include "cross.cat"
let RL =
try RL
with emptyset
let RU =
try RU
with emptyset
let LF = LF | RL
let ALL-LOCKS = LKR | LKW | UL | LF | RU
flag ~
empty [M \ IW] ; loc ; [ALL-LOCKS]
as mixed-lock-accesses
let lk-rmw = ([LKR] ; po-loc ; [LKW]) \ (po ; po)
let rmw = rmw | lk-rmw
flag ~
empty LKW \ range(lk-rmw)
as unpaired-LKW
flag ~
empty LKR \ domain(lk-rmw)
as unpaired-LKR
empty ([LKW] ; po-loc ; [LKR]) \ (po-loc ; [UL] ; po-loc)
as lock-nest
flag ~
empty [FW] ; loc ; [ALL-LOCKS]
as lock-final
let R = R | LKR | LF | RU
let W = W | LKW
let Release = Release | UL
let Acquire = Acquire | LKR
let critical = ([LKW] ; po-loc ; [UL]) \ (po-loc ; [LKW | UL] ; po-loc)
flag ~
empty UL \ range(critical)
as unmatched-unlock
let UNMATCHED-LKW = LKW \ domain(critical)
empty ([UNMATCHED-LKW] ; loc ; [UNMATCHED-LKW]) \ id
as unmatched-locks
let rfi-lf = ([LKW] ; po-loc ; [LF]) \ ([LKW] ; po-loc ; [UL] ; po-loc)
let all-possible-rfe-lf =
let possible-rfe-lf r =
let pair-to-relation p = p ++
0
in map pair-to-relation ((LKW * {r}) & loc & ext)
in map possible-rfe-lf (LF \ range(rfi-lf))
with rfe-lf
from cross(all-possible-rfe-lf)
let rf-lf = rfe-lf | rfi-lf
let rfi-ru = ([UL] ; po-loc ; [RU]) \ ([UL] ; po-loc ; [LKW] ; po-loc)
let all-possible-rfe-ru =
let possible-rfe-ru r =
let pair-to-relation p = p ++
0
in map pair-to-relation (((UL | IW) * {r}) & loc & ext)
in map possible-rfe-ru RU
with rfe-ru
from cross(all-possible-rfe-ru)
let rf-ru = rfe-ru | rfi-ru
let rf = rf | rf-lf | rf-ru
let co0 = co0 | ([IW] ; loc ; [LKW]) |
(([LKW] ; loc ; [UNMATCHED-LKW]) \ [UNMATCHED-LKW])
include "cos-opt.cat"
let W = W | UL
let M = R | W
let co = (co | critical | (critical^-1 ; co))+
let coe = co & ext
let coi = co & int
let rf = rf | ([IW | UL] ; singlestep(co) ; lk-rmw^-1)
let rfe = rf & ext
let rfi = rf & int
let fr = rf^-1 ; co
let fre = fr & ext
let fri = fr & int
show co,rf,fr