NuxiNL/cloudlibc

Inject custom clocks, RNG's

mcandre opened this issue · 2 comments

I saw the awesome talk on CloudABI and think it would be a good idea to begin offering dependency injection for the system clock and for random number generation, for even richer application tests. Could we begin designing an API towards that end?

Couple of things we need to take into consideration when designing such APIs:

  • Making PRNGs injectable shouldn't be too hard. We could simply model PRNGs as pipes from which you can read data. There is no need to add any special kernel primitives for that. We do need to keep in mind that PRNGs are already used at a very early stage, namely to set up stack smashing protection (SSP). The random seed is currently passed in through the auxiliary vector (AT_CANARY + AT_CANARYLEN). Do we want to keep AT_CANARY? If so, should it be seeded by the PRNG? Or should we change crt0 to read from the PRNG on process startup?
  • Injecting clocks is an interesting one. It's not just that a clock is read, processes may also sleep on them. And in the case of polling frameworks, sleep may be interrupted. What would the API look like from an implementation side? Do we want the implementation to get insight in the full list of threads that are waiting, or should it only communicate information about the first thread that needs to be woken up?

yes