Open ryancaicse opened 2 years ago
Thanks Ryan! Technically you're right, things would be aesthetically balanced if we had a pthread_mutex_unlock(&(NewThread->StartMutex))
in the !KSUCCESS() case. In practice it doesn't end up mattering because NewThread is being destroyed in the !KSUCCESS() case, having failed to start the new thread.
I'm tempted to leave things as-is.
@evangreen Hi, thank you for your reply and confirm this!
There is a similar case, the Thread->StartMutex
is not released before the thread goes die. Would it better to release the lock before?
Hm. It's a similar story there. The StartMutex acts like a barrier, ensuring that ClpThreadStart() doesn't let the thread run its main routine until pthread_create() has finished initializing the thread members. I suppose the StartMutex could be replaced with a pthread_cond_t, but the mutex is a little lighter.
@evangreen OK, Thank you. Feel free to close this issue if they would be fixed.
Hi, developers, thank you for your checking. It seems the lock
NewThread->StartMutex
is not released correctly when!KSUCCESS(KernelStatus)
?https://github.com/minoca/os/blob/460ae51663e02f607f0738521cc2488e0866e70c/apps/libc/dynamic/pthread/pthread.c#L248-L278