LWN.net Logo

Leading items

Papers from the Real Time Linux Workshop

By Jake Edge
October 14, 2009

There are far too many interesting Linux and free software conferences these days, so it would be difficult—really, impossible—to attend them all. Slides and videos of the talks can help fill in the gaps, but, for conferences with a more academic bent, the papers that are the basis of the presentations can give an even more detailed look. The papers from the recently concluded Real Time Linux Workshop are a good example; this article will briefly look at a few of them.

Myths and Realities of Real-Time Linux Software Systems

This paper [PDF] can serve as an introduction to realtime for those who are not familiar with what that means. Author Kushal Koolwal starts with the basics: defining realtime, describing various kinds of latencies, and looking at hard vs. soft realtime, before moving into a few myths. Koolwal then looks at realtime in Linux, focusing on the PREEMPT_RT patchset. In a few short pages, this paper will give the reader a good foundation in realtime and the trade-offs necessary to support it.

Finding origins of latencies using Ftrace

Ftrace developer Steven Rostedt describes how to use ftrace to find unexpected and/or unacceptable latencies, which may be a barrier to realtime processing, in his paper [PDF]. Ftrace is a relatively new tool in the kernel that provides various kinds of tracing information and has some facilities that can be used specifically for tracking down latency issues. Tracers like irqsoff, preemptoff, and wakeup (along with some variants) capture information while the kernel is running in specific modes (i.e. with interrupts disabled, preemption turned off, etc.).

Rostedt's paper gives a fairly detailed look at the tracers, how to enable them, what they do, and the output they produce. While these latency tracers are active, they capture things like kernel functions called or trace event points encountered while looking for the maximum time spent in the latency-causing modes. By looking at what the kernel is doing when the latency has exceeded expectations, it can lead a developer to the specific cause—which may lead to a way to reduce the latency. Rostedt mentions the JACK "audio connection kit" developers as an early adopter of latency tracing, noting that they found both kernel and JACK bugs that were causing excess latency.

Towards Linux as a Real-Time Hypervisor

Jan Kiszka reported [PDF] on experiments using Linux as a hypervisor for realtime processing. Using KVM and QEMU, he measured the latency in both the host and guest operating systems under a number of different scenarios. One of the more obvious means to increase the responsiveness of the guest is to raise the priority of the QEMU threads and to put them into a realtime scheduling class. But that can lead to starving host OS processes that the guest is waiting on, which could lead to deadlock or other undesirable behavior.

The paper reports on the measurements of average and maximum latency, as part of a latency histogram, under different conditions: a baseline test in the host as well as in the guest, applying the priority and scheduling class changes to the guest, lowering the priority on the asynchronous I/O (AIO) QEMU threads, and using PREEMPT_RT kernel on the host. In addition, Kiszka describes a "paravirtualized scheduling" approach that allows the guest to send the host information on spinlock usage that will allow the host scheduler to adjust priorities of the guest processes for more efficient use of the CPUs, while avoiding priority inversions

ARM Fast Context Switch Extension for Linux

The organization of the ARMv5 cache can cause performance problems that may preclude its use for realtime tasks. The cache is based on virtual memory addresses and, since Linux processes share the same range of virtual addresses, each context switch requires invalidating the cache. Depending on the CPU type, memory speed, and the program's data access pattern, the cost of reloading a process's data from main memory can be on the order of 200 microseconds—too much for many time-critical applications.

One alternative is to share a flat address space between all of the processes, but then the memory protection provided by separate address spaces is lost. Gilles Chanteperdrix and Richard Cochran describe [PDF] another approach for doing context switches that preserves the memory protections without sacrificing the cache at every context switch. They use the ARM Fast Context Switch Extension (FCSE) and partition the virtual address space into separate 32MB chunks so that processes do not have overlapping address ranges. This allows for up to 128 processes running in the 3GB available for non-kernel addresses. The translation lookaside buffer (TLB) must still be flushed on context switches to enforce memory protection, but the data and instruction caches are preserved.

The actual implementation required reducing the number of available processes to 95. Either 95 or 128 processes, along with the 32MB address space restriction, were unacceptable for many embedded applications, so the authors added a "best effort mode" that eliminates those restrictions, but cannot guarantee that it won't have to do cache flushes on some context switches. They reported that average latencies for their test cases reduced by roughly half when the "guaranteed" mode was used, and by roughly one-quarter with "best effort" mode, when compared to the standard Linux kernel.

Design and Implementation of Node Order Protocol

Distributed systems often use "time division multiple access" (TDMA) as a means to coordinate access to a shared communications medium (e.g. shared bus or wireless frequencies). But, TDMA requires a reliable means to synchronize the clocks on the various systems and that synchronization uses some of the shared bandwidth simply for timekeeping. The authors, Li Chanjuan, Nicholas McGuire, and Zhou Qingguo, propose [PDF] a different protocol, Node Ordering Protocol (NOP), that avoids much of the complexity and bandwidth waste that occur with TDMA.

As its name implies, NOP relies on a consistent ordering of the nodes in the network. It also requires that nodes monitor the other nodes to determine if a faulty node is not correctly following the ordering scheme. The advantages, according to the authors, are that NOP is much easier to implement and validate than other protocols with complex synchronization requirements, loss of bandwidth due to temporal padding is not required, and that error detection is much simpler and bounded in time.

Use of cookies in real-time system development

One last paper to mention is the scholarly-sounding, if tongue-in-cheek, look at cookie consumption and "the positive impact on the real-time Linux community we were able to observe". The authors, M. Gleixner and M. McGuire, look at various cookie protocols—with code—and conclude that uni-directional protocols are best for real-time Linux development: "Though greedy protocols have been discussed in the past, we found that considering these has negative impacts on developers long term and thus are deprecated."

The slides for some of the presentations are available on the Open Source Automation Development Lab (OSADL) web site. There are quite a few more papers than we looked at here available as well. While the papers can't really replace the experience of attending, there is much of interest for those that are looking for more information on realtime in Linux.

Comments (3 posted)

Maemo Summit 2009: Fremantle, Harmattan, and N900

October 14, 2009

This article was contributed by Nathan Willis

Nokia's second annual Maemo Summit brought together 400 developers and power users of the Linux-based tablet community in Amsterdam over the October 9-11 weekend. Maemo Community Manager Quim Gil said the primary goal was to bring the community together for the social and interactive benefits, but the three-day program also provided a solid introduction to the new Maemo 5 release, a preview of Maemo 6, and a chance to work with the Nokia N900 — which ships with as close to a standard Linux distribution as the marketplace has seen delivered on a usable mobile phone.

[Summit intro]

Friday's program was planned by Nokia, and featured several plenary talks delivered by Nokia staff, including the company's vice president of Maemo devices Ari Jaaksi, vice president of marketing Jose-Luis Martinez Merino, and director of Maemo product planning Janne Heikkinen. Session talks covered user interface and user experience design for the new release, application and widget development, and introductions to the changes slated for the next generation of Maemo, Maemo 6 "Harmattan." Saturday and Sunday's program was chosen by the Maemo.org community, and covered development in depth, as well as more user-centric subjects like introductions to the key applications and device customization.

Meet 5, meet 6

The biggest news in the Maemo community is the impending release of the Nokia N900, successor to the 770, N800, and N810 tablets — and the first to include cellular phone support. The N900 uses Maemo 5 "Fremantle," for which the official software development kit (SDK) has been available since December of 2008. Like previous releases, Maemo 5 uses libraries and toolkits common to desktop Linux distributions: Glib, GTK+, Pango, Cairo, GStreamer, BlueZ, D-Bus, Telepathy, etc. The new version adds Clutter, PulseAudio, GUPnP, Tracker, and upstart to that list, among other changes.

Nokia made a surprise announcement on the first day, providing pre-production N900 devices to 300 summit attendees for a six-month loan period (attendance was initially capped at 300; when registration hit the cap, it was expanded to 400 — Nokia assured the attendees that everyone who was not a Nokia employee or Nokia subcontractor would receive a device).

The core N900 applications — media player, calendar, communications tools, and web browser — were built by Nokia, but a considerable number of community-written and third-party applications are already built and available for the platform through the Maemo.org repositories. The Summit program recognized many of these applications with lightning talks or full sessions, and showcased five of them in the Sunday morning keynote slot for "Fremantle Stars." The stars included the microblogging tool Mauku, weather report utility OMWeather, exercise trainer eCoach, OpenStreetMap mapping tool OSM2Go, and liqbase, a suite of widgets and small applications designed for handwriting use, sketching, and other non-keyboard interaction.

[Jaaksi interview]

The early focus on providing Maemo 5 development tools and support should make the N900 application market full when the phone finally goes on sale. Similarly, Nokia has already started preparing developers for the changes and additions slated for Maemo 6, which is expected to be released sometime in late 2010.

The most talked-about change in Maemo 6 is the adoption of the Qt framework for the default applications. Nokia states several technical reasons for the change, including the desire to use OpenGL ES hardware acceleration for the entire interface, multi-touch and gesture input, and an application state machine API. It is no secret, though, that Nokia has business reasons for the change as well; as the owner of Qt creator Trolltech, the company is pushing the framework on all platforms: Maemo, Symbian, desktop Linux, Windows, and embedded devices. On Friday morning, Nokia announced the immediate availability of an official Qt stack for Maemo 5 — specifically, a "technology preview" release targeting application developers.

When the switch to Qt was initially announced, some questioned whether it was too soon, and would short-circuit developers' desire to build their applications for Maemo 5 with the current framework. Judging by the number and variety of Maemo 5 applications currently available, though, few, if any, developers appear to have chosen to skip Fremantle.

Oh, and did we mention it's a phone?

The majority of the excitement and discussion surrounding Maemo 5 and the N900 focuses on its capabilities as a portable Internet tablet like its predecessors; one could almost be excused for forgetting from time to time that the N900 is "also" a fully-capable cell phone. Perhaps that emphasis is appropriate; Blackberry, Palm, and Apple have placed the bulk of their efforts into highlighting the Internet features of their high-end mobile phone platforms.

Maemo 5 is still a big step forward for Linux on mobile devices, however, precisely because cell phone functionality on the N900 makes it a choice for the average smartphone consumer. More importantly, Maemo 5 is, for all intents and purposes, a standard Linux distribution under the hood — it is not a locked-down, code-signed environment in which all user applications run in an isolated virtual machine environment. An xterm is one of the default N900 applications; any user that wishes to alter system components right down to the kernel can gain root access without tiptoeing through an arcane jailbreaking process.

[oFono talk]

Consequently, one of the most intriguing talks at Maemo Summit was Saturday's "Maemo and oFono," which detailed Nokia's work on an open source cell phone communication stack. The cellular stack handles a range of functions, from communicating with the cell modem itself, to monitoring and caching network status and selection information, to processing and formatting SMS and MMS messages, to managing SIM card security. Modem management itself is a tricky field, as many cell modems still use the decades-old Hayes (i.e. "AT") command set, while others (including Nokia's) use vendor specific replacements with more features.

oFono uses D-Bus, and has a small core with a plugin system that handles functions like network registration, SMS formatting, and call handling. Intel is also heavily involved in the project, and according to speaker Rémi Denis-Courmont, has made most of the commits, particularly with the hardware drivers. oFono is still in pre-release; Maemo 5 uses a closed-source stack called the cellular service daemon (CSD), and Denis-Courmont said that oFono is unlikely to make it to Maemo 6 by launch time, either.

Free software purists may decry the N900 for its inclusion of proprietary code, including the CSD phone stack. Unlike other closed applications on Maemo devices, however, there has never been a free alternative, so oFono represents a big piece of the "purity" puzzle — even if it is several years from appearing in consumer devices. When asked by the audience why Nokia did not simply open up CSD, Denis-Courmont responded that the company was not satisfied with the code and preferred to write a proper open source solution from scratch, even if that takes time.

In a sense, that is the same story as Maemo itself. Nokia invested several years and several generations of product design building the Maemo Linux platform, and at the same time invested heavily in building an enthusiastic and deep community of Maemo application developers. It even encourages development of competing applications and interfaces, such as the Canola media player, the Mer distribution, and liqbase.

As a result, Nokia now has a solid open source phone platform to show for it, one that (according to Jaaksi) shares approximately 80 percent of its code with the standard desktop and enterprise Linux distributions. More importantly, neither Android nor the LiMo Foundation — which have not made the same investment in community building — has anywhere close to the active community writing open source applications and contributing upstream to the project. Google, for example, places its emphasis on commercial applications, and does not even track open source applications for the platform. On the other end of the spectrum, the OpenMoko project—lofty as its goals are—has not developed into a commercially viable product and gets poor reviews on user experience. The size of the Maemo community does not guarantee success for the platform, but as open source advocates know, it does provide a large advantage.

[Note: Nokia underwrote travel for the author, as well as for several other journalists and around one quarter of the community attendees. The author would like to thank Nokia, Quim Gil, and the Maemo Community Council for the opportunity, for their help, and for being accessible during a very busy event.]

Comments (17 posted)

The Open Web: KDE frees the web from the browser

October 14, 2009

This article was contributed by Koen Vervloesem

In recent times, the KDE project has been at the forefront of integrating the web into the desktop. In mid-September, Sebastian Kügler announced Project Silk. Meanwhile, Frank Karlitschek has been working on the Social Desktop for some time now.

On October 29, NLUUG holds its Fall Conference with the theme "The Open Web", where both KDE developers will give a talk. Sebastian will talk about freeing the web from the browser, while Frank's talk will be about the Social Desktop integration of web communities into desktop applications. Your author asked them to give a preview of their talks in an email interview.

Free the web from the browser

Sebastian will talk about the differences between the web as we use it now and what he calls "local clients": "My plan is to show how we can make the web more accessible for a multitude of different devices, and how we can tackle this." This is all part of his Project Silk, which has, as its ultimate goal, a close integration of the content and services of the web into the KDE user experience.

To see why it makes sense to integrate web content into a desktop environment, we have to take a birds-eye view on the evolution of web browsers in the last couple of years. Then, we see that the web browser is now actually a very general platform: it evolved from a simple HTML viewer into a runtime environment for web applications that provide online services. What didn't change is one core assumption, according to Sebastian:

Most of these applications are written for one target device. This device has a screen of, let's say, 1024x768, a keyboard and a mouse and is always online. This has been a reasonable assumption for some time, but is becoming less and less of a given.

Indeed, if we look at our current use of the internet, it's much more varied than before: from mobile phones and internet tablets to netbooks, laptops, desktops, and media centers. Assumptions that were true when we accessed web services five years ago are simply not true anymore, Sebastian explains:

Now the user might have a spotty internet connection, which is often the case when you're using mobile devices on the road. Screens might not be big enough to show a full web application: on netbooks, screen real estate is very sparse, so we need to make better use of it. On the other side of the scale, it makes a lot of sense to enjoy online content on media centers, think of watching online videos from services like YouTube from your comfortable chair.

So in all those new use cases, the assumptions that websites make fall short. Reading small text is often impossible on large but low-resolution TV screens, a remote control or a touch screen behaves completely differently than a mouse or touch pad. Those capabilities of a device are best known to the client, so it's much easier to control these input mechanisms for web applications on the client. But there's more:

By not restricting web applications to a web browser, we can use the client's technologies to do really interesting things with the data on the desktop. The semantic desktop features that are integrated into KDE can greatly enhance the ease of use of information, on the local machine, but also on the web — and connect and combine those bits of information.

Of course using a native client to display online content provides a more coherent user experience when you're on the web from your desktop. Last but not least, Sebastian sees a security advantage: by separating content and client-side application logic from each other, it should be easier to build safer web applications.

Many things in the pipeline

Project Silk doesn't come out of the blue: KDE has already integrated many online sources into applications. For example, Sebastian has worked with Frank and others on components that integrate social networking into KDE's Plasma desktop shell. So we have already a lot of online content, such as email, contacts and social networks, integrated into desktop applications. But Sebastian admits that most of these efforts are rather cluttered and do little in the sense of sharing code, ideas, or infrastructure.

Most KDE applications are already fully network-transparent: they use the KIO API that allows a user to access remote files using the same methods as accessing local files. Moreover, in recent years some interesting services have been built: with Akonadi KDE has central cached storage for PIM data such as emails, contacts and calendaring. Nepomuk provides the basis to handle all kinds of metadata on the KDE desktop. According to Sebastian, these services are a powerful base to build applications that are "vastly superior to JavaScript-driven browser applications."

One of the first components in project Silk that KDE developers have been working on is Selkie, which turns a web application into a first class citizen of the KDE desktop by providing better integration with the window manager, integration with desktop services such as the notification system. and custom, per-web-application actions:

We've written a promising prototype and the idea seems to work surprisingly well. We have working test cases to manipulate the inner workings of a web application from the toolbar by injecting JavaScript into the running web application. This is a surprisingly easy way to give back some control to third parties on how web applications look like and behave on the desktop. I'll demo the prototype of Selkie during my talk.

More things in the pipeline include components to integrate online multimedia content into the KDE Media Center components. Sebastian also lists some lower-level activity going on, in the form of QJSon, a small library for the JSon protocol, classes to search and access content from MediaWikis such as Wikipedia, a thumbnailer for web pages, and so on. Because many applications that make KDE "silk" are integrated into the applications or Plasma, there is no central point with Project Silk code, but there is a git repository that collects the bits that aren't integrated yet.

The Social Desktop

Frank's talk at the NLUUG Fall Conference will be about the idea and the status of the Social Desktop in KDE, which he first proposed in his keynote speech at the 2008 Akademy in Belgium. The core idea of this project is to bring communication and collaboration in online communities to desktop applications, taking away the need to surf to forums and social networks in a browser. During his talk, Frank will give an overview of all the new features and possibilities from a developer and a user point of view. There is already work in-progress:

We have already implemented the means to find other KDE users near you, management of your friends, messaging, content sharing, knowledge base access and more. During my talk, I will give a more complete overview. We will have really good integration in KDE 4.4, which will be released in January. The access library for all the Social Desktop features will be moved into the KDE libraries and all the identity management will be a central part of KDE, so all KDE applications can access this social aspect very easily. We already have several applications that use these new possibilities.

So the point of the Social Desktop is to connect people to each other and bring them closer to the KDE desktop project and related topics. Frank stresses that this is not only useful for developers, but also for regular users: "For example, you can get in contact with other KDE users and can see what your friends are doing. Or you can get help via the Knowledge Base Integration without the need to open up a browser."

To be able to use social networks on the KDE desktop without tying the Social Desktop to one web platform like Facebook or Twitter, the developers worked on support for the open collaboration services (OCS) standard, which is an open standard published on freedesktop.org. According to Frank, several websites have already committed to supporting this specification so that users can choose from different data sources:

A social desktop should be independent so the users can use different "service providers" and there is no lock-in. Because of this, it is important to have an open and independent API specification so that different clients and different servers can understand each other and speak the same language.

Just like Sebastian said, Frank explains that there's nothing wrong with the browser per se, but if you integrate web services directly in desktop applications you can get a richer experience:

One example is an education application you use to practice your vocabulary in a different language. You get automatically a list of other people who want to learn your language and speak the language you want to learn. So you can connect and learn together. You can't get this with a standard desktop application. But you also can't get the richness and performance with a web application. A social desktop application combines both.

Social Desktop Contest

This brings us to the winners of the Social Desktop Contest, which was started on 17 June 2009. The goal of the contest was to foster community development and innovations around the OCS API. The winners of the contest were recently announced. In the announcement, Frank wrote:

There have been many new ideas and innovations coming from the community in the Social Desktop area and we received a large number of really good submissions. This made it obviously hard for the jury, as you can have only so many winners.

The winning submission of the contest is an ExtendedAboutDialog for KDE apps by Téo Mrnjavac. It gets information about the developers of a program — for example contact details, web addresses, and nationality — from opendesktop.org and shows it in the "About" window. This gives the application a human face and enables direct interaction with the development team. The extended about dialog can be used in any KDE application and already ships with Amarok 2.2.

The second place winner is the Knowledge base widget by Marco Martin. This is a plasmoid that lets users query the online opendesktop.org knowledge base without the need to visit a forum or subscribe to a mailing list. The widget will be part of KDE 4.4. The third place is for libopengdesktop by Guido Roberto. This is a simple Glib-based library that gives easy access to Open Collaboration Services providers. It will be useful to bring the Social Desktop to Gnome and XFCE platforms. The fourth place is for PyContent, a plasma widget written in Python to show the newest contents in specific categories from a content provider.

Open projects for an open web

Both projects, the Social Desktop and Project Silk, have a very open attitude. The idea, the server side and the API specifications of the Social Desktop are completely platform independent, Frank stresses:

We are developing a KDE specific client library at the moment, but it is possible to integrate this functionality easily into other applications or desktops. Proof of this is that one of the winners of the Social Desktop Contest developed a library to integrate this easily into GNOME. Gwibber, a GNOME Twitter application, has already support for the API.

At this moment, project Silk is still KDE-specific, but this has its reasons, Sebastian explains:

We are not yet in touch with other desktop environment's developers for cross-desktop developments. One reason is that we first want to have something in our hands. Going out and talking about lofty ideas often costs a lot of time. In this phase, Silk is an internal thing to KDE, we first have to collect and streamline our efforts, and work on a couple of things we think we are missing.

Contribute to an open web

Both projects are also open for contributions. KDE developers and users can get involved easily in the social desktop project. There is a mailing list, a wiki, the specification is available on freedesktop.org and of course all the KDE code is available in the KDE svn. Frank adds that there will be a developer meeting later this year specially for the Social Desktop: "Everybody is welcome. So please send me an email if you want to participate. It isn't important which desktop or technology you use. The Social Desktop is a completely open project."

Project Silk is very much an umbrella for people that work on web integration components, so it's not a closed group of people but, instead, consists of a number of people from all over KDE that have already been working on web integration aspects. That's why it's easy to contribute, as Sebastian notes: "Developers that find these ideas interesting should get in touch with us on the #kde-silk IRC channel on the Freenode.net network, or via the kde-silk@kde.org mailing list. We've spent some time documenting ideas about Project Silk on Techbase, KDE's knowledge base wiki."

All in all, both projects are still in their infancy, which is an interesting opportunity for open source developers who want to do some innovative work. The submissions to the Social Desktop Contest and the Project Silk ideas on Techbase are good sources for inspiration.

Comments (12 posted)

Page editor: Jonathan Corbet
Next page: Security>>

Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds