Example: Queue of DMA Requests
DSP/BIOS vs. Portos
Given one DMA channel, successive DMA requests have to be queued when the channel is busy. A DMA transfer terminates with a DMA done interrupt, at which point the next DMA request in queue can be serviced. In this example, in DSP/BIOS case we queue them with tasks and semaphores. In Portos we queue them with queue of functions (the natural way). This is a simplistic example; some functions may do more stuff.
See also Highlights.
| DSP/BIOS Tasks |
Portos Priority Functions |
|
#include <std.h> char *src; } MessageDma; |
#include <portos.h> // Queue to synchronize DMA requests static po_queue_Queue myQ = po_queue_INIT(&myQ, 1, 0); |
|
// Task to handle DMA requests (priority 3) // For ever loop MessageDma msg; } } |
// DMA request handler (priority 3) void dma_handler(po_priority(3), char *src, char *dest, int len) { // Start DMA transfer } |
| // DMA done interrupt void dma_done_interrupt(void) { // Reset DMA and other registers } |
// DMA done interrupt void dma_done_interrupt(void) { // Reset DMA and other registers } |
| // Task myfunc that launches DMA transfers (priority 5) void myfunc(void) { // For ever loop MessageDma msg; } } |
// Launches DMA transfers (priority 5) void myfunc(po_priority(5)) { // Send packet to dma_handler (via queue) } |
| // Random interrupt that requests new DMA transfers void random_interrupt(void) { // Activate task that schedules transfers } |
// Random interrupt that requests new DMA transfers void random_interrupt(void) { // Call priority function that schedules transfers } |
| // Main function int main() { TSK_Attrs attr1 = {0}; } |
// Main function int main() { // Init Portos } |