periph
periph copied to clipboard
cpu: Add Realtime() function
This function would:
- Call runtime.LockOSThread()
- Call pthread_setschedparam() to set the scheduling priority value to very high priority for the thread locked goroutine.
In practice, the only way to unlock the goroutine would be to exit. This would safeguard against various potential issues and would force users to have correctly designed concurrency. A protection should also be applied to disallow its use on single-core system.
As a fallback, it could increase the whole process priority, e.g. syscall.SetPriority(syscall.PRIO_PROCESS, 0, -20) with an actual reasonable value to be determined.
Note: I'm still ambivalent about the above, if it belongs in the library at all but it is relevant enough for the use cases to make sense.