1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-01-26 00:35:31 +00:00

LV2: Avoid using multi-variable atomic waiting on cpu_thread::state wait

This commit is contained in:
Eladash 2022-09-20 11:47:05 +03:00 committed by Ivan
parent 2a00a88e2a
commit d25d1ecb3a
16 changed files with 31 additions and 24 deletions

@ -588,7 +588,7 @@ void cpu_thread::operator()()
continue;
}
thread_ctrl::wait_on(state, state0);
state.wait(state0);
if (state & cpu_flag::ret && state.test_and_reset(cpu_flag::ret))
{
@ -640,7 +640,7 @@ cpu_thread::cpu_thread(u32 id)
void cpu_thread::cpu_wait(bs_t<cpu_flag> old)
{
thread_ctrl::wait_on(state, old);
state.wait(old);
}
static atomic_t<u32> s_dummy_atomic = 0;

@ -245,7 +245,7 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString,
break;
}
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
if (is_blocking)

@ -1641,7 +1641,10 @@ void spu_thread::cleanup()
vm::free_range_lock(range_lock);
// Signal the debugger about the termination
state += cpu_flag::exit;
if (!state.test_and_set(cpu_flag::exit))
{
state.notify_one();
}
}
spu_thread::~spu_thread()

@ -1605,9 +1605,13 @@ void lv2_obj::schedule_all(u64 current_time)
if (target->state & cpu_flag::suspend)
{
ppu_log.trace("schedule(): %s", target->id);
target->state.atomic_op(FN(x += cpu_flag::signal, x -= cpu_flag::suspend));
target->start_time = 0;
if ((target->state.fetch_op(FN(x += cpu_flag::signal, x -= cpu_flag::suspend, void())) & (cpu_flag::wait + cpu_flag::signal)) != cpu_flag::wait)
{
continue;
}
if (notify_later_idx == std::size(g_to_notify))
{
// Out of notification slots, notify locally (resizable container is not worth it)

@ -452,7 +452,7 @@ error_code sys_cond_wait(ppu_thread& ppu, u32 cond_id, u64 timeout)
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -524,7 +524,7 @@ error_code sys_event_queue_receive(ppu_thread& ppu, u32 equeue_id, vm::ptr<sys_e
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -250,7 +250,7 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -487,7 +487,7 @@ error_code _sys_lwcond_queue_wait(ppu_thread& ppu, u32 lwcond_id, u32 lwmutex_id
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -247,7 +247,7 @@ error_code _sys_lwmutex_lock(ppu_thread& ppu, u32 lwmutex_id, u64 timeout)
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -256,7 +256,7 @@ error_code sys_mutex_lock(ppu_thread& ppu, u32 mutex_id, u64 timeout)
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -415,7 +415,7 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr>
break;
}
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
if (ppu.gpr[3] == static_cast<u64>(-SYS_NET_EINTR))
@ -579,7 +579,7 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
break;
}
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
if (ppu.gpr[3] == static_cast<u64>(-SYS_NET_EINTR))
@ -859,7 +859,7 @@ error_code sys_net_bnet_recvfrom(ppu_thread& ppu, s32 s, vm::ptr<void> buf, u32
break;
}
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
if (ppu.gpr[3] == static_cast<u64>(-SYS_NET_EINTR))
@ -1053,7 +1053,7 @@ error_code sys_net_bnet_sendto(ppu_thread& ppu, s32 s, vm::cptr<void> buf, u32 l
{
break;
}
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
if (ppu.gpr[3] == static_cast<u64>(-SYS_NET_EINTR))
@ -1408,7 +1408,7 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}
@ -1648,7 +1648,7 @@ error_code sys_net_bnet_select(ppu_thread& ppu, s32 nfds, vm::ptr<sys_net_fd_set
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -360,7 +360,7 @@ void _sys_process_exit(ppu_thread& ppu, s32 status, u32 arg2, u32 arg3)
break;
}
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}
@ -472,7 +472,7 @@ void _sys_process_exit2(ppu_thread& ppu, s32 status, vm::ptr<sys_exit2_param> ar
break;
}
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -209,7 +209,7 @@ error_code sys_rwlock_rlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout)
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}
@ -472,7 +472,7 @@ error_code sys_rwlock_wlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout)
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -213,7 +213,7 @@ error_code sys_semaphore_wait(ppu_thread& ppu, u32 sem_id, u64 timeout)
}
else
{
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}

@ -1493,7 +1493,7 @@ error_code sys_spu_thread_group_join(ppu_thread& ppu, u32 id, vm::ptr<u32> cause
break;
}
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
}
while (false);

@ -891,7 +891,7 @@ error_code sys_usbd_receive_event(ppu_thread& ppu, u32 handle, vm::ptr<u64> arg1
break;
}
thread_ctrl::wait_on(ppu.state, state);
ppu.state.wait(state);
}
ppu.check_state();