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.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
|CentOS 6.8 Released||May 27, 2016|
|Secure Desktops with Qubes: Introduction||May 27, 2016|
|Chris Birchall's Re-Engineering Legacy Software (Manning Publications)||May 26, 2016|
|ServersCheck's Thermal Imaging Camera Sensor||May 25, 2016|
|Petros Koutoupis' RapidDisk||May 24, 2016|
|The Italian Army Switches to LibreOffice||May 23, 2016|
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Secure Desktops with Qubes: Introduction
- Chris Birchall's Re-Engineering Legacy Software (Manning Publications)
- The Italian Army Switches to LibreOffice
- Linux Mint 18
- Petros Koutoupis' RapidDisk
- ServersCheck's Thermal Imaging Camera Sensor
- Oracle vs. Google: Round 2
- The FBI and the Mozilla Foundation Lock Horns over Known Security Hole
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide