Presentation is loading. Please wait.

Presentation is loading. Please wait.

DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization 1 1. 1.Introduction.

Similar presentations


Presentation on theme: "DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization 1 1. 1.Introduction."— Presentation transcript:

1 DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization 1 1. 1.Introduction 2. 2.Real-Time System Design Considerations 3. 3.Hardware Interrupts (HWI) 4. 4.Software Interrupts (SWI) 5. 5.Task Authoring (TSK) 6. 6.Data Streaming (SIO) 7. 7.Multi-Threading (CLK, PRD) 8. 8.BIOS Instrumentation (LOG, STS, SYS, TRC) 9. 9.Static Systems (GCONF, TCONF) 10. 10.Cache (BCACHE) 11. 11.Dynamic Systems (MEM, BUF) 12. 12.Flash Programming (HexAIS, Flashburn) 13. 13.Inter-Thread Communication (MSGQ,...) 14. 14.DSP Algorithm Standard (XDAIS) 15. 15.Input Output Mini-Drivers (IOM) 16. 16.Direct Memory Access (DMA) 17. 17.Review

2 Objectives   Describe the fundamental concepts of tasks   Demonstrate the use of semaphores in tasks   Author TSK code using simple data block pointers   Create a TSK with the CCS GUI   Describe the TSK object   Modify SWI based code to employ TSK T TO Technical Training Organization 2

3 Tasks   TSK vs SWI   TSK Scheduling   Semaphores (SEM)   Task Object   Review   Lab 12 Ready Blocked Terminated 12 Running pend post preempted Created when highest priority T TO Technical Training Organization 3

4 SWI TSK 12 Scheduler States : TSK vs SWI Ready Blocked Terminated 12 Running pend post preempted Created when highest priority 12 Ready Inactive 12 Running when highest priority preempted Posted Created   ready to run when created   by BIOS startup if specified in GCONF   by TSK_create() in dynamic systems (mod 11)   preemptive   blocked when pending on an unavailable resource   returned to ready state when resource is posted   may be terminated when no longer needed Tasks are: completed T TO Technical Training Organization 4

5 SWI vs. TSK SWIFeatureTSK Preemptable Block, Suspend Delete prior to completion by other threads User Name, Error Number, Environment Pointer Can interface with SIO context switch speed Context preserved across accesses to thread Can call SEM_pend() Stack API callable by - - - faster slower - NO * system Individual ASM, C C T TO Technical Training Organization * SEM_pend with timeout of 0 is allowed 5

6 Tasks   TSK vs SWI   TSK Scheduling   Semaphores (SEM)   Task Object   Review   Lab 12 Ready Blocked Terminated 12 Running pend post preempted Created when highest priority T TO Technical Training Organization 6

7 Priority Background DSP/BIOS Scheduler HWI Hardware Interrupts SWI Software Interrupts TSK Tasks IDL Background   HWI priorities set by hardware   Fixed number, preemption optional   All TSKs are preempted by all SWIs and HWIs   All SWIs are preempted by all HWIs   Preemption amongst HWI is determined by user   In absence of HWI, SWI, and TSK, IDL functions run in loop   14 SWI priority levels   Any number possible, all preemptive   15 TSK priority levels   Any number possible, all preemptive   Continuous loop   Non-realtime in nature Foreground Hard R/T Soft R/T T TO Technical Training Organization 7

8 Thread Preemption Example HWI SWI 2 SWI 1 IDL TSK 2 TSK 1 interrupt pend sem2 interrupt pend sem2 pend sem1 interrupt return post swi1 return post swi2 return post sem2 return post swi2 return post sem1 post sem2 return pend sem2 pend sem1 Events over time T TO Technical Training Organization 8

9 Tasks   TSK vs SWI   TSK Scheduling   Semaphores (SEM)   Task Object   Review   Lab 12 Ready Blocked Terminated 12 Running pend post preempted Created when highest priority T TO Technical Training Organization 9

10 Task Code Topology - SEM Posting Void taskFunction(…) { /* Prolog */ while (‘condition’){ SEM_pend() /* Process */ } /* Epilog */ } Void taskFunction(…) { /* Prolog */ while (‘condition’){ SEM_pend() /* Process */ } /* Epilog */ }   Initialization (runs once only)   Processing loop - option: termination condition   Wait for resources to be available   Perform desired DSP work...   Shutdown (runs once - at most)   TSK can encompass three phases of activity   SEM can be used to signal resource availability to TSK   SEM_pend() blocks TSK until next buffer is available T TO Technical Training Organization 10

