mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 22:11:26 +12:00
Some freezing fixed
This commit is contained in:
parent
2200e6f4d9
commit
eca7339a67
6 changed files with 38 additions and 20 deletions
|
@ -6,6 +6,11 @@ void SSemaphore::wait()
|
||||||
u32 order;
|
u32 order;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
if (m_count && m_out_order == m_in_order)
|
||||||
|
{
|
||||||
|
m_count--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
order = m_in_order++;
|
order = m_in_order++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +25,7 @@ void SSemaphore::wait()
|
||||||
|
|
||||||
m_cond.wait_for(cv_lock, std::chrono::milliseconds(1));
|
m_cond.wait_for(cv_lock, std::chrono::milliseconds(1));
|
||||||
|
|
||||||
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
if (m_count)
|
if (m_count)
|
||||||
{
|
{
|
||||||
|
@ -36,12 +42,12 @@ void SSemaphore::wait()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SSemaphore::try_wait()
|
bool SSemaphore::try_wait()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
// TODO: ordering?
|
|
||||||
if (m_count && m_in_order == m_out_order)
|
if (m_count && m_in_order == m_out_order)
|
||||||
{
|
{
|
||||||
m_count--;
|
m_count--;
|
||||||
|
@ -57,18 +63,21 @@ 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)
|
||||||
|
{
|
||||||
|
m_count++;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_count++;
|
|
||||||
m_cond.notify_one();
|
m_cond.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SSemaphore::post_and_wait()
|
bool SSemaphore::post_and_wait()
|
||||||
{
|
{
|
||||||
// TODO: ???
|
// TODO: merge these functions? Probably has a race condition.
|
||||||
if (try_wait()) return false;
|
if (try_wait()) return false;
|
||||||
|
|
||||||
post();
|
post();
|
||||||
|
|
|
@ -6,7 +6,8 @@ class SSemaphore
|
||||||
u32 m_count;
|
u32 m_count;
|
||||||
u32 m_in_order;
|
u32 m_in_order;
|
||||||
u32 m_out_order;
|
u32 m_out_order;
|
||||||
std::mutex m_mutex, m_cv_mutex;
|
std::mutex m_cv_mutex;
|
||||||
|
std::mutex m_mutex;
|
||||||
std::condition_variable m_cond;
|
std::condition_variable m_cond;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1882,8 +1882,13 @@ void RSXThread::Task()
|
||||||
inc=1;
|
inc=1;
|
||||||
|
|
||||||
u32 put, get;
|
u32 put, get;
|
||||||
|
// this code produces only mov + bswap:
|
||||||
se_t<u32>::func(put, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, put))));
|
se_t<u32>::func(put, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, put))));
|
||||||
se_t<u32>::func(get, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, get))));
|
se_t<u32>::func(get, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, get))));
|
||||||
|
/*
|
||||||
|
se_t<u32>::func(put, InterlockedCompareExchange((volatile unsigned long*)((u8*)m_ctrl + offsetof(CellGcmControl, put)), 0, 0));
|
||||||
|
se_t<u32>::func(get, InterlockedCompareExchange((volatile unsigned long*)((u8*)m_ctrl + offsetof(CellGcmControl, get)), 0, 0));
|
||||||
|
*/
|
||||||
|
|
||||||
if(put == get || !Emu.IsRunning())
|
if(put == get || !Emu.IsRunning())
|
||||||
{
|
{
|
||||||
|
|
|
@ -471,7 +471,7 @@ int cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
|
||||||
return CELL_GCM_ERROR_FAILURE;
|
return CELL_GCM_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); // could freeze on exit
|
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH);
|
||||||
|
|
||||||
u32 current = ctxt->current;
|
u32 current = ctxt->current;
|
||||||
u32 end = ctxt->end;
|
u32 end = ctxt->end;
|
||||||
|
@ -488,6 +488,8 @@ int cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
|
||||||
|
|
||||||
if(res > 0) Memory.Copy(ctxt->begin, ctxt->current - res, res);
|
if(res > 0) Memory.Copy(ctxt->begin, ctxt->current - res, res);
|
||||||
ctxt->current = ctxt->begin + res;
|
ctxt->current = ctxt->begin + res;
|
||||||
|
|
||||||
|
//InterlockedExchange64((volatile long long*)((u8*)&ctrl + offsetof(CellGcmControl, put)), (u64)(u32)re(res));
|
||||||
ctrl.put = res;
|
ctrl.put = res;
|
||||||
ctrl.get = 0;
|
ctrl.get = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -802,7 +802,7 @@ int cellRescSetConvertAndFlip(mem_ptr_t<CellGcmContextData> cntxt, s32 idx)
|
||||||
int cellRescSetWaitFlip()
|
int cellRescSetWaitFlip()
|
||||||
{
|
{
|
||||||
cellResc->Log("cellRescSetWaitFlip()");
|
cellResc->Log("cellRescSetWaitFlip()");
|
||||||
GSLockCurrent lock(GS_LOCK_WAIT_FLIP); // could stall on exit
|
GSLockCurrent lock(GS_LOCK_WAIT_FLIP);
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ extern gcmInfo gcm_info;
|
||||||
|
|
||||||
int cellGcmCallback(u32 context_addr, u32 count)
|
int cellGcmCallback(u32 context_addr, u32 count)
|
||||||
{
|
{
|
||||||
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); // could freeze on exit
|
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH);
|
||||||
|
|
||||||
CellGcmContextData& ctx = (CellGcmContextData&)Memory[context_addr];
|
CellGcmContextData& ctx = (CellGcmContextData&)Memory[context_addr];
|
||||||
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
|
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
|
||||||
|
@ -24,6 +24,7 @@ int cellGcmCallback(u32 context_addr, u32 count)
|
||||||
|
|
||||||
ctx.current = ctx.begin + res;
|
ctx.current = ctx.begin + res;
|
||||||
|
|
||||||
|
//InterlockedExchange64((volatile long long*)((u8*)&ctrl + offsetof(CellGcmControl, put)), (u64)(u32)re(res));
|
||||||
ctrl.put = res;
|
ctrl.put = res;
|
||||||
ctrl.get = 0;
|
ctrl.get = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue