Purpose
"uspace" is a new implementation of RTAPI which uses userspace POSIX APIs for scheduling. It can be run in a mode which provides access to hardware and realtime scheduling guarantees, or it can be run in a "sim-like" mode.
When used with the RT-PREEMPT kernel, max latency on most hardware is enough for "servo-cycle-only" systems, and in some systems may be good enough for software step generating systems. (latency reports on a small range of systems seem to range from 12us to 90us)
"uspace" is desirable because it allows LinuxCNC to work with a kernel shipped by Debian, and enables new hardware interfaces such as ethernet (mesa 7i80).
The work is mostly being done by JeffEpler, with help from a variety of the usual suspects. Some code is adapted from "unified-build-candidate-3", an ancestor branch of the machinekit project.
Because of the way the machinekit project's git history was structured, it is not possible to merge just their userspace rtapi implementation. That is why JeffEpler chose to make a fresh implementation instead.
Comparison of RTAPI implementations
Name | in version.. | Kernelspace | Realtime guarantee | Hardware Access |
rtai | all linuxcnc | Y | Y | Y |
sim | all linuxcnc | N | N | N |
uspace | linuxcnc branch | N | Y | Y |
|
unified | machinekit | N | Y | Y |
Status
The code works, but is undergoing review and will be rebased at least once more before being merged to master branch. It is in branch jepler/rtos-uspace-apis.
There are two other branches, but they are no longer going to be maintained by JeffEpler:
- branch jepler/rtos-uspace: Change the userspace realtime from pth to pthreads. Provides realtime guarantee under RT-PREEMPT, but no hardware access. Will be merged with rtos-uspace-apis, no longer maintained separately.
- branch jepler/rtos-uspace-hm2-eth: Rebase of micges's hm2-eth / hm2-7i80 branch. Allows hm2_eth to work, but breaks other hm2_xxx drivers. Will not be merged as long as that is the case. Will need to be rebased on master branch once rtos-uspace-apis is merged.
Requirements
In addition to the regular requirements of linuxcnc in sim mode, libudev-dev is required to build, and a -rt kernel is required for realtime scheduling guarantees. libpth-dev is no long required.
All testing to date has been done on Debian 7 "Wheezy" with the 3.2.0-rt-amd64 and 3.2.0-rt-686-pae
kernels. Ubuntu used to offer -rt kernels, but no longer appears to do so.
Getting the code
The code is on git.linuxcnc.org. If you want to try it with a 7i80 card, use branch jepler/rtos-uspace-hm2-eth, otherwise use branch jepler/rtos-uspace-apis.
Configuring and building
./configure --with-realtime=uspace
make
sudo make setuid
If you do not "sudo make setuid", then linuxcnc runs without realtime guarantees and without access to hardware. If you run "sudo make setuid", then linuxcnc runs with access to hardware. If you run "sudo make setuid", and run with a RT-PREEMPT kernel, then linuxcnc runs with access to hardware and with realtime guarantees.
What's missing?
Hardware support
Hardware support: The following drivers are built and tested:
- hal_parport
- serport
- hm2_7i43 (tested with 7i43-4)
- hm2_pci (tested with 5i20, 5i25, 5i22)
- hm2_test
The other PCI drivers will need adaptation to the hostmot2-style PCI driver registration before they work.
Other EPP drivers should only require a small amount of work to adapt.
ISA drivers are probably not worth tinkering with. Any which use memory-mapped I/Os? would require additional API work.
Incomplete driver support will not hold back the merge of this branch.
Improvements in response to review
I have gotten many helpful review comments, and have incorporated most of them into the branch.
Further testing
So far, only a few machines have run this code. If you try this branch, please give feedback, preferably on the developers' mailing list or IRC channel.