I want to implement the multiple threading in C without using any of the POSIX library. Any help would be appreciated.
Not : Don't use fork() or vfork().
See:
for UNIX like systems.
Also see:
for BSDs and modern UNIXes.
This page gives many examples of barebone implementations using these primitives and more.
You can use atomic instructions to implement the locking primitives (mutex, semaphores).
I also suggest looking at actual implementations of userland thread libraries to get some hints. See this page which gives a list of implementations for Linux.
Finally, you might want to get some information on coroutines and perhaps trampolines, although the later isn't as closely related.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With