- Author
- Not stated (a Fil-C documentation page, written in the first person)
- Published
- Undated
- Kind
- Project design document
- Original
- fil-c.org/context_switches
- Subject
- Systems and hardware
What it is
The page documents how Fil-C, a memory-safe C implementation, supports context switching. It covers setjmp, longjmp and the ucontext functions.
What it says
- The page says Fil-C supports setjmp, longjmp and ucontext without allowing stack corruption.
- The page explains that setjmp saves registers, not the stack, so late jumps fail.
- In Fil-C, jmp_buf points to an opaque object, and longjmp panics from unrelated frames.
- Fil-C ignores the user's stack pointer for makecontext and allocates its own hidden stack.
- Each fiber context follows a restricted state machine and stays on its creating thread.
- The page says the collector tracks grey fibers so their stacks are rescanned.
- The ucontext support is new in version 0.681 and only in the glibc build.
What evidence it gives
The document gives code examples, an assembly listing, a state machine and a collector scenario. It reports results from gcc 11.4.0 and clang 14.0.0 on one example.
Interests and limits
The project describes its own work. No tests or performance figures appear. The text itself says that bugs would most likely be in two named places. Correctness is argued, not proven.