Skip to main content
deleted 84 characters in body
Source Link
user16034
user16034

The minimum cannot be $0$, because at least one $\text{while}$ will execute, a $\text{while}$ that is entered is performed in full$\text{cnt}\ge0$, and the execution of some assignment $\text{while}$$\text{counter}=\text{cnt}+1$ will inevitably increment $\text{counter}$be performed.

But the minimum can be $1$, as follows:

  • the left process executes with $i=0$, until the assignment $\text{cnt = counter;}$ (hence $\text{i}==1$ and $\text{cnt}==0$).

  • the right process executes all iterations with $i= 1, \cdots9$ and exits.

  • the left process finishes processing and performs the assigment $\text{counter = 0 + 1;}$ and terminates.

Then, unless the incrementation of $i$ is done atomically, the maximum is $20$, as follows:

  • both processes execute the $\text{while}$ test and the RHS of the assignment $\cdots=\text i+1$.

  • both processes perform the LHS of the assignment, $\text i=\cdots$.

  • both processes execute the rest of the loop without overlap.

This way, both loops run $10$ times, for a total of $20$.

If the incrementation is atomic, the maximum is $10$.

The minimum cannot be $0$, because at least one $\text{while}$ will execute, a $\text{while}$ that is entered is performed in full, and the execution of some $\text{while}$ will inevitably increment $\text{counter}$.

But the minimum can be $1$, as follows:

  • the left process executes with $i=0$, until the assignment $\text{cnt = counter;}$ (hence $\text{i}==1$ and $\text{cnt}==0$).

  • the right process executes all iterations with $i= 1, \cdots9$ and exits.

  • the left process finishes processing and performs the assigment $\text{counter = 0 + 1;}$ and terminates.

Then, unless the incrementation of $i$ is done atomically, the maximum is $20$, as follows:

  • both processes execute the $\text{while}$ test and the RHS of the assignment $\cdots=\text i+1$.

  • both processes perform the LHS of the assignment, $\text i=\cdots$.

  • both processes execute the rest of the loop without overlap.

This way, both loops run $10$ times, for a total of $20$.

If the incrementation is atomic, the maximum is $10$.

The minimum cannot be $0$, because $\text{cnt}\ge0$, and some assignment $\text{counter}=\text{cnt}+1$ will inevitably be performed.

But the minimum can be $1$, as follows:

  • the left process executes with $i=0$, until the assignment $\text{cnt = counter;}$ (hence $\text{i}==1$ and $\text{cnt}==0$).

  • the right process executes all iterations with $i= 1, \cdots9$ and exits.

  • the left process finishes processing and performs the assigment $\text{counter = 0 + 1;}$ and terminates.

Then, unless the incrementation of $i$ is done atomically, the maximum is $20$, as follows:

  • both processes execute the $\text{while}$ test and the RHS of the assignment $\cdots=\text i+1$.

  • both processes perform the LHS of the assignment, $\text i=\cdots$.

  • both processes execute the rest of the loop without overlap.

This way, both loops run $10$ times, for a total of $20$.

If the incrementation is atomic, the maximum is $10$.

added 1 character in body
Source Link
user16034
user16034

The minimum cannot be $0$, because at least one $\text{while}$ will execute, a $\text{while}$ that is entered is performed in full, and the execution of anysome $\text{while}$ will inevitably increment $\text{counter}$.

But the minimum can be $1$, as follows:

  • the left process executes with $i=0$, until the assignment $\text{cnt = counter;}$ (hence $\text{i}==1$ and $\text{cnt}==0$).

  • the right process executes all iterations with $i= 1, \cdots9$ and exits.

  • the left process finishes processing and performs the assigment $\text{counter = 0 + 1;}$ and terminates.

Then, unless the incrementation of $i$ is done atomically, the maximum is $20$, as follows:

  • both processes execute the $\text{while}$ test and the RHS of the assignment $\cdots=\text i+1$.

  • both processes perform the LHS of the assignment, $\text i=\cdots$.

  • both processes execute the rest of the loop without overlap.

This way, both loops run $10$ times, for a total of $20$.

If the incrementation is atomic, the maximum is $10$.

The minimum cannot be $0$, because at least one $\text{while}$ will execute, a $\text{while}$ that is entered is performed in full, and the execution of any $\text{while}$ will inevitably increment $\text{counter}$.

