I'm writing a custom task scheduler, and I would like to know if there is any way of setting the processor affinity for the current thread on Mono (running on Linux).
For the .NET runtime running on Windows, I've managed to get this to work by following Lenard Gunda's Running .NET threads on selected processor cores article; however, his approach fails on Mono (and Linux) because:
- It requires a P/Invoke call to
GetCurrentThreadId
in theKernel32.dll
library. - The
Process.Threads
property currently returns an empty collection on Mono.
Does anyone please have a workaround for this?