11 Count > 0 Decrement count Pend Return TRUE true Semaphore Pend Semaphore Structure:   Non-negative 16-bit counter   Pending queue (FIFO) Semaphore Structure:   Non-negative 16-bit counter   Pending queue (FIFO) Return FALSE timeout expires SEM posted false Block task yes no timeout = 0 SEM_pend(&sem, timeout) #define SYS_FOREVER (Uns)// wait forever #define SYS_POLL (Uns)0// don’t wait T TO Technical Training Organization 11

12 Task pending on sem? Ready first waiting task Return True Task switch will occur if higher priority task is made ready Semaphore Post Increment count False Semaphore Structure:   Non-negative count   Pending queue (FIFO) Semaphore Structure:   Non-negative count   Pending queue (FIFO) Post SEM_post(&sem) T TO Technical Training Organization 12

13 Static Creation of SEM var mySem = SEM.create("mySem"); mySem.comment = "my SEM"; mySem.count = 0; T TO Technical Training Organization Creating a new SEM Obj 1. right click on SEM mgr 2. select “Insert SEM” 3. type object name 4. right click on new SEM 5. select “Properties” 6. indicate desired User Comment (FYI) Initial SEM count 13

14 SEM API Summary SEM_pendWait for the semaphore SEM_postSignal the semaphore SEM_countGet the current semaphore count SEM_resetReset SEM count to the argument-specified value SEM_newPuts specified count value in specified SEM SEM_ipost SEM_post in ISR – obsolete – use SEM_post SEM APIDescription SEM_createCreate a semaphore SEM_deleteDelete a semaphore Mod 11 T TO Technical Training Organization SEM_pendBinaryWait for binary semaphore to = 1 SEM_postBinaryWrite a 1 to the specified semaphore 14

15 Tasks   TSK vs SWI   TSK Scheduling   Semaphores (SEM)   Task Object   Review   Lab 12 Ready Blocked Terminated 12 Running pend post preempted Created when highest priority T TO Technical Training Organization 15

16 Static Creation of TSK Creating a new TSK 1. right click on TSK mgr 2. select “Insert TSK” 3. type TSK name 4. right click on new TSK 5. select “Properties” 8. indicate desired priority stack properties function arguments etc T TO Technical Training Organization 16

17 fxn * environ * priority6 stack * namelpf1 C fxn, eg: bk FIR inst2 myTsk Task Object Concepts... Task object:  Pointer to task function  Priority: changable  Pointer to task’s stack  Stores local variables  Nested function calls  makes blocking possible  Interrupts run on the system stack  Pointer to text name of TSK  Environment: pointer to user defined structure: fxn * environ * priority6 stack * namelpf2 struct myEnv T TO Technical Training Organization TSK_setenv(TSK_self(),&myEnv); hMyEnv = TSK_getenv(&myTsk); TSK stack struct myEnv TSK stack 17

