management to an implementation.

[Scheduling and Dispatching]{}\[sched\]

We propose a new state for Ada tasks to facilitate correct scheduling and dispatching for threads synchronizing via [synchronized]{} or read-modify-write types. If a thread is in a sync loop, the thread state changes to “in\_sync\_loop”. Note that sync loops can only happen inside [concurrent]{} objects. Thus they can be spotted easily by the compiler and cannot be confused with “normal” loops. Note also that for the state change it makes sense not to take place during the first iteration of the sync loop, because the synchronization may succeed immediately. For read-modify-write loops, iteration from the third iteration on may be a good choice; for spin loops, an iteration from the second iteration on may be a good choice.

In this way the runtime can guarantee that not all available CPUs (cores) are occupied by threads in state “in\_sync\_loop”. Thus we can be sure that at least one thread makes progress and finally all [synchronized]{} or read-modify-write variables are released (if the program’s synchronization structure is correct and the program does not deadlock).

After leaving a sync loop, the thread state changes back to “runable”.

[Examples]{}\[sec:examples\]

[Non-blocking Stack.]{}\[lfs\] Listing \[lfsada\] shows an implementation 