mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 04:32:35 +01:00
Implement thread_ctrl::scoped_priority
RAII priority control (+1, or -1)
This commit is contained in:
parent
a69248299d
commit
ee288340b0
@ -281,6 +281,24 @@ public:
|
|||||||
// Get current thread stack addr and size
|
// Get current thread stack addr and size
|
||||||
static std::pair<void*, usz> get_thread_stack();
|
static std::pair<void*, usz> get_thread_stack();
|
||||||
|
|
||||||
|
// Sets the native thread priority and returns it to zero at destructor
|
||||||
|
struct scoped_priority
|
||||||
|
{
|
||||||
|
explicit scoped_priority(int prio)
|
||||||
|
{
|
||||||
|
set_native_priority(prio);
|
||||||
|
}
|
||||||
|
|
||||||
|
scoped_priority(const scoped_priority&) = delete;
|
||||||
|
|
||||||
|
scoped_priority& operator=(const scoped_priority&) = delete;
|
||||||
|
|
||||||
|
~scoped_priority()
|
||||||
|
{
|
||||||
|
set_native_priority(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
static const u64 process_affinity_mask;
|
static const u64 process_affinity_mask;
|
||||||
|
@ -600,7 +600,7 @@ void cell_audio_thread::update_config()
|
|||||||
|
|
||||||
void cell_audio_thread::operator()()
|
void cell_audio_thread::operator()()
|
||||||
{
|
{
|
||||||
thread_ctrl::set_native_priority(1);
|
thread_ctrl::scoped_priority high_prio(+1);
|
||||||
|
|
||||||
// Allocate ringbuffer
|
// Allocate ringbuffer
|
||||||
ringbuffer.reset(new audio_ringbuffer(cfg));
|
ringbuffer.reset(new audio_ringbuffer(cfg));
|
||||||
|
@ -2358,7 +2358,7 @@ extern void ppu_initialize(const ppu_module& info)
|
|||||||
named_thread_group threads(fmt::format("PPUW.%u.", ++g_fxo->get<thread_index_allocator>()->index), thread_count, [&]()
|
named_thread_group threads(fmt::format("PPUW.%u.", ++g_fxo->get<thread_index_allocator>()->index), thread_count, [&]()
|
||||||
{
|
{
|
||||||
// Set low priority
|
// Set low priority
|
||||||
thread_ctrl::set_native_priority(-1);
|
thread_ctrl::scoped_priority low_prio(-1);
|
||||||
|
|
||||||
for (u32 i = work_cv++; i < workload.size(); i = work_cv++)
|
for (u32 i = work_cv++; i < workload.size(); i = work_cv++)
|
||||||
{
|
{
|
||||||
|
@ -434,7 +434,7 @@ void spu_cache::initialize()
|
|||||||
named_thread_group workers("SPU Worker ", worker_count, [&]() -> uint
|
named_thread_group workers("SPU Worker ", worker_count, [&]() -> uint
|
||||||
{
|
{
|
||||||
// Set low priority
|
// Set low priority
|
||||||
thread_ctrl::set_native_priority(-1);
|
thread_ctrl::scoped_priority low_prio(-1);
|
||||||
|
|
||||||
// Initialize compiler instances for parallel compilation
|
// Initialize compiler instances for parallel compilation
|
||||||
std::unique_ptr<spu_recompiler_base> compiler;
|
std::unique_ptr<spu_recompiler_base> compiler;
|
||||||
@ -521,9 +521,6 @@ void spu_cache::initialize()
|
|||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore default priority
|
|
||||||
thread_ctrl::set_native_priority(0);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -618,7 +618,7 @@ namespace rsx
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Raise priority above other threads
|
// Raise priority above other threads
|
||||||
thread_ctrl::set_native_priority(1);
|
thread_ctrl::scoped_priority high_prio(+1);
|
||||||
|
|
||||||
if (g_cfg.core.thread_scheduler_enabled)
|
if (g_cfg.core.thread_scheduler_enabled)
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ render_creator::render_creator(QObject *parent) : QObject(parent)
|
|||||||
|
|
||||||
std::thread enum_thread = std::thread([&]
|
std::thread enum_thread = std::thread([&]
|
||||||
{
|
{
|
||||||
thread_ctrl::set_native_priority(-1);
|
thread_ctrl::scoped_priority low_prio(-1);
|
||||||
|
|
||||||
vk::instance device_enum_context;
|
vk::instance device_enum_context;
|
||||||
if (device_enum_context.create("RPCS3", true))
|
if (device_enum_context.create("RPCS3", true))
|
||||||
|
@ -421,7 +421,7 @@ logs::file_writer::file_writer(const std::string& name, u64 max_size)
|
|||||||
|
|
||||||
m_writer = std::thread([this]()
|
m_writer = std::thread([this]()
|
||||||
{
|
{
|
||||||
thread_ctrl::set_native_priority(-1);
|
thread_ctrl::scoped_priority low_prio(-1);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user