Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch STM_domain.agree_prop_par_asym to use Atomics #368

Merged
merged 3 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes

## Next

- #368: Switch `STM_domain.agree_prop_par_asym` from using
`Semaphore.Binary` to using an `int Atomic.t` which improves
the error rate across platforms and backends

## 0.2

- #342: Add two submodules of combinators in `Util`:
Expand Down
10 changes: 5 additions & 5 deletions lib/STM_domain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ module Make (Spec: Spec) = struct
let agree_prop_par_asym (seq_pref, cmds1, cmds2) =
let sut = Spec.init_sut () in
let pref_obs = interp_sut_res sut seq_pref in
let sema = Semaphore.Binary.make false in
let wait = Atomic.make 2 in
let child_dom =
Domain.spawn (fun () ->
Semaphore.Binary.release sema;
Atomic.decr wait;
while Atomic.get wait <> 0 do Domain.cpu_relax() done;
try Ok (interp_sut_res sut cmds2) with exn -> Error exn)
in
while not (Semaphore.Binary.try_acquire sema) do
Domain.cpu_relax ()
done;
Atomic.decr wait;
while Atomic.get wait <> 0 do Domain.cpu_relax() done;
let parent_obs = try Ok (interp_sut_res sut cmds1) with exn -> Error exn in
let child_obs = Domain.join child_dom in
let () = Spec.cleanup sut in
Expand Down