Pregunta

Note that FIFO ordering necessarily applies to specific internal points of execution within these methods.

from doc

What do they mean with internal points of execution?

¿Fue útil?

Solución

The documentation immediately says after that:

So, it is possible for one thread to invoke acquire before another, but reach the ordering point after the other

Which means this scenario is possible:

thread 1                 thread 2
--------                 --------
calls acquire()
                         calls acquire()
                         acquire() does its job
acquire() does its job

(where acquires() does its job is what the doc refers to as the "ordering point")

In short: there is no guarantee that, timely speaking, the first thread calling acquire() gets to acquire the semaphore first. What is guaranteed is that when it returns from acquire(), other acquire() callers will have to wait.

This is a rare occurrence, but possible.

Otros consejos

They are refereing to points of execution internal to the acquire() method. They mean that, in the implementation of acquire(), there is some 'ordering point' where the first thread to get there will be the first to leave. So, if thread A gets calls enters acquire() before B, but B gets to the ordering point first, B will come out first (despite entering acquire second).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top