Fixed mutex::is_locked_by_me() on Gcc

Gcc's thread implementation fails to compare null thread id. So, an
auxiliary variable was created to tell if the mutex is locked or not.