mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 20:22:30 +01:00
Fixed thread issues
Fixed args passing Fixed thread stopping/pausing (temporarily) Fixed problems with SC_Condition and SC_Mutex (partially)
This commit is contained in:
parent
a0c8e116df
commit
311486ed79
@ -89,14 +89,12 @@ void CPUThread::Wait(const CPUThread& thr)
|
||||
|
||||
bool CPUThread::Sync()
|
||||
{
|
||||
wxCriticalSectionLocker lock(m_cs_sync);
|
||||
|
||||
return m_sync_wait;
|
||||
}
|
||||
|
||||
int CPUThread::ThreadStatus()
|
||||
{
|
||||
if(Emu.IsStopped())
|
||||
if(Emu.IsStopped() || IsStopped() || IsPaused())
|
||||
{
|
||||
return CPUThread_Stopped;
|
||||
}
|
||||
@ -236,7 +234,7 @@ void CPUThread::Pause()
|
||||
DoPause();
|
||||
Emu.CheckStatus();
|
||||
|
||||
ThreadBase::Stop();
|
||||
// ThreadBase::Stop(); // "Abort() called" exception
|
||||
#ifndef QT_UI
|
||||
wxGetApp().SendDbgCommand(DID_PAUSED_THREAD, this);
|
||||
#endif
|
||||
|
@ -93,7 +93,7 @@ CPUThread* CPUThreadManager::GetThread(u32 id)
|
||||
{
|
||||
CPUThread* res;
|
||||
|
||||
Emu.GetIdManager().GetIDData(id, res);
|
||||
if (!Emu.GetIdManager().GetIDData(id, res)) return nullptr;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ PPCThread* GetCurrentPPCThread()
|
||||
|
||||
PPCThread::PPCThread(CPUThreadType type) : CPUThread(type)
|
||||
{
|
||||
memset(m_args, 0, sizeof(m_args));
|
||||
}
|
||||
|
||||
PPCThread::~PPCThread()
|
||||
@ -24,7 +25,6 @@ PPCThread::~PPCThread()
|
||||
|
||||
void PPCThread::DoReset()
|
||||
{
|
||||
memset(m_args, 0, sizeof(u64) * 4);
|
||||
}
|
||||
|
||||
void PPCThread::InitStack()
|
||||
|
@ -174,7 +174,7 @@ u64 DynamicMemoryBlockBase<PT>::AllocAlign(u32 size, u32 align)
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::Alloc()
|
||||
{
|
||||
return AllocAlign(GetSize() - GetUsedSize(), 0) != 0;
|
||||
return AllocAlign(GetSize() - GetUsedSize()) != 0;
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
|
@ -123,7 +123,7 @@ public:
|
||||
virtual u8* GetMem(u64 addr) const { return mem + addr; }
|
||||
|
||||
virtual bool AllocFixed(u64 addr, u32 size) { return false; }
|
||||
virtual u64 AllocAlign(u32 size, u32 align = 0) { return 0; }
|
||||
virtual u64 AllocAlign(u32 size, u32 align = 1) { return 0; }
|
||||
virtual bool Alloc() { return false; }
|
||||
virtual bool Free(u64 addr) { return false; }
|
||||
virtual bool Lock(u64 addr, u32 size) { return false; }
|
||||
@ -215,7 +215,7 @@ public:
|
||||
virtual void Delete();
|
||||
|
||||
virtual bool AllocFixed(u64 addr, u32 size);
|
||||
virtual u64 AllocAlign(u32 size, u32 align = 0);
|
||||
virtual u64 AllocAlign(u32 size, u32 align = 1);
|
||||
virtual bool Alloc();
|
||||
virtual bool Free(u64 addr);
|
||||
virtual bool Lock(u64 addr, u32 size);
|
||||
|
@ -176,8 +176,8 @@ void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, int xid, mem_func_ptr_t<void (*
|
||||
}
|
||||
|
||||
//start callback thread
|
||||
//if(func)
|
||||
//func.async(aio, error, xid, res);
|
||||
if(func)
|
||||
func.async(aio, error, xid, res);
|
||||
|
||||
ConLog.Warning("*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=%d, res=%d, xid=%d [%s])",
|
||||
fd, (u64)aio->offset, buf_addr, (u64)aio->size, res, xid, path.c_str());
|
||||
@ -195,6 +195,7 @@ int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<void
|
||||
|
||||
thread t("fsAioRead", std::bind(fsAioRead, fd, aio, xid, func));
|
||||
t.detach();
|
||||
//fsAioRead(fd, aio, xid, func);
|
||||
|
||||
aio_id = xid;
|
||||
|
||||
|
@ -188,7 +188,7 @@ extern int sys_ppu_thread_get_priority(u32 thread_id, u32 prio_addr);
|
||||
extern int sys_ppu_thread_get_stack_information(u32 info_addr);
|
||||
extern int sys_ppu_thread_stop(u32 thread_id);
|
||||
extern int sys_ppu_thread_restart(u32 thread_id);
|
||||
extern int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u32 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr);
|
||||
extern int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u64 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr);
|
||||
extern void sys_ppu_thread_once(u32 once_ctrl_addr, u32 entry);
|
||||
extern int sys_ppu_thread_get_id(const u32 id_addr);
|
||||
extern int sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq, u64 req, u32 spup_addr);
|
||||
|
@ -27,7 +27,7 @@ struct condition
|
||||
|
||||
int sys_cond_create(u32 cond_addr, u32 mutex_id, u32 attr_addr)
|
||||
{
|
||||
sys_cond.Log("sys_cond_create(cond_addr=0x%x, mutex_id=0x%x, attr_addr=%d)",
|
||||
sys_cond.Warning("sys_cond_create(cond_addr=0x%x, mutex_id=0x%x, attr_addr=%d)",
|
||||
cond_addr, mutex_id, attr_addr);
|
||||
|
||||
if(!Memory.IsGoodAddr(cond_addr) || !Memory.IsGoodAddr(attr_addr)) return CELL_EFAULT;
|
||||
@ -68,9 +68,32 @@ int sys_cond_wait(u32 cond_id, u64 timeout)
|
||||
condition* cond_data = nullptr;
|
||||
if(!sys_cond.CheckId(cond_id, cond_data)) return CELL_ESRCH;
|
||||
|
||||
cond_data->cond.WaitTimeout(timeout ? timeout : INFINITE);
|
||||
u32 counter = 0;
|
||||
const u32 max_counter = timeout ? (timeout / 1000) : 20000;
|
||||
do
|
||||
{
|
||||
if (Emu.IsStopped()) return CELL_ETIMEDOUT;
|
||||
|
||||
return CELL_OK;
|
||||
switch (cond_data->cond.WaitTimeout(1))
|
||||
{
|
||||
wxCOND_NO_ERROR: return CELL_OK;
|
||||
wxCOND_TIMEOUT: break;
|
||||
default: return CELL_EPERM;
|
||||
}
|
||||
|
||||
if (counter++ > max_counter)
|
||||
{
|
||||
if (!timeout)
|
||||
{
|
||||
sys_cond.Warning("sys_cond_wait(cond_id=0x%x, timeout=0x%llx): TIMEOUT", cond_id, timeout);
|
||||
counter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CELL_ETIMEDOUT;
|
||||
}
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
int sys_cond_signal(u32 cond_id)
|
||||
|
@ -48,9 +48,28 @@ int sys_mutex_lock(u32 mutex_id, u64 timeout)
|
||||
mutex* mtx_data = nullptr;
|
||||
if(!sys_mtx.CheckId(mutex_id, mtx_data)) return CELL_ESRCH;
|
||||
|
||||
mtx_data->mtx.Lock();
|
||||
u32 counter = 0;
|
||||
const u32 max_counter = timeout ? (timeout / 1000) : 20000;
|
||||
do
|
||||
{
|
||||
if (Emu.IsStopped()) return CELL_ETIMEDOUT;
|
||||
|
||||
return CELL_OK;
|
||||
if (mtx_data->mtx.TryLock() == wxMUTEX_NO_ERROR) return CELL_OK;
|
||||
Sleep(1);
|
||||
|
||||
if (counter++ > max_counter)
|
||||
{
|
||||
if (!timeout)
|
||||
{
|
||||
sys_mtx.Warning("sys_mutex_lock(mutex_id=0x%x, timeout=0x%llx): TIMEOUT", mutex_id, timeout);
|
||||
counter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CELL_ETIMEDOUT;
|
||||
}
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
int sys_mutex_trylock(u32 mutex_id)
|
||||
@ -60,7 +79,7 @@ int sys_mutex_trylock(u32 mutex_id)
|
||||
mutex* mtx_data = nullptr;
|
||||
if(!sys_mtx.CheckId(mutex_id, mtx_data)) return CELL_ESRCH;
|
||||
|
||||
if(mtx_data->mtx.TryLock()) return 1;
|
||||
if (mtx_data->mtx.TryLock() != wxMUTEX_NO_ERROR) return CELL_EBUSY;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ int sys_ppu_thread_restart(u32 thread_id)
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u32 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr)
|
||||
int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u64 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr)
|
||||
{
|
||||
sysPrxForUser.Log("sys_ppu_thread_create(thread_id_addr=0x%x, entry=0x%x, arg=0x%x, prio=%d, stacksize=0x%x, flags=0x%llx, threadname_addr=0x%x('%s'))",
|
||||
thread_id_addr, entry, arg, prio, stacksize, flags, threadname_addr, Memory.ReadString(threadname_addr).mb_str());
|
||||
|
Loading…
Reference in New Issue
Block a user