mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 15:31:26 +12:00
Small workaround
This commit is contained in:
parent
5da33c6243
commit
54cdc41ac8
6 changed files with 32 additions and 28 deletions
|
@ -43,29 +43,22 @@ bool SSemaphore::try_wait()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSemaphore::post(u32 value)
|
void SSemaphore::post()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
if (m_count >= m_max)
|
if (m_count >= m_max)
|
||||||
{
|
{
|
||||||
value = 0;
|
return;
|
||||||
}
|
|
||||||
else if (value > (m_max - m_count))
|
|
||||||
{
|
|
||||||
value = m_max - m_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (value)
|
m_count++;
|
||||||
{
|
m_cond.notify_one();
|
||||||
m_count++;
|
|
||||||
value--;
|
|
||||||
m_cond.notify_one();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SSemaphore::post_and_wait()
|
bool SSemaphore::post_and_wait()
|
||||||
{
|
{
|
||||||
|
// TODO: ???
|
||||||
if (try_wait()) return false;
|
if (try_wait()) return false;
|
||||||
|
|
||||||
post();
|
post();
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
|
|
||||||
bool try_wait();
|
bool try_wait();
|
||||||
|
|
||||||
void post(u32 value = 1);
|
void post();
|
||||||
|
|
||||||
bool post_and_wait();
|
bool post_and_wait();
|
||||||
};
|
};
|
|
@ -81,6 +81,7 @@ int sys_cond_signal(u32 cond_id)
|
||||||
{
|
{
|
||||||
cond->signal_stamp = get_system_time();
|
cond->signal_stamp = get_system_time();
|
||||||
cond->signal.lock(target);
|
cond->signal.lock(target);
|
||||||
|
Emu.GetCPU().NotifyThread(target);
|
||||||
|
|
||||||
if (Emu.IsStopped())
|
if (Emu.IsStopped())
|
||||||
{
|
{
|
||||||
|
@ -105,15 +106,19 @@ int sys_cond_signal_all(u32 cond_id)
|
||||||
|
|
||||||
while (u32 target = (mutex->protocol == SYS_SYNC_PRIORITY ? cond->m_queue.pop_prio() : cond->m_queue.pop()))
|
while (u32 target = (mutex->protocol == SYS_SYNC_PRIORITY ? cond->m_queue.pop_prio() : cond->m_queue.pop()))
|
||||||
{
|
{
|
||||||
|
cond->signaler = GetCurrentCPUThread()->GetId();
|
||||||
cond->signal_stamp = get_system_time();
|
cond->signal_stamp = get_system_time();
|
||||||
cond->signal.lock(target);
|
cond->signal.lock(target);
|
||||||
|
Emu.GetCPU().NotifyThread(target);
|
||||||
|
|
||||||
if (Emu.IsStopped())
|
if (Emu.IsStopped())
|
||||||
{
|
{
|
||||||
ConLog.Warning("sys_cond_signal_all(id=%d) aborted", cond_id);
|
ConLog.Warning("sys_cond_signal_all(id=%d) aborted", cond_id);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cond->signaler = 0;
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +148,7 @@ int sys_cond_signal_to(u32 cond_id, u32 thread_id)
|
||||||
{
|
{
|
||||||
cond->signal_stamp = get_system_time();
|
cond->signal_stamp = get_system_time();
|
||||||
cond->signal.lock(target);
|
cond->signal.lock(target);
|
||||||
|
Emu.GetCPU().NotifyThread(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Emu.IsStopped())
|
if (Emu.IsStopped())
|
||||||
|
@ -188,6 +194,7 @@ int sys_cond_wait(u32 cond_id, u64 timeout)
|
||||||
{
|
{
|
||||||
if (cond->signal.unlock(tid, tid) == SMR_OK)
|
if (cond->signal.unlock(tid, tid) == SMR_OK)
|
||||||
{
|
{
|
||||||
|
const u64 stamp2 = get_system_time();
|
||||||
if (SMutexResult res = mutex->m_mutex.trylock(tid))
|
if (SMutexResult res = mutex->m_mutex.trylock(tid))
|
||||||
{
|
{
|
||||||
if (res != SMR_FAILED)
|
if (res != SMR_FAILED)
|
||||||
|
@ -209,11 +216,12 @@ int sys_cond_wait(u32 cond_id, u64 timeout)
|
||||||
mutex->recursive = 1;
|
mutex->recursive = 1;
|
||||||
const volatile u64 stamp = cond->signal_stamp;
|
const volatile u64 stamp = cond->signal_stamp;
|
||||||
cond->signal.unlock(tid);
|
cond->signal.unlock(tid);
|
||||||
//ConLog.Write("sys_cond_wait(): signal latency %d", get_system_time() - stamp);
|
Emu.GetCPU().NotifyThread(cond->signaler);
|
||||||
|
//ConLog.Write("sys_cond_wait(): signal latency %lld (minimum %lld)", get_system_time() - stamp, stamp2 - stamp);
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sleep(1);
|
SM_Sleep();
|
||||||
|
|
||||||
if (counter++ > max_counter)
|
if (counter++ > max_counter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,12 +17,15 @@ struct Cond
|
||||||
{
|
{
|
||||||
Mutex* mutex; // associated with mutex
|
Mutex* mutex; // associated with mutex
|
||||||
SMutex signal;
|
SMutex signal;
|
||||||
|
u32 signaler; // signaler thread id (for signal_all)
|
||||||
SleepQueue m_queue;
|
SleepQueue m_queue;
|
||||||
|
|
||||||
u64 signal_stamp;
|
u64 signal_stamp;
|
||||||
|
|
||||||
Cond(Mutex* mutex, u64 name)
|
Cond(Mutex* mutex, u64 name)
|
||||||
: mutex(mutex)
|
: mutex(mutex)
|
||||||
, m_queue(name)
|
, m_queue(name)
|
||||||
|
, signaler(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -93,7 +93,7 @@ int sys_mutex_destroy(u32 mutex_id)
|
||||||
|
|
||||||
int sys_mutex_lock(u32 mutex_id, u64 timeout)
|
int sys_mutex_lock(u32 mutex_id, u64 timeout)
|
||||||
{
|
{
|
||||||
sys_mtx.Log("sys_mutex_lock(mutex_id=%d, timeout=0x%llx)", mutex_id, timeout);
|
sys_mtx.Log("sys_mutex_lock(mutex_id=%d, timeout=%lld)", mutex_id, timeout);
|
||||||
|
|
||||||
Mutex* mutex;
|
Mutex* mutex;
|
||||||
if (!Emu.GetIdManager().GetIDData(mutex_id, mutex))
|
if (!Emu.GetIdManager().GetIDData(mutex_id, mutex))
|
||||||
|
|
|
@ -8,72 +8,72 @@ SysCallBase sys_rsx("sys_rsx");
|
||||||
|
|
||||||
int sys_rsx_device_open()
|
int sys_rsx_device_open()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_device_open()");
|
sys_rsx.Error("TODO: sys_rsx_device_open()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_device_close()
|
int sys_rsx_device_close()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_device_close()");
|
sys_rsx.Error("TODO: sys_rsx_device_close()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_memory_allocate()
|
int sys_rsx_memory_allocate()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_memory_allocate()");
|
sys_rsx.Error("TODO: sys_rsx_memory_allocate()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_memory_free()
|
int sys_rsx_memory_free()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_memory_free()");
|
sys_rsx.Error("TODO: sys_rsx_memory_free()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_context_allocate()
|
int sys_rsx_context_allocate()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_context_allocate()");
|
sys_rsx.Error("TODO: sys_rsx_context_allocate()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_context_free()
|
int sys_rsx_context_free()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_context_free()");
|
sys_rsx.Error("TODO: sys_rsx_context_free()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_context_iomap()
|
int sys_rsx_context_iomap()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_context_iomap()");
|
sys_rsx.Error("TODO: sys_rsx_context_iomap()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_context_iounmap()
|
int sys_rsx_context_iounmap()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_context_iounmap()");
|
sys_rsx.Error("TODO: sys_rsx_context_iounmap()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_context_attribute(s32 context_id, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6)
|
int sys_rsx_context_attribute(s32 context_id, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6)
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_context_attribute(context_id=%d, a2=%llu, a3=%llu, a4=%llu, a5=%llu, a6=%llu)", context_id, a2, a3, a4, a5, a6);
|
sys_rsx.Error("TODO: sys_rsx_context_attribute(context_id=%d, a2=%llu, a3=%llu, a4=%llu, a5=%llu, a6=%llu)", context_id, a2, a3, a4, a5, a6);
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 a3)
|
int sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 a3)
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_device_map(a1_addr=0x%x, a2_addr=0x%x, a3=%d)", a1.GetAddr(), a2.GetAddr(), a3);
|
sys_rsx.Error("TODO: sys_rsx_device_map(a1_addr=0x%x, a2_addr=0x%x, a3=%d)", a1.GetAddr(), a2.GetAddr(), a3);
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_device_unmap()
|
int sys_rsx_device_unmap()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_device_unmap()");
|
sys_rsx.Error("TODO: sys_rsx_device_unmap()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_rsx_attribute()
|
int sys_rsx_attribute()
|
||||||
{
|
{
|
||||||
sys_rsx.Warning("Unimplemented function: sys_rsx_attribute()");
|
sys_rsx.Error("TODO: sys_rsx_attribute()");
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue