RTLinux with PTB

I'm trying to use RTLinux with PTB, as per Mario's suggestions in the ECVP 2010 poster. I first installed 10.10 Ubuntu, but I learned it doesn't have an easy way to setup/install RTLinux. I installed 10.04 instead, which works with a simple "sudo apt-get install linux-rt"

Also, you need to use the SHIFT key to get the boot manager to show up when Ubuntu boots, so you can run the linux-rt kernel.

I installed the 64-bit version of Ubunto, and I installed MATLAB 2010a (both 64-bit and 32-bit versions). However, I just read from Mathworks they don't support running 32-bit MATLAB on a 64-bit UNIX platform:

http://www.mathworks.com/support/solutions/en/data/1-1CAT7/index.html

So I guess this is just a question for Mario, but did you use 32-bit Ubuntu in your testing with RTLinux?

Thanks,
Matt
--- In psychtoolbox@yahoogroups.com, "IanA" <iandol@...> wrote:
>
> --- In psychtoolbox@yahoogroups.com, "Mario" <mario.kleiner@> wrote:
> > The 64-bit ptb's for Windows or OS/X are still far away, in case anybody wonders. Linux is by a large margin the most pleasant os for doing 64 bit ports, basically an almost painfree, straightforward endevaour. The other systems are quite the opposite, so Windows is probably still many months away and i wouldn't expect a 64 bit os/x version before the end of 2011 (optimistic guess).
>
> Would being able to build on a newer OS X install make a difference. I tried building Screen myself, but there were many warnings and errors, and I realise I don't have the same dylibs you have which appear to be dependencies. But I wondered if a 10.6 + XCode environment could make this easier? Or are the problems deeper than just building universal binaries...

No, the problems are as deep as they can get as far as a 64 bit port is the goal. I'll need to rewrite large parts of the OS/X specific code from scratch. Or find some other ways to avoid that, which is mostly my plan. Apple made sure that their 64 bit api's are as backwards incompatible as possible to their 32 bit api's, so they can force each developer to throw away large parts of well working code and learn a new programming language that nobody outside apple ever cared about in order to incompletely restore functionality by use of new api's nobody wanted. But hey, it's 64 bit and 64 bit is good and Apple thinks different than the rest of the slightly more sane software development world. And who would disagree? After all, os/x is the worlds most advanced operating system [according to Apple], so it must be good and Steve knows what's good for you.

This brain-damage is also the reason why it took Adobe forever to provide 64 bit apps for Mac and why MS-Office is still 32 bit only on Mac.

Things that won't work at all on 64 bit and need to be rewritten from scratch

* All setup/management code for windowed onscreen windows and anything that interacts with the desktop window manager.

* Everything related to mouse queries and handling.

* Everything Quicktime: Videocapture, video recording, movie creation and movie playback.

* Everything related to font handling and text rendering.

* All kinds of other more tiny bits. And all the stuff i'm not aware of yet.

Incidentally these are also the parts which took the most time of tinkering, debugging, testing and refinement to get right - the most painful bits to reimplement. All these subsystems, which matured sometimes over 10-20 years in Apple's operating systems and still contained many bugs have been replaced by relatively new and relatively immature technology.

I'll probably be able to bypass reimplementation of some of these bits by reusing api's and functionality that comes from Linux but has been ported to os/x. E.g., the Linux based font handling and text rendering has been ported and is implemented in the os/x ptb as an option. Quality and speed of the Linux text renderer are as good or better than the os/x renderer, but some of the more exotic parameters are ignored on the linux renderer, and text appearance will be slightly different. If you just want good looking text, no problem. If you are into very precise text rendering, your stimuli will be different between the 32 bit ptb and the 64 bit version.

The Quicktime engine i will likely scrap completely. The GStreamer framework from Linux works already very well on Linux and pretty ok on Windows for the tasks Quicktime did. I'll try to use that on os/x as well, so we get rid on these dependencies on Apple technology as much as possible.

The rest is unclear. In theory one could (ab)use/recycle the X-Windows window management code from Linux on OS/X as well, as OS/X has X-Windows system support. But Apple being the unpredictable company it is and Mathworks being Mathworks, who knows if X11 isn't the next thing they will remove because Steve changed his mind about what's good for you? Also their X-Windows layer is much less capable than the Linux counterpart.

The os/x port is a big undertaking with many known problems and probably also a couple of unknown problems. My conclusion is that in the future we shouldn't rely on a company that shows such unpredictable and unfriendly behaviour towards developers. Getting rid of as many os/x specific technology as possible is the plan, replacing it with cross-platform code as much as possible. I probably won't even start looking into this until "Lion" is released and i'll have much more time. I'm sure Apple will add some unpleasant and brain-damaged surprises to that system as well for a bit of extra entertainment.


On MS-Windows i don't expect such severe problems, just the usual pain of dependency hell that is associated with doing anything on that platform. Microsoft has many faults, but at least they know that it is important to not intentionally piss off their developers.

On Linux, the Linux specific part of porting was done in less than four hours: Reading through code to confirm it already does the right thing and fixing less than 10 lines of code. The rest is automagic, to cite Apple, "It just works(tm)".

All the rest of time (about two weekends of work) was spent checking and fixing our own operating system independent core code. This is now mostly done and doesn't need to be repeated for the other systems.

But thanks for asking, shared pain is only half the pain.
-mario
--- In psychtoolbox@yahoogroups.com, Jochen Laubrock <laubrock@...> wrote:
>
> On Apr 8, 2011, at 22:38 , Mario wrote:
>
> > Oh i also forgot that nobody looked into PsychHID, so keyboard, mouse and most other i/o devices may be dead as well, or not, who knows? At that point even a crippled ptb would probably become pointless.
>
> I'm afraid PsychHID won't work, either. HID utilities have been replaced by HID Manager (see, e.g., HID Class Device Interface Guide; IOKit.framework).

Great! They don't even manage to stay backwards compatible to something they introduced only a few years ago as the best way to do things? How sad is that? If it were really old OS-9 cruft, ok, but this??

Anyway, Linux probably to the rescue again. libusb and libhid were originally developed for Linux to provide such functionality and have been mostly ported to Windows and OS/X. We use libusb already on all platforms for the Kinect and Datapixx drivers. I guess we'll try to use those as a common implementation for PsychHID on all operating systems. I don't want to use another shiny new Apple technology which gets killed after a couple of years.

This means a rewrite of PsychHID in large parts. At least we may finally get a PsychHID that works on Windows and Linux as well this way.


> Part of the functionality of the Quicktime Framework has been replaced by QTKit.

Yes, part of the functionality, probably the bits needed to play movies on the iPhone, not the full functionality. And Apple needed to play really awkward tricks in os/x to hide the holes in QTKit's functionality. E.g., running a 32-bit quicktime server process in the os which processes requests on behalf of 64 bit QTKit and passes data to it, because the "engineering geniuses" at Apple couldn't solve the problem of missing functionality for QTKit either.

>

I will try to base all former QT functionality on GStreamer. It works already pretty well on Linux and Windows (in trunk, not yet released to ptb beta) and hopefully gets us rid of another dependency on Apple proprietary technology.

> In fact, most of the non-core targets of ptb compile fine using XCode 4 and a 64 bit target, but Screen, PsychSound, PsychHID don't.

PsychSound is ok to die. It is only there for backwards compatibility. PsychPortAudio is the important bit.

> I imagine that it's quite a lot of work to fix that. But it may be worthwhile?

It's not that we have options.

>
> Apple has often made decisions to prune the tree that have resulted in a quite usable API.
>
> jochen
>

Or to prune competitors. Or for mostly tactical/political reasons or to gain some other market advantage, of course always sold as a big advancement in one or the other way. Their strongest skill imho is marketing and PR.

Backwards compatiblity is an important feature of an operating system or computer hardware platform. It is also important, but not as vitally critical for other software. As an OS platform provider you have responsibility not only for your products but for the large number of companies and products that depend on the quality and stability of your platform. What Apple does is just unprofessional. Other operating system vendors go through great pain and effort to keep their systems as backwards compatible as possible. Microsoft made a couple of incompatible changes with Vista to fix some really grave problems with their former systems. Nothing as major as what Apple did, but Microsoft received a lot of beating for what they did - and they did it for a much better reason than Apple. Apple not so, their much more drastic measures are hailed progress.

Of course removing old cruft is the most simple and cheap solution to clean up a system. You extend your profit margin by making all others pay for your bad engineering decisions. Most customers and developers don't like to pay for their vendors mistakes, which is why other platform providers go through great effort to avoid such situations.

The other problem with new API and technology is that it usually needs many years to mature. That doesn't matter as long as you have access to the old API or if you only have very basic mainstream needs for control and precision. Unfortunately both is not the case here.

-mario