如何使用C线程,而无需使用POSIX库< pthreads.h中> [英] How to make thread in C without using POSIX library <pthread.h>

查看:150
本文介绍了如何使用C线程,而无需使用POSIX库< pthreads.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:

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