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

Add simple examples for MS queue #59

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
082fc44
Add a simple example of Michael_scott_queue
nikochiko Mar 1, 2023
f07b56b
Add a wider range of examples
nikochiko Mar 1, 2023
e148857
Fix space leaks of Michael-Scott queue
polytypic Mar 10, 2023
cf89702
Run on 5.0.0 rather than 5.0.0~alpha0
polytypic Mar 16, 2023
52f961e
Merge pull request #64 from ocaml-multicore/ms-queue-fix-and-tweaks
lyrm Mar 16, 2023
bd9b0b5
Fix the lock-free update of Michael-Scott style queue tail
polytypic Mar 20, 2023
31d51fd
set QCHECK_MSG_INTERVAL to avoid clutter in CI logs
jmid Mar 23, 2023
71c075c
Merge pull request #69 from jmid/set-qcheck-msg-interval
lyrm Mar 23, 2023
7c5bd51
mark alcotest as a test dependency
Khady Apr 3, 2023
9abc664
Merge pull request #70 from Khady/patch-1
Sudha247 Apr 3, 2023
42bd001
Better prints, concurrency with do_work function
nikochiko Apr 8, 2023
2713111
Merge pull request #66 from ocaml-multicore/fix-ms-queue-tail-update
lyrm May 9, 2023
970cd86
Add Random.self_init and run dune fmt
nikochiko May 10, 2023
ef6414f
Adopt OCaml Code of Conduct
Sudha247 May 11, 2023
a1e1613
Merge pull request #71 from ocaml-multicore/code-of-conduct
lyrm May 16, 2023
087e287
Removing overlaps between github action and ocaml ci. Removing not wo…
lyrm May 11, 2023
03d7fe7
Merge pull request #72 from lyrm/CI_changes
lyrm May 22, 2023
a17d1a3
Add multicoretest tests for current data structures.
lyrm Jan 12, 2023
7195de5
Merge pull request #61 from lyrm/stm-test
lyrm May 23, 2023
d87aca1
Require qcheck-stm.0.2 and remove pin
jmid Jun 2, 2023
6380a6d
Merge pull request #75 from jmid/remove-qcheck-stm-pin
lyrm Jun 7, 2023
a782481
- Renaming lockfree to Saturn
lyrm Feb 23, 2023
1e7c41f
Merge pull request #67 from lyrm/dsds
Sudha247 Jul 6, 2023
67164e5
Refactor to separate lockfree from non-lockfree data structures.
lyrm Jul 4, 2023
fee6012
Merge pull request #76 from lyrm/refactoring
Sudha247 Jul 10, 2023
b485b74
Prepare release
Sudha247 Jul 10, 2023
8b9a688
Merge pull request #77 from ocaml-multicore/prepare-release-0.4
Sudha247 Jul 10, 2023
2aa31c2
Remove .merlin and .ocp-indent files.
lyrm Jul 26, 2023
b66baa9
Merge pull request #86 from lyrm/cleanup_dot_files
lyrm Jul 26, 2023
0401757
Correct issue caused by saturn_lockfree module beeing named Lockfree.
lyrm Jul 26, 2023
4fe464d
Add a barrier module in tests to replace the use of semaphores.
lyrm Jul 5, 2023
46e1662
Format.
lyrm Jul 31, 2023
682fbcf
Merge pull request #85 from lyrm/saturn_lockfree
lyrm Jul 31, 2023
a519b4b
Improve documentation and changes barrier implementation a bit for op…
lyrm Jul 31, 2023
83253a5
Merge pull request #88 from lyrm/barrier_for_tests
lyrm Aug 1, 2023
e25194f
Merge commit 'refs/pull/59/head' of https://github.com/ocaml-multicor…
Sudha247 Sep 13, 2023
057c02b
Update examples to reflect lockfree -> saturn
Sudha247 Sep 13, 2023
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
3 changes: 3 additions & 0 deletions examples/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(executables
(names michael_scott_queue)
(libraries lockfree))
20 changes: 20 additions & 0 deletions examples/michael_scott_queue.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
open Lockfree.Michael_scott_queue

let push_work_pop queue item =
push queue item;
for _ = 1 to 100_000_000 do
(* do other work *)
ignore ()
done;
match pop queue with
| Some v -> Printf.printf "pushed %d and popped %d\n" item v
| None -> failwith "pop failed: empty list"

let main () =
nikochiko marked this conversation as resolved.
Show resolved Hide resolved
let ms_q = create () in
let d1 = Domain.spawn(fun _ -> push_work_pop ms_q 1) in
let d2 = Domain.spawn(fun _ -> push_work_pop ms_q 2) in
let d3 = Domain.spawn(fun _ -> push_work_pop ms_q 3) in
Domain.join d1; Domain.join d2; Domain.join d3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, we can use Arrays or Lists to make this easier to manage --

let domains = Array.init 4 (fun _ -> Domain.spawn(...)) in
...
Array.iter Domain.join domains

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks much better yes.


let _ = main ()