chaos4ever / chaos

The chaos Operating System
https://chaos4ever.github.io/
15 stars 6 forks source link

[storm] Refactor IPC to use circular queue #153

Closed perlun closed 4 years ago

perlun commented 4 years ago

This was a rather complex change which was discussed with @doverhill on Slack a bit. Because our memory allocation tend to degenerate over time, we looked into other ways of handling the IPC than the previous approach (which would incur a memory allocation and deallocation for every single message being posted via the IPC mechanism)

The new approach uses a circular queue, which was written in an isolated and reusable way, completely separate from the mailbox code. This means that mailbox_send and mailbox_receive got a whole lot more readable in the process, as an added bonus.

The implementation was greatly helped by the fact that we could unit test the circular queue in isolation, in VS Code on Linux (with full gdb debugger support). This was an incredible help in getting this done with a reasonable level of effort. The library used for writing the tests is cmocka.

Kernel development has never felt this "easy" before, relatively speaking. I still ran into a bug (in mailbox_receive) but it was literally a 10-minute fix. After it was done, the system would boot up correctly again, which felt really nice.

perlun commented 4 years ago

Merging this now since no-one has yet complained about any parts of it. :stuck_out_tongue_winking_eye: @doverhill If you find anything, please let me know and I'll fix it post-merge.