Added basic atomic locks and added locks to `add_kernel_task`