手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

在Ubuntu下用Eclipse开发ARM多线程程序

[日期:2012-02-12] 来源:Linux社区  作者:ex_net [字体:大 中 小]

第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;
}

编译看看效果。

在Ubuntu下用Eclipse开发ARM多线程程序

linux
相关资讯       Eclipse  arm  Ubuntu安装教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款