Mutex lock in njit function

AFAIK numba on CPU does not have atomics support, the CUDA one does.
I would write the locking mechanism you need in C and use it via FFI.

From this thread, you can use object mode to get your locks, if you so desire.