-
Notifications
You must be signed in to change notification settings - Fork 31
Add simple examples for MS queue #59
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
Open
nikochiko
wants to merge
37
commits into
ocaml-multicore:main
Choose a base branch
from
nikochiko:examples
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 f07b56b
Add a wider range of examples
nikochiko e148857
Fix space leaks of Michael-Scott queue
polytypic cf89702
Run on 5.0.0 rather than 5.0.0~alpha0
polytypic 52f961e
Merge pull request #64 from ocaml-multicore/ms-queue-fix-and-tweaks
lyrm bd9b0b5
Fix the lock-free update of Michael-Scott style queue tail
polytypic 31d51fd
set QCHECK_MSG_INTERVAL to avoid clutter in CI logs
jmid 71c075c
Merge pull request #69 from jmid/set-qcheck-msg-interval
lyrm 7c5bd51
mark alcotest as a test dependency
Khady 9abc664
Merge pull request #70 from Khady/patch-1
Sudha247 42bd001
Better prints, concurrency with do_work function
nikochiko 2713111
Merge pull request #66 from ocaml-multicore/fix-ms-queue-tail-update
lyrm 970cd86
Add Random.self_init and run dune fmt
nikochiko ef6414f
Adopt OCaml Code of Conduct
Sudha247 a1e1613
Merge pull request #71 from ocaml-multicore/code-of-conduct
lyrm 087e287
Removing overlaps between github action and ocaml ci. Removing not wo…
lyrm 03d7fe7
Merge pull request #72 from lyrm/CI_changes
lyrm a17d1a3
Add multicoretest tests for current data structures.
lyrm 7195de5
Merge pull request #61 from lyrm/stm-test
lyrm d87aca1
Require qcheck-stm.0.2 and remove pin
jmid 6380a6d
Merge pull request #75 from jmid/remove-qcheck-stm-pin
lyrm a782481
- Renaming lockfree to Saturn
lyrm 1e7c41f
Merge pull request #67 from lyrm/dsds
Sudha247 67164e5
Refactor to separate lockfree from non-lockfree data structures.
lyrm fee6012
Merge pull request #76 from lyrm/refactoring
Sudha247 b485b74
Prepare release
Sudha247 8b9a688
Merge pull request #77 from ocaml-multicore/prepare-release-0.4
Sudha247 2aa31c2
Remove .merlin and .ocp-indent files.
lyrm b66baa9
Merge pull request #86 from lyrm/cleanup_dot_files
lyrm 0401757
Correct issue caused by saturn_lockfree module beeing named Lockfree.
lyrm 4fe464d
Add a barrier module in tests to replace the use of semaphores.
lyrm 46e1662
Format.
lyrm 682fbcf
Merge pull request #85 from lyrm/saturn_lockfree
lyrm a519b4b
Improve documentation and changes barrier implementation a bit for op…
lyrm 83253a5
Merge pull request #88 from lyrm/barrier_for_tests
lyrm e25194f
Merge commit 'refs/pull/59/head' of https://github.com/ocaml-multicor…
Sudha247 057c02b
Update examples to reflect lockfree -> saturn
Sudha247 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(executables | ||
(names michael_scott_queue) | ||
(libraries lockfree)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () = | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this looks much better yes. |
||
|
||
let _ = main () |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.