Over and over again: periodic tasks in Linux

It is very common for real-time applications to have tasks that need to run periodically, for example to scan inputs or to generate regular outputs. A crude solution is to use a processing loop with a sleep at the end, but the periodicity will vary as the execution time varies. To create accurate periodic tasks you need to use timers. In this article I will show how timers work in Linux, especially with regard to multi-threaded applications.

Naming threads

Threads show up in process listings with the same name as their parent process which makes them hard to tell apart (this article describes how to list threads). It would be much nicer if the threads were given meaningful names such as “input_task”, “alarm_thread” and so on. In this short note I will show how it is done.

Listing threads

Since the introduction of the Native POSIX Threads Library (NPTL) threads have become rather elusive. They don't show up in the default process listing using the ps command and if you are using the ps applet from Busybox they don't show up ever. In this note I will show how to display thread information using the full ps program and how to do the same thing in a shell script if you don't have it.

Mutex mutandis: understanding mutex types and attributes

The mutex is a simple little thing with one job to do: ensure mutual exclusion between threads. Yet Linux has up to 16 variations of the mutex, depending on which versions of the kernel and C library you have (see the table at the end). In this article I will try to explain why there are so many and how they affect your programs.

Reducing JFFS2 mount time

When it comes to choosing a file system for flash memory JFFS2 is top of the list for most projects. It is robust and works with most flash chips using NOR or NAND technologies. The problem is that JFFS2 partitions can be slow to mount and as flash memory sizes increase, so does the issue of the tine to mount.

There is a solution: "erase block summary" or EBS. It has been in Linux kernels since 2.6.15.

Getting to grips with Eclipse: remote access and debugging

Most people working with embedded Linux are using Eclipse as the IDE, but not always taking full advantage of it. In this article I will look at one handy plug-in: the Remote System Explorer or RSE. RSE gives you three things: it allows you to explore the files on the target board, meaning that you can copy files over using drag and drop and, the killer app for me, you can edit a file on the target just by double clicking on it. The second feature is a remote shell so that you can run a terminal window in Eclipse - a marginal benefit in my opinion.

Syndicate content