RFR: 8323807: Async UL: Add a stalling mode to async UL
Johan Sjölen
jsjolen at openjdk.org
Tue Dec 17 11:36:39 UTC 2024
On Tue, 17 Dec 2024 10:52:27 GMT, Afshin Zafari <azafari at openjdk.org> wrote:
> Nice work, but I did not understand the role of stalled message in this producer-consumer pattern. Why this pseudo-code is not suitable here?
>
> ```
> void produce() {
> OuterLock olock;
> InnerLock ilock;
> while (attempt_produce(shared_buffer)){
> ilock.wait();
> }
> }
>
> void consume() {
> InnerLock ilock;
> consume(shared_buffer); // and/or flush the whole buffer
> ilock.notify();
> }
> ```
>
> Since when consumer notifies producers via the `ilock`, there is free space in the buffer (since it is flushed) and the producer(s) can try again to put their messages.
Good question, the reason is slightly obscure. I wanted to guarantee that larger-than-buffer messages can be logged. It's highly unlikely that such messages occur, but I thought it best to deal with that situation now instead of regretting it with an infinitely stalled thread at a user later.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22770#issuecomment-2548219917
More information about the hotspot-runtime-dev
mailing list