confstr()函数判断线程程序库类型

《构建嵌入式Linux系统》第四章提到线程的使用,线程库在2.6内核之前都是 LinuxThreads 库,而新内核开始使用 New POSIX Threading Library(简称 NPTL)。
在选择内核版本时需要考虑线程的应用程度,选择适合的内核版本;以下代码用于判断线程库类型,在我机器上的执行结果是 Pthreads lib is NPTL 2.17

#define _XOPEN_SOURCE

#include <unistd.h>
#include <stdio.h>

int main(void)
{
        char    name[128];
        confstr(_CS_GNU_LIBPTHREAD_VERSION, name, sizeof(name));
        printf("Pthreads lib is %s\n", name);
        return 0;
}
Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.