第1步:安裝 Eclipse 開發環境 http://www.linuxidc.com/Linux/2012-02/53964.htm
第2步:配置Eclipse 的ARM開發環境 http://www.linuxidc.com/Linux/2012-02/54007.htm
第3步:新建一個過程,配置好環境
敲入下面的代碼
#include <pthread.h>
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
void *create(void *arg)
{
while(1)
{
printf("thread is Running ..... ");
sleep(5);
}
}
void *ReaderThread(void *arg)
{
while(1)
{
sleep(4);
printf("Read ID=\r\n");
}
}
int main(int argc, char *argv[])
{
pthread_t tidp;
int rc1,rc2;
rc1=pthread_create(&tidp,NULL,create,NULL);
if(rc1!=0)
{
printf("pthread_create is not created ... \r\n");
return -1;
}
printf("prthread_create is created... \r\n");
rc2=pthread_create(&tidp,NULL,ReaderThread,NULL);
if(rc2!=0)
{
printf("ReaderThread is not created ... \r\n");
return -1;
}
printf("ReaderThread is created... \r\n");
while(1)
{
printf("System is Runing...\r\n");
sleep(1);
}
return 0;
}
編譯看看效果。