Anatomy of a Small Open-Source Kernel for DSPs
Using DSPs in deeply embedded systems, we work mainly in a commercial world and wish dsp_K to be friendly with other host operating systems. As such, several additional sources besides Linux influence dsp_K development, notably classic monolithic operating systems (like vxWorks), process-oriented software design and simple PC-based kernels (e.g., uC/OS).
The dsp_K architecture is perhaps most influenced by classic monolithic operating systems like UNIX and its real-time extensions, especially VxWorks (the BSP file dsp_Ku.h compares to configAll.h). I recommend the UNIX man pages, which prove an excellent guide when writing libraries. Plenty of quality texts on UNIX-like and POSIX systems can be found on any academic publisher's web site.
There is no academic paper specifically about dsp_K, but the kernel embodies an approach to software design present in a research paper I had published a decade ago (certainly it's not worth obtaining, but see Resources if you're interested). In it, and based upon Hoare's model of communicating sequential processes, a process is comprised of concurrent threads that can run forever using their own scheduling mechanism. This is a specialization of process-oriented software design.
The process-oriented approach to software design, embodied by the Occam programming language, for example, is most visible in the dsp_K layer 2 process API. Both demand encapsulation, but contrasting with object-oriented design, especially as seen through C++, you will see the process-oriented model is one that encourages simplicity of purpose rather than genericness. Both models are useful ways to structure software applications, but dsp_K applications are more readily designed using a process-oriented approach where runtime and memory space are precious commodities.
You could write the simplest preemptive multitasking program with nothing but a PIT or tick. Consider the SHARC DSP and its shadow registers; the tick ISR could do nothing but reprogram the mode 1 register to flip onto the other of the two available register sets and perform an rti (return from interrupt instruction). By general consensus, to be considered an RTOS, a multitasking program should provide a few more features than only a PIT. An easy way to think about a desirable feature set is to play around with an existing, freely available, small PC-based RTOS, such as uC/OS, which is especially useful since it is free for noncommercial use.
I will summarize the history of the dsp_K project to date later, but as a teaser, the dsp_K project began in late October 1999, about a year or so after both the µClinux mailing list became popular and RTLinux papers were published. It was possible to run µClinux on the PalmPilot simulator under Linux and patch in and run RTLinux modules on PC-Linux. Indirectly, these projects influenced the structure, minimalism and features dsp_K provides and demonstrate how it might coexist with higher order RTOSes. It was further instructive to look at the mailing lists to see the issues people encountered when trying to adopt the new embedded Linux technologies.
Of necessity our discussion will center around the SHARC DSP implementation. But you might be interested in porting the BSP to other DSPs or wish to understand the general software design, so I'll try to strike a suitable balance.
As a reminder, the BSP comprises the minimal services required to provide a functional software platform for an application to run, along with a minimal kernel personality, interrupts, context switching, scheduler sanity checker and task functions.
You can find specific details about interrupts on the SHARC in the relevant Analog Devices manuals, which you should have anyway if you are going to develop an application for that target. Basically, interrupts are the mechanism by which the hardware notifies the kernel software of interesting events, for example a periodic tick. When one is raised, the hardware enters interrupt mode by pushing the program counter and status stacks into special-purpose registers and loads the program counter with a new value corresponding to the raised interrupt (commonly called the interrupt vector). The program (or kernel execution) continues from the new vector location. Although there are further details you can explore in the SHARC technical manuals, that is basically it. Summarized in Listing 1, you can also take a look at the dsp_Ki.asm file to see the interrupt vectors at the start.
The rti instruction is executed from within the kernel software to exit interrupt mode. When executed, the hardware pops the program counter and status stacks from the special-purpose registers it used earlier, and program execution continues from where it left off before the interrupt was raised. Interrupt-handling code is placed into a program code segment (commonly named seg_rth for runtime header) and is statically allocated in the correct memory location by the linker during buildtime.
Practical Task Scheduling Deployment
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.View Now!
|The Firebird Project's Firebird Relational Database||Jul 29, 2016|
|Stunnel Security for Oracle||Jul 28, 2016|
|SUSE LLC's SUSE Manager||Jul 21, 2016|
|My +1 Sword of Productivity||Jul 20, 2016|
|Non-Linux FOSS: Caffeine!||Jul 19, 2016|
|Murat Yener and Onur Dundar's Expert Android Studio (Wrox)||Jul 18, 2016|
- The Firebird Project's Firebird Relational Database
- Stunnel Security for Oracle
- My +1 Sword of Productivity
- Non-Linux FOSS: Caffeine!
- Managing Linux Using Puppet
- SUSE LLC's SUSE Manager
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Doing for User Space What We Did for Kernel Space
- Google's SwiftShader Released
- SuperTuxKart 0.9.2 Released
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide