Example #1
0
s32 sys_ppu_thread_get_priority(u64 thread_id, u32 prio_addr)
{
	sys_ppu_thread.Log("sys_ppu_thread_get_priority(thread_id=%lld, prio_addr=0x%x)", thread_id, prio_addr);

	CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
	if(!thr) return CELL_ESRCH;

	Memory.Write32(prio_addr, (s32)thr->GetPrio());

	return CELL_OK;
}
Example #2
0
s32 sys_ppu_thread_get_priority(u64 thread_id, u32 prio_addr)
{
	sysPrxForUser->Log("sys_ppu_thread_get_priority(thread_id=%lld, prio_addr=0x%x)", thread_id, prio_addr);

	CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
	if(!thr) return CELL_ESRCH;
	if(!Memory.IsGoodAddr(prio_addr)) return CELL_EFAULT;

	Memory.Write32(prio_addr, thr->GetPrio());

	return CELL_OK;
}
Example #3
0
u32 SleepQueue::pop_prio() // SYS_SYNC_PRIORITY
{
	std::lock_guard<std::mutex> lock(m_mutex);

	while (true)
	{
		if (list.size())
		{
			u32 highest_prio = ~0;
			u32 sel = 0;
			for (u32 i = 0; i < list.size(); i++)
			{
				CPUThread* t = Emu.GetCPU().GetThread(list[i]);
				if (!t)
				{
					list[i] = 0;
					sel = i;
					break;
				}
				u64 prio = t->GetPrio();
				if (prio < highest_prio)
				{
					highest_prio = prio;
					sel = i;
				}
			}
			u32 res = list[sel];
			list.erase(list.begin() + sel);
			/* if (Emu.GetIdManager().CheckID(res)) */
			if (res)
			// check thread
			{
				return res;
			}
		}
		return 0;
	}
}