mirror of
https://github.com/thewesker/RASCSI.git
synced 2025-12-23 13:51:09 -05:00
#16 Lots more refactoring.... doesn't work anymore... work in progress
This commit is contained in:
28
src/raspberrypi/os.cpp
Normal file
28
src/raspberrypi/os.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "os.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Pin the thread to a specific CPU
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void FixCpu(int cpu)
|
||||
{
|
||||
#ifndef BAREMETAL
|
||||
cpu_set_t cpuset;
|
||||
int cpus;
|
||||
|
||||
// Get the number of CPUs
|
||||
CPU_ZERO(&cpuset);
|
||||
sched_getaffinity(0, sizeof(cpu_set_t), &cpuset);
|
||||
cpus = CPU_COUNT(&cpuset);
|
||||
|
||||
// Set the thread affinity
|
||||
if (cpu < cpus) {
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(cpu, &cpuset);
|
||||
sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
|
||||
}
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user