供了三种通信方法。
3.6.1 FIFO设备
RTLinux用FIFO管道来在Linux进程或者Linux内核与实时进程间传递数据,这种管道称为实时管道(real-time FIFOs),以区别UNIX IPC机制中的管道。
RT-FIFO管道是在内核地址空间的。通过一个整数来引用。RT-FIFOs的数目在编译系统时给定,可以重新编译系统改变大小。
操作RT-FIFOs的函数包括创建、删除、读FIFO和写FIFO。读写操作是原子操作,不能中断。不可中断是为了避免优先级倒置问题。
在Linux进程中,把RT-FIFOs当作普通的字符设备,而不是一个系统调用。字符设备给用户一个与实时任务通信的全功能的应用程序接口(API)。这个接口对Linux进程来说是标准的设备接口,包括:open, close, read和write。
struct file_operations rtf_fops
static struct file_operations rtf_fops =
{
rtf_llseek,
rtf_read,
rtf_write,
NULL,
rtf_poll,
NULL,
NULL,
rtf_open,
NULL,
rtf_release,
NULL,
NULL,
NULL,
NULL,
NULL
};
下面是原始的存取例程:
int rtf_create(unsigned int minor, int size)
int rtf_destroy(unsigned int minor)
int rtf_put(unsigned int minor, void *buf, int count)
int rtf_get(unsigned int minor, void *buf, int count)
对于每个FIFO管道可以通过
int rtf_create_handler(unsigned int minor,
int (*handler) (unsigned i 上一页 [1] [2] [3] [4] 下一页 没有相关教程
|