top | item 17147834

Show HN: Faster Fibers using Threads

4 points| bgongfu | 7 years ago |github.com

3 comments

order

wahern|7 years ago

It's a shame this experimental Google proposal for userspace thread scheduling never got picked up: https://blog.linuxplumbersconf.org/2013/ocw/system/presentat...

The basic API (see page 17) consisted of:

  pid_t switchto_wait(timespec *timeout)
  - Enter an 'unscheduled state', until our control is
  reinitiated by another thread or external event (signal).

  void switchto_resume(pid_t tid)
  - Resume regular execution of tid

  pid_t switchto_switch(pid_t tid)
  - Synchronously transfer control to target sibling
  thread, leaving the current thread unscheduled.
The key abstraction is switchto_switch, which explicitly transfers control to another thread, leaving the current thread quiescent. It's analogous to setcontext(3) or longjmp(3).

bgongfu|7 years ago

While I'm all for more options, and against deprecating commonly used functionality; the results I'm getting say that first class context switching support isn't really as important as we like to pretend.