| 307 | | It indicates that the statements comprising the block should be executed without the intervention of other processes. |
| 308 | | |
| 309 | | More precisely, there is a global atomic lock which is initially free. |
| 310 | | A process attempting to execute an atomic block will wait until the atomic lock becomes free, i.e., no other process is inside an atomic block. |
| 311 | | The process must also wait until the guard of the atomic block holds; this means that the first statement in the block is enabled. |
| 312 | | Once the atomic lock is free and the guard holds, the atomic block becomes enabled and the process may enter the atomic block. |
| 313 | | The process may not necessarily enter the atomic block as soon as these conditions hold, because some other enabled process may be scheduled first. |
| | 308 | In this example, ''stmt'' is a compound statement `{` ... `}`. This is usually the case. |
| | 309 | |
| | 310 | Semantics: there is a global atomic lock which is initially free. |
| | 311 | A process attempting to execute an atomic statement will wait until the atomic lock becomes free, i.e., no other process is inside an atomic statement. |
| | 312 | The process must also wait until the guard of the atomic statement holds; this means that the first sub-statement of the statement is enabled. |
| | 313 | Once the atomic lock is free and the guard holds, the atomic statement becomes enabled and the process may enter the atomic statement. |
| | 314 | The process may not necessarily enter the atomic statement as soon as these conditions hold, because some other enabled process may be scheduled first. |
| 315 | | But if the enabling conditions hold and this process is scheduled, it will obtain the atomic lock and begin executing the statements |
| 316 | | of the atomic block without other processes executing. |
| 317 | | Upon reaching the end of the atomic block, the process releases the atomic lock and exits the block. |
| 318 | | |
| 319 | | There is an exception to atomicity: if the process inside the atomic block executes a [#yield $yield statement], it releases the atomic lock. |
| | 316 | But if the enabling conditions hold and this process is scheduled, it will obtain the atomic lock and begin executing ''stmt'' without other processes executing. |
| | 317 | Upon reaching the end of ''stmt'', the process releases the atomic lock and exits ''stmt''. |
| | 318 | |
| | 319 | There is an exception to atomicity: if the process executing inside the atomic statement call the [#yield $yield function], it releases the atomic lock. |
| 322 | | the atomic lock and continue executing its block atomically. |
| 323 | | |
| 324 | | If a statement inside an atomic block blocks, so that the process executing the atomic block has no enabled statement, execution deadlocks. |
| 325 | | The exception to this rule is that the first statement in the atomic block, and the first statement after a `$yield`, as described above, |
| | 322 | the atomic lock and continue executing atomically. |
| | 323 | |
| | 324 | If a statement inside an atomic statement blocks, so that the process executing the atomic statement has no enabled statement, execution deadlocks. |
| | 325 | The exception to this rule is that the first sub-statement in the atomic statement, and the first statement after a `$yield`, as described above, |