The term to search for prior art is user-mode scheduler / scheduling. Basically you add additional kernel features that allow making some scheduling decisions in the application, it's not something you'd just build on a vanilla pthreads implementation.
Examples:
Windows 7 UMS: https://learn.microsoft.com/en-us/windows/win32/procthread/u...
google3 fibers / switchto: https://www.youtube.com/watch?v=KXuZi9aeGTw