18 TSK Object T TO Technical Training Organization struct KNL_Obj { // from KNL.h QUE_Elemready; // ready/sem queue QUE_Elemalarm; // alarm queue elem QUE_Elemsetpri; // set priority queue QUE_Handlequeue; // task's ready queue Intpriority; // task priority Unsmask; // 1 << priority Ptrsp; // current stack ptr Unstimeout; // timeout value Intmode; // blocked, ready,... STS_Obj*sts; // for TSK_deltatime() Boolsignalled; // woken by sem or t-out }; typedef struct TSK_Obj { // from TSK.h KNL_Objkobj; // kernel object Ptrstack; // used w TSK_delete() size_tstacksize; // ditto Intstackseg; // stack alloc’n RAM Stringname; // printable name Ptrenviron; // environment pointer Interrno; // TSK_seterr()/_geterr() Boolexitflag; // FALSE for server tasks } TSK_Obj, *TSK_Handle; typedef struct TSK_Config { IntSTACKSEG; IntPRIORITY; size_tSTACKSIZE; FxnCREATEFXN; FxnDELETEFXN; FxnEXITFXN; FxnSWITCHFXN; FxnREADYFXN; } TSK_Config; typedef struct TSK_Stat { TSK_Attrsattrs; // task attributes TSK_Modemode; // running, blocked... Ptrsp; // stack ptr size_tused; // stack max } TSK_Stat; typedef struct TSK_Attrs { Int priority ;// task priority Ptr stack ;// stack supplied size_t stacksize ;// size of stack Int stackseg ;// stack alloc’n seg Ptr environ ;// environment pointer String name ;// printable name Bool exitflag; // server tasks = false Bool initstackflag; // FALSE: no stack init } TSK_Attrs; 18

19 Tasks   TSK vs SWI   TSK Scheduling   Semaphores (SEM)   Task Object   Review   Lab 12 Ready Blocked Terminated 12 Running pend post preempted Created when highest priority T TO Technical Training Organization 19

20 TSK API Summary TSK_exitTerminate execution of the current task TSK_getenvGet task environment TSK_setenvSet task environment TSK_getnameGet task name TSK_createCreate a task ready for execution TSK_deleteDelete a task TSK APIDescription Mod 11   Most TSK API are used outside the TSK so other parts of the system can interact with or control the TSK   Most TSK API are to allow:   TSK scheduler management (Mod 7)   TSK monitor & debug (Mod 8)   Dynamic creation & deletion of TSK (Mod 11)   TSK author usually has no need for any TSK API within the TSK code itself T TO Technical Training Organization 20

21 TSK API Summary TSK_settimeSet task statistics initial time TSK_deltatimeRecord time elapsed since TSK made ready TSK_getstsGet task STS object TSK_seterrSet task error number TSK_geterrGet task error number TSK_statRetrieve the status of a task TSK_checkstacksCheck for stack overflow TSK_disableDisable DSP/BIOS task scheduler TSK_enableEnable DSP/BIOS task scheduler TSK_getpriGet task priority TSK_setpriSet a tasks execution priority TSK_tickAdvance system alarm clock TSK_itickAdvance system alarm clock (ISR) TSK_sleepDelay execution of the current task TSK_timeReturn current value of system clock TSK_yieldYield processor to equal priority task TSK APIDescription Mod 8 Mod 7 T TO Technical Training Organization 21

22 Tasks   TSK vs SWI   TSK Scheduling   Semaphores (SEM)   Task Object   Review   Lab 12 Ready Blocked Terminated 12 Running pend post preempted Created when highest priority T TO Technical Training Organization 22

23 Audio Out (48 KHz) Lab 5: Task Thread - TSK ADC AIC33 Audio In (48 KHz) McBSP DRR FIR.c FIR Code DAC AIC33 McBSP DXR mcbsp.c coeffs.c Coefficients BIOS\Labs\HWBIOS\Labs\Work BIOS\Labs\Algos   Begin with the SWI-based buffered system   Modify SWI to run as TSK; add SEM_pend and while loop   TCF: remove SWI obj, add TSK and SEM objs   Modify HWI to post SEM instead of SWI   Build, load, test, verify performance isrAudio pInBuf[bkCnt]=MCBSP_read MCBSP_write(pOutBuf[bkCnt]) if(bkCnt=2*BUF) QUE_put(&from DevQbufs) SEM_post(&mySem) bkCnt=0; HWI12 tskProcBuf procBuf while() SEM_pend(&mySem) for (i =0, i<HIST; i ++) pIn ][i]= pPriorIn ][ 2*BUF-HIST ]; if( sw0 == 1 ) FIR(in[ pIn-HIST ],out[ pOut ]) else {pOut[i]=pIn[i]} T TO Technical Training Organization 23

24 Lab 5 : Procedure Overview   In the TCF file:   replace the processing SWI with a TSK   create a SEM   In audio.c:   In the isrAudio (HWI) function:   Post a SEM instead of the SWI   In the procBuf (TSK) function   Add a while loop and SEM_pend to the remaining code in procBuf()   Build, download, run, and verify the correct operation of the new solution   Optionally, copy the solution files to C:\BIOS\mySols\05 24

25 ti Technical Training Organization 32

26 Lab Details FilterDebugRelease Off18%4.7% On61%6.5% HWI – based lab 3 FilterDebugRelease Off3.8%2.3% On45%3.7% SWI – based lab 4 Observations: Moving from SWI to TSK showed results within 0.1% of being the same So… the ‘extra overhead’ of TSK vs SWI doesn’t really amount to much at all, and could easily be countered by a small increase in buffer size, which will have much greater effect than thread type FilterDebugRelease Off 3.8% 2.5% On 45% 3.8% TSK – based lab 5


Download ppt "DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization 1 1. 1.Introduction."

Similar presentations


Ads by Google