rocr: Fix sem_post overflow errors
WaitSemaphore and PostSemaphore are used in the HybridMutex
implementation. If HybridMutex did not have to call WaitSemaphore when
acquired, then calling PostSemaphore would cause the internal count
inside sem_t to slowly grow to large values and eventually cause
overflow.
Change-Id: I173fc17c874b49926e56991405e9086ea8c138fc
[ROCm/ROCR-Runtime commit: f58aff630c]
이 커밋은 다음에 포함됨:
1 부모
3e694d739a
커밋
ed5bbc1eeb
1 파일이 변경됨
+8
@@ -369,6 +369,14 @@ bool WaitSemaphore(Semaphore sem) {
|
||||
}
|
||||
|
||||
void PostSemaphore(Semaphore sem) {
|
||||
int waitval = 1;
|
||||
if (sem_getvalue(*(sem_t**)&sem, &waitval))
|
||||
assert(false && "Failed to get semaphore waiters");
|
||||
|
||||
/* sem_getvalue return <= 0 when there are threads blocked on sem_wait */
|
||||
if (waitval > 0)
|
||||
return;
|
||||
|
||||
if (sem_post(*(sem_t**)&sem))
|
||||
assert(false && "Failed to post semaphore");
|
||||
}
|
||||
|
||||
새 이슈에서 참조
사용자 차단