80,349
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <pthread.h>
namespace android{
void* f2(void *cookie){
return NULL;
}
void* f1(void *cookie){
return NULL;
};
void test(){
int i = 0;
void *c = NULL;
while(1){
pthread_t p1;
pthread_t p2;
printf("p1 return :%d\n",pthread_create(&p1,NULL,f1,c));
printf("p2 return :%d\n",pthread_create(&p2,NULL,f2,c));
pthread_join(p2,NULL);
pthread_join(p1,NULL);
printf("i:%d\n",i++);
}
}
}
using namespace android;
int main(int argc,char *argv[])
{
test();
return 0;
}
make file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := hello
LOCAL_SRC_FILES := \
hello03.cpp
LOCAL_LDLIBS := -llog -lutils -lz -ldl -lgcc
LOCAL_CFLAGS += -DLINKER_DEBUG=1 -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
LOCAL_C_INCLUDES += system/core/include/cutils
LOCAL_SHARED_LIBRARIES := libutils
include $(BUILD_EXECUTABLE)
错误信息
(gdb) bt
#0 __get_tls () at bionic/libc/arch-x86/bionic/__get_tls.c:35
#1 0xf7f784b7 in __get_thread () at bionic/libc/bionic/pthread.c:163
#2 0xf7f79969 in pthread_exit (retval=0x0) at bionic/libc/bionic/pthread.c:570
#3 0xf7f79bda in __thread_entry (func=0x80489e0 <android::f1(void*)>, arg=0x804b148, tls=0x100fff00)
at bionic/libc/bionic/pthread.c:217
#4 0x00000000 in ?? ()