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
CODETOOLS-7903060: jcstress: ProducerConsumer problem sample #104
CODETOOLS-7903060: jcstress: ProducerConsumer problem sample #104
Conversation
👋 Welcome back mmirwaldt! A progress list of the required criteria for merging this PR into |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a general comment about the style. The is sample code, it has to be fluent. Meaning, the reader has to be able to read the entire file as prose, being told what is shown, what are the expected results and why, what are the actual results. Look at how Basic*
samples are written.
This, unfortunately, does not pass the bar for a good sample yet.
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
…cerConsumerProblem
I must confess I am not sure how much description is enough for you and what is too much. It appeared to me in the last PRs you sometimes prefer rather a minimum than a maximum of explainations to avoid useless comments about obvious things. Maybe I am wrong. Btw: I always try to be short on my answers for you because I believe you don't like to read long texts from me. |
Maybe it's a good idea to review again the sample ClassicProblem_01_DiningPhilosophers after this PR. |
Please change the PR title to "CODETOOLS-7903060: jcstress: ProducerConsumer problem sample" to get it hooked properly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just merged #105 that brings consistency to all current samples. Please pull from master, move your sample in the new location and try to match the style :)
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
Done. |
@mmirwaldt this pull request can not be integrated into git checkout ClassicProblem_02_ProducerConsumerProblem-3
git fetch https://git.openjdk.java.net/jcstress master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there.
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
.../openjdk/jcstress/samples/concurrency/classic/ClassicProblem_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not there. Please match the style of the previous samples exactly.
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Show resolved
Hide resolved
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Show resolved
Hide resolved
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Show resolved
Hide resolved
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Show resolved
Hide resolved
...n/java/org/openjdk/jcstress/samples/problems/classic/Classic_02_ProducerConsumerProblem.java
Outdated
Show resolved
Hide resolved
Which results?
for other tests than FlawedTwoProducersOneConsumer.
How can I enable this output for all other tests? I have added the separators but I miss the results. |
I am confused. Some integration tests don't run anymore. I cannot imagine any last change causing that. |
Say |
Ah thank you, @shipilev! I have added the results for all the other tests. Please feel free to ask for further changes. |
Any update, @shipilev? |
void producer() { | ||
produce(); | ||
produce(); | ||
} | ||
|
||
@Actor | ||
void consumer() { | ||
consume(); | ||
consume(); | ||
} | ||
|
||
@Arbiter | ||
public void fake(Z_Result r) { | ||
r.r1 = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmirwaldt , It does not seem to be good to have "all outcomes are acceptable".
Have you considered producing messages with different values so you can tell which one was consumed?
For instance: r1=produce(1); r2=produce(2);
and then r3=consume(); r4=consume();
.
Then you could verify:
- "1, 2, 1, 2" is acceptable
- all others states are forbidden.
The same would apply to the other samples.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, this is acceptable.
|
@mmirwaldt This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been no new commits pushed to the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@shipilev) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@mmirwaldt |
/sponsor |
Going to push as commit 0f28604. |
@shipilev @mmirwaldt Pushed as commit 0f28604. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This sample implements some solutions from the wikipedia article about the producer-consumer-problem on https://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem .
It contains these solutions:
I have decided not to implement the last solution with finite-range single writer registers in the wikipedia article. It looked far too complicated to me.
This is my third try to avoid squash commits.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jcstress pull/104/head:pull/104
$ git checkout pull/104
Update a local copy of the PR:
$ git checkout pull/104
$ git pull https://git.openjdk.java.net/jcstress pull/104/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 104
View PR using the GUI difftool:
$ git pr show -t 104
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jcstress/pull/104.diff