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.
|Simple Ways to Add Security to Web Development||Mar 14, 2014|
|Android Candy: Humans, Run!||Mar 12, 2014|
|Alice, the Turtle of the Modern Age||Mar 07, 2014|
|Using Django and MongoDB to Build a Blog||Mar 05, 2014|
|What virtualization solution do you use/manage at work?||Mar 04, 2014|
|Our Assignment||Mar 04, 2014|
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- Simple Ways to Add Security to Web Development
- UX Designer
- Returning to Ground from the Web's Clouds
- New Products
- Zato—Agile ESB, SOA, REST and Cloud Integrations in Python
- Sign Up to Win a Silicon Mechanics Swag Pack!
- You have to be careful there
2 weeks 3 days ago
- Wonder when LJ is going to
2 weeks 4 days ago
- Puerto Rico Free Software
2 weeks 5 days ago
2 weeks 6 days ago
- I hate voice commands
3 weeks 8 hours ago
- usabilty --- AGAIN with this nonsense
3 weeks 10 hours ago
- Don't make excuses
3 weeks 13 hours ago
- Sorry to let you know, but
3 weeks 14 hours ago
- Ridiculous statement. Not a
3 weeks 1 day ago
3 weeks 1 day ago