Convert task->flags to C11 atomics

Edited by Mark Andrews

Merge request reports