Embedded 版 (精华区)
发信人: vmlinuz (生活将因为你而美丽), 信区: Embedded_system
标 题: Linux as an Embedded Operating System (4)
发信站: 哈工大紫丁香 (2001年06月01日08:39:26 星期五), 转信
Low-level Approach to Real-time Linux
Of more immediate interest than the POSIX-based movement are the efforts to
implement a "hard" real-time Linux, the most promising of which may be the
Real-Time Linux (RT-Linux) project at the New Mexico Institute of Mining and
Technology. Observing that Linux is an operating system designed by desktop
computer users, researchers there concluded it would be fruitless to try to
graft real-time functionality onto an OS designed for timesharing.4 Instead
they implemented a simple real-time kernel underneath the operating system,
with Linux itself running as just one task within that kernel. Linux runs at
the lowest priority, and it can be preempted at any time by higher-priority
tasks.
The design philosophy behind RT-Linux was to minimize the changes made to
Linux itself, providing only the essentials necessary for implementing real-
time applications.5 Minimizing the disruption to Linux makes it easy to port
RT-Linux to new versions of Linux as they appear. As a result, RT-Linux
relies on Linux itself to provide almost all services needed, with RT-Linux
providing only low-level task creation, installation of interrupt service
routines, and queues for communication among the low-level tasks, ISRs,
and Linux processes.
One result of this design is that an RT-Linux application can be thought of
as having two domains-the real-time and the non-real-time. Functions placed
in the real-time domain can meet their real-time requirements, but they must
be simple because the resources available to them are quite limited. On the
other hand, non-real-time functionality has the full range of Linux
resources available for use, but cannot have any real-time requirements.
Facilities for communication between the two domains are provided. But
before using RT-Linux, an embedded system designer has to be sure that
all of the needed functionality could fit into one of the two domains.
Using RT-Linux does not magically make pre-existing Linux functionality
real-time. Suppose, for example, a designer has a Linux driver for a serial
port, and wants to toggle a parallel output line (using a real-time task)
within some fixed time after receiving a byte sequence on the serial
port. The Linux serial driver can't be used because it resides in the
non-real-time domain, and you can't predict when the serial
driver would awaken the real-time task driving the parallel output line to
perform its work. Thus, both the serial and the parallel ports would have
to be done in the real-time domain, which would require redesigning
the serial driver.
The RT-Linux facilities for task handling are basic. There is rt_task_init()
, which creates and starts a task. The stack size and priority can be
specified. Linux itself is run as a real-time task with the lowest priority.
The task is set up to run at periodic intervals by rt_task_make_periodic().
The rt_task_wait() facility blocks the calling task. The tasks are run using
a simple preemptive scheduler.
The primary means of communication between
the real-time tasks and the Linux processes is the FIFO. The rtf_create()
facility creates a FIFO of a desired size. Data is enqueued onto the FIFO by
rtf_put(), returning an error if the FIFO is full. Similarly, rtf_get()
dequeues data from the FIFO, returning an error if the FIFO is empty.
The most obvious use for this FIFO scheme is data streaming. In a data
acquisition application, for example, a real-time task could be set up
using rt_task_init() and rt_task_make_periodic() to acquire samples from an
I/O board at fixed intervals. This task would send its data to a Linux
process using rtf_put(). The Linux process would be in a loop, reading data
from the FIFO and perhaps writing the data to disk,sending it over a network,
or displaying it in an X window. The FIFO would serve as a buffer, so the
Linux process could operate without real-time constraints.
(TO BE CONTINUED)
--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: mtlab4.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.157毫秒