如何使用C线程,而无需使用POSIX库&LT; pthreads.h中&GT; [英] How to make thread in C without using POSIX library <pthread.h>
问题描述
我想要实现在C多线程不使用任何的POSIX库。
任何帮助将是AP preciated。
不:不要使用fork()或vfork的()
请参阅:
对于UNIX类系统。</ P>
另请参见:
有关BSD系统和现代化的UNIX系统。
这页面给出了使用这些原语和更多的准系统实现的例子很多。
您可以使用原子指令来实现锁定原语(互斥体,信号灯)。
我也建议看用户级线程库的实际实现来获得一些提示。请参见此页面这给了Linux实现的列表。
最后,您可能想获得协同程序也许的蹦床,虽然后来没有作为密切相关的。
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:
- getcontext and setcontext,
- and more generally ucontext
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.
这篇关于如何使用C线程,而无需使用POSIX库&LT; pthreads.h中&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!