It needs one other fix, and that is to have a check of the queue and poll high, 
in case the queue has elements when the method is entered.

But if you implement the queue using a buffered channel it is trivial to change 
the step #1 to handle this (the low and queue channels are mimic the high and 
low channel).

> On Apr 29, 2021, at 8:53 AM, Øyvind Teig <oyvind.t...@teigfam.net> wrote:
> 
> 
> They could still both have become ready (not in the same "cycle") between the 
> two selects. Even if that probability is low, it would need knowledge like 
> yours to show that this may in fact be zero. There could be a descheduling in 
> between, one of those in my opinion, not relevant arguments.
> torsdag 29. april 2021 kl. 15:47:42 UTC+2 skrev Jan Mercl:
> On Thu, Apr 29, 2021 at 3:23 PM Øyvind Teig <oyvin...@teigfam.net 
> <applewebdata://C00F6087-01B7-49F8-83EB-E490666B62C9>> wrote: 
> 
> > 4c is not "correct" as I want it. In the pri select case, if more than one 
> > is ready, then they shall not be randomly chosen. Never. They should be 
> > selected according to priority. 
> 
> That's not what 4c says. Instead of "more than one ready" it says 
> "both high and low _get ready at the same time_". 
> 
> Note that in the first approximation the probability of 4c happening 
> is approaching zero. If we consider time "ticks" in discrete quanta, 
> the probability is proportional to the size of the quantum. And 
> depending on a particular implementation of the scheduler the 
> probability of 4c can still be exactly zero. For example, the OS 
> kernel may deliver only one signal at a time to the process etc. 
> 
> So the "Never" case may quite well never happen at all. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com 
> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/2460a16f-af1b-4613-ba4a-72b13e816a2bn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/golang-nuts/2460a16f-af1b-4613-ba4a-72b13e816a2bn%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0849008D-FD08-4796-9D4B-D43316229F43%40ix.netcom.com.

Reply via email to