I think overflow should be prevented by not allowing to have enough tasks to overflow it in the first place, and not by checking here.

It's also indeed possible to check manually in the mutex, but it's slow, ugly, and also means that a program may either succeed by chance depending on whether enough of its tasks happen to try to take a mutex at the same time.

It seems much better to have a library where a program can fail on task creation, but never fails on mutex operations.