打印本文 打印本文 关闭窗口 关闭窗口
Linux嵌入式实时操作系统开发与设计(七)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数5527  更新时间:2009/4/22 20:45:21  文章录入:mintao  责任编辑:mintao
thread_status = pthread_create (&thread,  &attr, thread_code, (void *)1);

if (thread_status != 0) {

      rtl_printf("failed to create RT-thread: %d\n", thread_status);

      return -1;

} else {

      rtl_printf("created RT-thread\n");

}

 

if (bperiod) {

      pthread_create (&background_threadid,  NULL, background_thread, NULL);

}

return 0;

}

 

 

void cleanup_module(void)

{

        rtl_printf ("Removing module on CPU %d\n", rtl_getcpuid());

pthread_cancel (thread);

pthread_join (thread, NULL);

close(fd_fifo);

rtf_destroy(0);

if (bperiod) {

      pthread_cancel (background_threadid);

      pthread_join (background_threadid, NULL);

}

}

 

4.3.2  非实时部分

    非实时部分实际上建行就是一个应用程序,可以在控制台下编写。不过必须有/dev/rtf0设备的读取权限才能运行。

#include <stdio.h>

#include <errno.h>

#include <sys/time.h>

#include <sys/types.h>

#include <fcntl.h>

#include <unistd.h>

#include <sys/ioctl.h>

#include <rtl_fifo.h>

#include "common.h"

 

 

 

int main()

{

int fd0;

int n;

上一页  [1] [2] [3] [4] [5] [6] [7] [8]  下一页

打印本文 打印本文 关闭窗口 关闭窗口