How exactly is linearization order determined. How can it be said that Linearization order of the following code is the order in which released by wait(). How can it be checked whether the code is linearizable?
class Buffer
{
int in = 0;
int out = 0;
int numElems = 0;
synchronized void put(E elem) throws InterruptedException
{
while (!numElems < N)
{
wait();
}
buff[in] = elem;
in = (in + 1) % N;
notifyAll();
}
synchronized E take() throws InterruptedException
{
while (!numElems > 0)
{
wait();
}
E temp = buff[out];
out = (out + 1) % N;
return temp;
notifyAll();
}
}