This commit is contained in:
Nekotekina 2015-01-02 19:02:31 +03:00
parent 318d7276c0
commit d8664c8da4
8 changed files with 14 additions and 10 deletions

View File

@ -1118,7 +1118,7 @@ void SPUThread::StopAndSignal(u32 code)
SPU.In_MBox.PushUncond((u32)event.data1);
SPU.In_MBox.PushUncond((u32)event.data2);
SPU.In_MBox.PushUncond((u32)event.data3);
if (!eq->sq.invalidate(tid, eq->protocol))
if (!eq->sq.invalidate(tid, eq->protocol) && !eq->sq.pop(tid, eq->protocol))
{
assert(!"sys_spu_thread_receive_event() failed (receiving)");
}

View File

@ -210,6 +210,10 @@ bool sleep_queue_t::invalidate(u32 tid, u32 protocol)
{
if (v == tid)
{
if (&v == m_signaled.data())
{
return false; // if the thread is signaled, pop() should be used
}
m_signaled.erase(m_signaled.begin() + (&v - m_signaled.data()));
return true;
}

View File

@ -191,7 +191,7 @@ s32 sys_cond_wait(PPUThread& CPU, u32 cond_id, u64 timeout)
}
}
if (pushed_in_sleep_queue && !mutex->queue.invalidate(tid, mutex->protocol))
if (pushed_in_sleep_queue && !mutex->queue.invalidate(tid, mutex->protocol) && !mutex->queue.pop(tid, mutex->protocol))
{
assert(!"sys_cond_wait() failed (locking)");
}

View File

@ -210,7 +210,7 @@ s32 sys_event_queue_receive(u32 equeue_id, vm::ptr<sys_event_data> dummy_event,
t.GPR[5] = event.data1;
t.GPR[6] = event.data2;
t.GPR[7] = event.data3;
if (!eq->sq.invalidate(tid, eq->protocol))
if (!eq->sq.invalidate(tid, eq->protocol) && !eq->sq.pop(tid, eq->protocol))
{
assert(!"sys_event_queue_receive() failed (receiving)");
}

View File

@ -210,7 +210,7 @@ s32 sys_lwmutex_t::lock(be_t<u32> tid, u64 timeout)
}
}
if (!sq->invalidate(tid, attribute))
if (!sq->invalidate(tid, attribute) && !sq->pop(tid, attribute))
{
assert(!"sys_lwmutex_t::lock() failed (locking)");
}

View File

@ -160,7 +160,7 @@ s32 sys_mutex_lock(PPUThread& CPU, u32 mutex_id, u64 timeout)
}
}
if (!mutex->queue.invalidate(tid, mutex->protocol))
if (!mutex->queue.invalidate(tid, mutex->protocol) && !mutex->queue.pop(tid, mutex->protocol))
{
assert(!"sys_mutex_lock() failed (locking)");
}

View File

@ -212,7 +212,7 @@ s32 sys_rwlock_wlock(PPUThread& CPU, u32 rw_lock_id, u64 timeout)
}
}
if (!rw->wqueue.invalidate(tid, rw->protocol))
if (!rw->wqueue.invalidate(tid, rw->protocol) && !rw->wqueue.pop(tid, rw->protocol))
{
assert(!"sys_rwlock_wlock() failed (locking)");
}

View File

@ -100,8 +100,6 @@ s32 sys_semaphore_wait(u32 sem_id, u64 timeout)
s32 old_value;
{
LV2_LOCK(0);
sem->value.atomic_op_sync([&old_value](s32& value)
{
old_value = value;
@ -134,6 +132,10 @@ s32 sys_semaphore_wait(u32 sem_id, u64 timeout)
{
if (!sem->queue.invalidate(tid, sem->protocol))
{
if (sem->queue.pop(tid, sem->protocol))
{
return CELL_OK;
}
assert(!"sys_semaphore_wait() failed (timeout)");
}
return CELL_ETIMEDOUT;
@ -195,8 +197,6 @@ s32 sys_semaphore_post(u32 sem_id, s32 count)
return CELL_EINVAL;
}
LV2_LOCK(0);
if (count + sem->value.read_sync() - (s32)sem->queue.count() > sem->max)
{
return CELL_EBUSY;