But the minimum can be $1$, as follows:

  • the left process executes with $i=0$, until the assignment $\text{cnt = counter;}$ (hence $\text{i}==1$ and $\text{cnt}==0$).

  • the right process executes all iterations with $i= 1, \cdots9$ and exits.

  • the left process finishes processing and performs the assigment $\text{counter = 0 + 1;}$ and terminates.

Then, unless the incrementation of $i$ is done atomically, the maximum is $20$, as follows:

  • both processes execute the $\text{while}$ test and the RHS of the assignment $\cdots=\text i+1$.

  • both processes perform the LHS of the assignment, $\text i=\cdots$.

  • both processes execute the rest of the loop without overlap.

This way, both loops run $10$ times, for a total of $20$.

If the incrementation is atomic, the maximum is $10$.

The minimum cannot be $0$, because at least one $\text{while}$ will execute, a $\text{while}$ that is entered is performed in full, and the execution of some $\text{while}$ will inevitably increment $\text{counter}$.

But the minimum can be $1$, as follows:

  • the left process executes with $i=0$, until the assignment $\text{cnt = counter;}$ (hence $\text{i}==1$ and $\text{cnt}==0$).

  • the right process executes all iterations with $i= 1, \cdots9$ and exits.

  • the left process finishes processing and performs the assigment $\text{counter = 0 + 1;}$ and terminates.

Then, unless the incrementation of $i$ is done atomically, the maximum is $20$, as follows:

  • both processes execute the $\text{while}$ test and the RHS of the assignment $\cdots=\text i+1$.

  • both processes perform the LHS of the assignment, $\text i=\cdots$.

  • both processes execute the rest of the loop without overlap.

This way, both loops run $10$ times, for a total of $20$.

If the incrementation is atomic, the maximum is $10$.

added 364 characters in body
Source Link
user16034
user16034

The minimum cannot be $0$, because at least one $\text{while}$ will execute, a $\text{while}$ that is entered is performed in full, and the execution of any $\text{while}$ will inevitably increment $\text{counter}$.

But the minimum can be $1$, as follows:

  • the left process executes fromwith $i=0$, until the assignment $\text{cnt = counter;}$ (hence $\text{i}==1$ and $\text{cnt}==0$).

  • the right process executes all iterations with $i= 1, \cdots9$ and exits.

  • the left process finishes processing and performs the assigment $\text{counter = 0 + 1;}$ and terminates.

Then, unless the incrementation of $i$ is done atomically, the maximum is $20$, as follows:

  • both processes execute the $\text{while}$ test and the RHS of the assignment $\cdots=\text i+1$.

  • both processes perform the LHS of the assignment, $\text i=\cdots$.

  • both processes execute the rest of the loop without overlap.

This way, both loops run $10$ times, for a total of $20$.

If the incrementation is atomic, the maximum is $10$.

The minimum cannot be $0$, because at least one $\text{while}$ will execute, a $\text{while}$ that is entered is performed in full, and the execution of any $\text{while}$ will inevitably increment $\text{counter}$.

But the minimum can be $1$, as follows:

  • the left process executes from $i=0$, until the assignment $\text{cnt = counter;}$ (hence $\text{i}==1$ and $\text{cnt}==0$).

  • the right process executes all iterations with $i= 1, \cdots9$ and exits.

  • the left process finishes processing and performs the assigment $\text{counter = 0 + 1;}$ and terminates.

The minimum cannot be $0$, because at least one $\text{while}$ will execute, a $\text{while}$ that is entered is performed in full, and the execution of any $\text{while}$ will inevitably increment $\text{counter}$.

But the minimum can be $1$, as follows:

  • the left process executes with $i=0$, until the assignment $\text{cnt = counter;}$ (hence $\text{i}==1$ and $\text{cnt}==0$).

  • the right process executes all iterations with $i= 1, \cdots9$ and exits.

  • the left process finishes processing and performs the assigment $\text{counter = 0 + 1;}$ and terminates.

Then, unless the incrementation of $i$ is done atomically, the maximum is $20$, as follows:

  • both processes execute the $\text{while}$ test and the RHS of the assignment $\cdots=\text i+1$.

  • both processes perform the LHS of the assignment, $\text i=\cdots$.

  • both processes execute the rest of the loop without overlap.

This way, both loops run $10$ times, for a total of $20$.

If the incrementation is atomic, the maximum is $10$.

Source Link
user16034
user16034
Loading