Download Development of a Linux Driver for a MOST Interface and Porting to

Transcript
6.3.2.2 Synchronisation of Real-Time with Non Real-Time
With one exception, real-time and non real-time are decoupled in such a way that the real-time
part must not wait until the non real-time part finishes some action. However, the two ioctl calls
to setup RX and TX require that the driver is not inside a read or write function call respectively
because the reception/transmission is stopped to set it up again.
So, this means that if the non real-time part is in the MOST_SYNC_RT_SETUP_RX and the real-time
part issues a read(), the real-time part has to wait. In this period of time, the real-time condition is
violated.
However, this is not a consequence of the implementation but of the way the hardware works.
Changing the number of received or transmitted buffers requires setting up receiving or transmitting
completely new because of the allocation of a new DMA buffer [63, page 33].
The solution is to synchronise the real-time tasks that use the MOST device: Hard real-time can be
guaranteed after each task has setup his reception and receiving process.
6.4 Sample Applications
The sample application is illustrated together with the driver in figure 6.1 on page 126. The NetServices part is taken from the Linux sample application without any changes.
There are two different sample applications: one for receiving and another for sending synchronous
data. Both applications perform NetServices handling, so it’s not possible to run them on the same
PCI interface. The reason is because the NetServices device file provided by the Linux driver can be
opened only once at the same time. However, using two interfaces in one computer, one for sending,
the other for receiving, is possible.
LXRT is used for simplicity: It’s easier to have one program with more than one thread than two
different programs, one real-time task in the kernel and the other in the userspace. Also, LXRT tasks
are have memory protection against other tasks.
There are three threads in these applications:
1. the real-time thread that operates with the RTDM device;
2. the NetServices thread created by the NetServices library that handles NetServices events and
3. the Linux thread that consumes/produces the data.
The last thread is created because it’s not possible to access the file system in real-time.
The applications together with build instructions and a Makefile can be found in the /development/
most-driver/drivertest/sync-rt-tx/ and /development/most-driver/drivertest/sync-rt-rx/ subdirectory
on the CD.
130
Chapter 6 RTAI Driver for MOST