Chinaunix

标题: help pthread_tryjoin_np函数 [打印本页]

作者: 79hy    时间: 2009-04-10 12:05
标题: help pthread_tryjoin_np函数
我在ubuntu上调试程序,内核比较新,线程库中有pthread_tryjoin_np函数。但是实际环境是FC2:
内核是2.6.17, gcc (GCC) 3.3.3

线程库是:
/lib/tls/libpthread.so.0
NPTL 0.61 by Ulrich Drepper
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Forced unwind support include

编译程序:
gcc -Wall -g -std=c99 -D_GNU_SOURCE -pthread -c *.c

程序如下:

@:~$ cat 1.c
#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void fun()
{
    printf("aaaaa\n");
    sleep(10);
}
int
main()
{
// int pthread_create(pthread_t * thread, pthread_attr_t * attr, void * (*start_routine)(void *), void * arg);

//extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;

    pthread_t pid;
    printf("create\n");
    pthread_create(&pid, NULL, (void *)fun, NULL);

    int i;
    i=pthread_tryjoin_np(pid, NULL);
    printf("i = %d \n", i);

    exit(0);
}




有解决方案吗?

能不能升级一下线程库,只升级线程库,别升级glibc,那样动作太大。谢谢各位,在线等。。。

[ 本帖最后由 79hy 于 2009-6-10 10:34 编辑 ]
作者: 雨过白鹭洲    时间: 2009-04-10 12:08
pthread_tryjoin_np
作者: astezheng    时间: 2009-04-10 19:21
标题: 回复 #1 79hy 的帖子
我的系统上是好的,你仔细查一下你的线程库,是不是版本太低导致的,那是一个链接错,编译过了,说明你已经把那个函数的声明打开了




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2