/
TI BIOS TSK – Task Authoring TI BIOS TSK – Task Authoring

TI BIOS TSK – Task Authoring - PowerPoint Presentation

faustina-dinatale
faustina-dinatale . @faustina-dinatale
Follow
342 views
Uploaded On 2019-11-19

TI BIOS TSK – Task Authoring - PPT Presentation

TI BIOS TSK Task Authoring 15 February 2011 Dr Veton Këpuska 1 Objectives 15 February 2011 Dr Veton Këpuska 2 2 Outline 15 February 2011 Dr Veton Këpuska 3 3 Tasks vs SWI 15 February 2011 ID: 765725

sem tsk 2011 february tsk sem february 2011 veton puska task swi priority stack post pend bios semaphore ready

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "TI BIOS TSK – Task Authoring" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

TI BIOS TSK – Task Authoring 15 February 2011 Dr. Veton Këpuska 1

Objectives 15 February 2011 Dr. Veton Këpuska 2 2

Outline 15 February 2011 Dr. Veton Këpuska 3 3

Tasks vs. SWI 15 February 2011 Dr. Veton Këpuska 4 3

TSK vs. SWI 15 February 2011 Dr. Veton Këpuska 5

TSK Scheduler States: TSK vs. SWI 15 February 2011 Dr. Veton Këpuska 6 1 2 Ready Blocked Terminated 1 2 Running pend post preempted Created when highest priority SWI 1 2 Ready Inactive 1 2 Running when highest priority preempted Posted Created completed

Tasks Are: Ready to Run when Created by BIOS startup if specified in GCONFby 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 15 February 2011 Dr. Veton Këpuska 7

SWI vs. TSK 15 February 2011 Dr. Veton Këpuska 8 SWI Feature TSK  Preemptable  - Block, Suspend  - Delete prior to completion by other threads  - User Name, Error Number, Environment Pointer   Can interface with SIO  Faster context switch speed Slower - Context preserved across accesses to thread  NO* Can call SEM_pend ()  System Stack Individual ASM, C API callable by C * SEM_pend with timeout of 0 is allowed

TSK Scheduling 15 February 2011 Dr. Veton Këpuska 9 3

Task Scheduling 15 February 2011 Dr. Veton Këpuska 10

DSP/BIOS Scheduler 15 February 2011 Dr. Veton Këpuska 11 Priority Background HWI Hardware Interrupts SWI Software Interrupts TSK Tasks IDL Background HWI priorities set by hardware Fixed number, preemption optional 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

DSP/BIOS Scheduler All TSKs are preempted by all SWIs and HWIs All SWIs are preempted by all HWIsPreemption amongst HWI is determined by userIn absence of HWI, SWI, and TSK, IDL functions run in a loop 15 February 2011 Dr. Veton Këpuska 12

Thread Preemption Example 15 February 2011 Dr. Veton Këpuska 13 HWI SWI 2 SWI 1 IDL TSK 2 TSK 1 interrupt pend sem2 interrupt interrupt pend sem2 pend sem1 interrupt return 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

TSK Scheduling 15 February 2011 Dr. Veton Këpuska 14 3

Semaphores (SEM) 15 February 2011 Dr. Veton Këpuska 15

Task Code Topology: SEM Posting Initialization (runs once only) Processing loop - option: termination condition Wait for resources to be available Perform desired DSP work... Shutdown (runs once - at most) 15 February 2011 Dr. Veton Këpuska 16 Void taskFunction (…) { /* Prolog */ while (‘ condition ’) { SEM_pend (); /* Process */ } /* Epilog */ }

Task Code Topology: SEM Posting 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 15 February 2011 Dr. Veton Këpuska 17

Semaphore Pending: SEM_pend () 15 February 2011 Dr. Veton Këpuska 18 SEM_pend (& sem,timeout ) Count > 0 Decrement count Pend true Semaphore Structure: Non-negative 16-bit counter Pending queue (FIFO) Return TRUE Return FALSE timeout expires false Block task yes no timeout = 0 SEM posted #define SYS_FOREVER (Uns) -1 // wait forever #define SYS_POLL (Uns) 0 // don’t wait

Semaphore Post: SEM_post () 15 February 2011 Dr. Veton Këpuska 19 Task pending on sem ? Ready first waiting task Return True Task switch will occur if higher priority task is made ready Increment count False Semaphore Structure: Non-negative count Pending queue (FIFO) Post SEM_post (& sem )

Creation of SEM Object 15 February 2011 Dr. Veton Këpuska 20 Creating a new SEM Obj right click on SEM mgr select “Insert SEM” type object name right click on new SEM select “Properties” indicate desired User Comment (FYI) Initial SEM count var mySem = SEM.create (" mySem "); mySem.comment = "my SEM"; mySem.count = 0;

SEM API Summary 15 February 2011 Dr. Veton Këpuska 21 SEM_pend Wait for the semaphore SEM_post Signal the semaphore SEM_count Get the current semaphore count SEM_reset Reset SEM count to the argument-specified value SEM_new Puts specified count value in specified SEM SEM_ipost SEM_post in ISR – obsolete – use SEM_post SEM API Description SEM_create Create a semaphore SEM_delete Delete a semaphore Mod 11 SEM_pendBinary Wait for binary semaphore to = 1 SEM_postBinary Write a 1 to the specified semaphore

TSK Scheduling 15 February 2011 Dr. Veton Këpuska 22 3

Task Object 15 February 2011 Dr. Veton Këpuska 23

Creating a new TSK right click on TSK mgr select “Insert TSK” type TSK name right click on new TSK select “Properties” indicate desired priority stack properties function arguments etc Static Creation of TSK 15 February 2011 Dr. Veton Këpuska 24

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: 15 February 2011 Dr. Veton Këpuska 25 TSK_setenv ( TSK_self (),& myEnv ); hMyEnv = TSK_getenv (& myTsk ); fxn * environ * priority 6 stack * name lpf1 C fxn , eg : bk FIR inst2 myTsk fxn * environ * priority 6 stack * name lpf2 struct myEnv TSK stack struct myEnv TSK stack

15 February 2011 Dr. Veton Këpuska 26 typedef struct TSK_Stat { TSK_Attrs attrs ; // task attributes TSK_Mode mode; // running, blocked... Ptr sp; // stack ptr size_t used; // 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; struct KNL_Obj { // from KNL.h QUE_Elem ready; // ready/sem queue QUE_Elem alarm; // alarm queue elem QUE_Elem setpri; // set priority queue QUE_Handle queue; // task's ready queue Int priority; // task priority Uns mask; // 1 << priority Ptr sp; // current stack ptr Uns timeout; // timeout value Int mode; // blocked, ready, ... STS_Obj *sts; // for TSK_deltatime() Bool signalled; // woken by sem or t-out }; typedef struct TSK_Obj { // from TSK.h KNL_Obj kobj; // kernel object Ptr stack; // used w TSK_delete() size_t stacksize; // ditto Int stackseg; // stack alloc’n RAM String name; // printable name Ptr environ ; // environment pointer Int errno; // TSK_seterr()/_geterr() Bool exitflag; // FALSE for server tasks} TSK_Obj, *TSK_Handle;TSK Objecttypedef struct TSK_Config { Int STACKSEG; Int PRIORITY; size_t STACKSIZE; Fxn CREATEFXN; Fxn DELETEFXN; Fxn EXITFXN; Fxn SWITCHFXN; Fxn READYFXN;} TSK_Config;

TSK Scheduling 15 February 2011 Dr. Veton Këpuska 27 3

Review 15 February 2011 Dr. Veton Këpuska 28

TSK API Summary 15 February 2011 Dr. Veton Këpuska 29 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 TSK_exit Terminate execution of the current task TSK_getenv Get task environment TSK_setenv Set task environment TSK_getname Get task name TSK_create Create a task ready for execution TSK_delete Delete a task TSK API Description Mod 11

TSK API Summary 15 February 2011 Dr. Veton Këpuska 30 TSK_settime Set task statistics initial time TSK_deltatime Record time elapsed since TSK made ready TSK_getsts Get task STS object TSK_seterr Set task error number TSK_geterr Get task error number TSK_stat Retrieve the status of a task TSK_checkstacks Check for stack overflow TSK_disable Disable DSP/BIOS task scheduler TSK_enable Enable DSP/BIOS task scheduler TSK_getpri Get task priority TSK_setpri Set a tasks execution priority TSK_tick Advance system alarm clock TSK_itick Advance system alarm clock (ISR) TSK_sleep Delay execution of the current task TSK_time Return current value of system clock TSK_yield Yield processor to equal priority task TSK API Description Mod 8 Mod 7 21

TSK Scheduling 15 February 2011 Dr. Veton Këpuska 31 3

Lab 15 February 2011 Dr. Veton Këpuska 32

Lab 5: Task Thread - TSK 15 February 2011 Dr. Veton Këpuska 33 Audio Out (48 KHz) ADC AIC33 Audio In (48 KHz) McBSP DRR FIR.c FIR Code DAC AIC33 McBSP DXR mcbsp.c coeffs.c Coefficients BIOS\Labs\HW BIOS\Labs\Work BIOS\Labs\Algos 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]}

Lab 5: Task Thread - TSK 15 February 2011 Dr. Veton Këpuska 34 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

Lab 5 : Summary In the TCF file: replace the processing SWI with a TSKcreate 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 15 February 2011 Dr. Veton Këpuska 35

Lab 5: Procedure Overview Below are the steps required to adapt the SWI-based processing thread to a TSK-based version. If necessary, start CCS and open the solution from lab 4. Build the project and verify it performs properly In myWork.tcf : Replace the SWI that called procBuf with a TSK named tskProcBuf Create a SEM named semBufRdy In isr.c Replace the SWI_post () with a SEM_post () of semBufRdy 15 February 2011 Dr. Veton Këpuska 36

Lab 5: Procedure Overview In proc.c Add a while(1) loop around all the iterative code in procBuf . Add a SEM_pend on the newly created semaphore as the first line of the while loop Having completed the adaptation steps you can now: Build, load, run, and verify the correct operation of the new solution (optional) Relocate the initialization of the messages and toDevQ to the prolog of the TSK. While not required, this makes the TSK a more complete (and instantiable ) component Using windows explorer, copy all files from C:\BIOS\Labs\Work to C:\BIOS\mySols\05 15 February 2011 Dr. Veton Këpuska 37

Lab Details Observations: Moving from SWI to TSK showed results within 0.1% of being the sameSo… 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 15 February 2011 Dr. Veton Këpuska 38 Filter Debug Release Off 18% 4.7% On 61% 6.5% HWI – based lab 3 Filter Debug Release Off 3.8% 2.3% On 45% 3.7% SWI – based lab 4 Filter Debug Release Off 3.8% 2.5% On 45% 3.8% TSK – based lab 5

TI BIOS TSK END 15 February 2011 39 Dr. Veton Këpuska