2 ms·
As others have already mentioned, the main culprit here is libc and its assumption that it is running in a single-threaded environment. The libc was designed w
by bheadmaster 2y ago
As others have already mentioned, the main culprit here is libc and its assumption that it is running in a single-threaded environment.
The libc was designed with heavy use of global variables in mind. Modules in C are designed as compilation units with static global variables and exposed functions that operate on them.
There's a reason many big projects (and programmers) use their own version of the standard library instead of libc.
- ykonstant 2y agoAre there any good, instructive open source examples of custom libc replacements you could link? Especially ones that circumvent the single-threaded assumption of libc; I'd love to use the code to educate myself.
- sn9 2y agomusl is one of the better ones [0]. None other than John Regehr recommends studying it [1]. [0] https://en.wikipedia.org/wiki/Musl https://en.wikipedia.org/wiki/Musl [1] https://blog.regehr.org/archives/1393 https://blog.regehr.org/archives/1393