|
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] 下一页 没有相关教程
|