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

Slides:



Advertisements
Similar presentations
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
Advertisements

Resource management and Synchronization Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
Real-Time Library: RTX
Chung-Ta King National Tsing Hua University
CSCI 4717/5717 Computer Architecture
The Process Control Block From: A Process Control Block (PCB, also called Task Control Block or Task Struct) is.
Processes CSCI 444/544 Operating Systems Fall 2008.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
1 Computer System Overview OS-1 Course AA
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
1 CSIT431 Introduction to Operating Systems Welcome to CSIT431 Introduction to Operating Systems In this course we learn about the design and structure.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
3-1 System peripherals & Bus Structure Memory map of the LPC2300 device is one contiguous 32-bit address range. However, the device itself is made up of.
DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. D SP TEXAS INSTRUMENTS TECHNOLOGY 1.
Computer System Overview Chapter 1. Operating System Exploits the hardware resources of one or more processors Provides a set of services to system users.
MICROPROCESSOR INPUT/OUTPUT
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization 1.Introduction 2.Real-Time System Design Considerations 3.Hardware.
Copyright © 2004 Texas Instruments. All rights reserved. 1.Introduction 2.Real-Time System Design Considerations 3.Hardware Interrupts (HWI) 4.Software.
DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization 1 1.Introduction 2.Real-Time.
2-1 The critical section –A piece of code which cannot be interrupted during execution Cases of critical sections –Modifying a block of memory shared by.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
UBI >> Contents Chapter 2 Software Development tools Code Composer Essentials v3: Code Debugging Texas Instruments Incorporated University of Beira Interior.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
DSP/BIOS Scheduling Chapter 9 C6000 Integration Workshop Copyright © 2005 Texas Instruments. All rights reserved. Technical Training Organization T TO.
DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization 1.Introduction 2.Real-Time.
Code Composer Studio & DSP/BIOS
32-Bit-Digital Signal Controller Texas Instruments Incorporated
Overview Task State Diagram Task Priority Idle Hook AND Co-Routines
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization Introduction.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
MicroC/OS-II S O T R.  MicroC/OS-II (commonly termed as µC/OS- II or uC/OS-II), is the acronym for Micro-Controller Operating Systems Version 2.  It.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization 1 1.Introduction 2.Real-Time.
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
1 Run-to-Completion Non-Preemptive Scheduler. 2 In These Notes... What is Scheduling? What is non-preemptive scheduling? Examples Run to completion (cooperative)
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
DSP/BIOS Real Time Operating system using DSP /ARM processor.
DSP/BIOS System Integration Workshop Copyright © 2004 Texas Instruments. All rights reserved. T TO Technical Training Organization 1.Introduction 2.Real-Time.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Chapter 4 DSP/BIOS. DSP/BIOS Part 1 - Introduction.
Processes and threads.
Process concept.
Topics Covered What is Real Time Operating System (RTOS)
Timer and Interrupts.
Real-time Software Design
TI BIOS TSK – Task Authoring 15 November 2018 Dr. Veton Këpuska.
Multi-Threaded Systems
Processor Fundamentals
Chapter 2: The Linux System Part 3
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Chapter 3: Process Management
Presentation transcript:

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

Objectives  Describe the way BIOS can implement a time base  Setup a time base via the BIOS CLK module  Describe the results of invoking various BIOS CLK API  Set functions to run at a periodic rate via the PRD module  Describe how to implement delayed ‘one-shot’ functions  Describe how the scheduler can be managed via BIOS API  List various BIOS scheduler management API  Select and incorporate scheduler management API to obtain desired performance in a given system T TO Technical Training Organization 2

 Clock Manager : CLK  Periodic Functions : PRD  Scheduler Control API for:  HWI & IDL  SWI  TSK  Review  Lab Multi-Threading  Can BIOS keep track of time for me?  Can time instead of data availability be used to launch threads?  Can BIOS keep track of time for me?  Can time instead of data availability be used to launch threads? T TO Technical Training Organization 3

BIOS Clock Services – CLK API CPU clock  4 or 8 Timer Counter Period Timer ISR Timer Interrupt Low Rate ClockHigh Rate Clock Low Res Clock CLK API Description CLK_getltime Get low-resolution time (32-bit value) CLK_gethtime Get high-resolution time (32-bit value) CLK_getprd Get period register value CLK_countspms Get number of hardware timer counts per millisecond  CLK abstracts details of HW timer to provide low-res time / system tick  Timer period is set and CLK objects specified in BIOS configuration  CLK can drive periodic objects directly, or at different rates as PRD SWI  CLK time values are often helpful in real-time analysis (next module) CLK_countspmsCLK_getprdCLK_getltimeCLK_gethtime System Tick CLK Object(s) + x f T TO Technical Training Organization 4

Setup of CLK via Configuration Tool Setup of the CLK Module 1. right click on CLK mgr 2. select “Properties” 3. define Low res clock rate via usecs/int 4. optionally, set other parameters as desired Optional: Making a new CLK object 1. right click on CLK mgr 2. select “Insert CLK” 3. type CLK name 4. right click on new CLK 5. select “Properties” 6. type function to run T TO Technical Training Organization All CLK objects are invoked each Lo Res tick – PRD fxns can run at different intervals – next... 5

Multi-Threading  Can I have a number of functions, each invoked at a given periodic rate?  Can I invoke a function that will run once after a given time has passed?  Can I have a number of functions, each invoked at a given periodic rate?  Can I invoke a function that will run once after a given time has passed?  Clock Manager : CLK  Periodic Functions : PRD  Scheduler Control API for:  HWI & IDL  SWI  TSK  Review  Lab T TO Technical Training Organization 6

DSP/BIOS Periodic Functions  A special SWI that provides preemptive scheduling for periodic functions  While SIO indicates data available and SEM indicates posting by other thread, when time is the gating event PRD is most ideal choice  Also useful for modeling interrupts to simulate peripherals (IO devices) T TO Technical Training Organization 7

Periodic Events – PRD SWI Timer ISR System Tick CLK Object(s) PRD_clock... PRD_tick...  PRD_tick() is invoked by PRD_clock by default (also TSK_tick)  PRD_tick() may be called by any desired user function as well  PRD_tick() launches the PRD_swi which  Scans the list of PRD_obj’s  Determines if the specified time for the given PRD_obj has elapsed  If so, the function associated with the PRD_obj is called  All PRD_obj functions must complete within ONE system (PRD) tick  Recommended: make PRD_swi highest priority SWI  If routines are short and tick is long - no problem  Long functions can be broken up with posts of other threads PRD_swi PRD_obj... PRD Object Period4 FunctionfuncX() Typecontinuous Arg00 Arg10 Period # of ticks before calling fxn Function Function to execute Type Continuous or One-shot T TO Technical Training Organization 8

Setup of PRD via Configuration Tool Creating a PRD 1. right click on PRD mgr 2. select “Insert PRD” 3. type PRD name 4. right click on new PRD 5. select “Properties” 6. indicate desired period (ticks) mode function arguments  A PRD can directly launch a regular SWI by specifying:  function: _SWI_post  arg0:_mySWI allowing control of priority, and meeting requirement for all PRDs to complete before the next PRD tick T TO Technical Training Organization _myFxn 9

TCONF Setup of PRD Module & Object PRD.OBJMEMSEG = prog.get("myMEM"); where to locate PRD Objects PRD.USECLK = "true"; CLK MOD will feed PRD PRD.MICROSECONDS = ; uSecs/tick – skip if using CLK var myPrd = PRD.create(“myPrd"); create a PRD Object myPrd.period = 1024; # of ticks between calls to PRD Obj * myPrd.mode = "continuous"; type – continuous or “one-shot” myPrd.fxn = prog.extern(“_myFxn"); function PRD Obj will run myPrd.arg0 = 0; user arguments - optional myPrd.arg1 = 0; T TO Technical Training Organization * Underlying interrupt rate is largest binary number divisible into period value, so for lowest overhead, pick a binary number when possible 10

One-shot Periodic Functions  Allows delayed execution of a function by n system ticks  PRD_start() invokes each iteration of the one-shot function  PRD_stop() can be used to abort a one-shot prior to timeout  Example of use: software watchdog function Low-res clock (incremented by system tick) PRD Object X Period4 FunctionfuncX() Type 1 shot Arg00 Arg10 PRD_start() funcX() T TO Technical Training Organization 11

PRD API Description PRD_tick Advance tick counter, dispatch periodic functions PRD_start Arm a periodic function for onetime execution PRD_stop Stop a periodic function from execution PRD_getticks Get the current tick counter  Tick counter can be manually incremented by the user with PRD_tick()  One-shot periodic functions are managed with PRD_start() & PRD_stop()  Inspection of tick count is possible with PRD_getticks()  Continuous periodic functions are set up via the BIOS configuration tool and are generally not managed at run-time via BIOS API PRD API Review T TO Technical Training Organization 12

 Clock Manager : CLK  Periodic Functions : PRD  Scheduler Control API for:  HWI & IDL  SWI  TSK  Review  Lab Multi-Threading  Is it possible for me to alter the behaviour of the BIOS scheduler when the need arises? T TO Technical Training Organization 13

Scheduler Management API  Generally, threads are automatically managed by BIOS according to the priorities of each thread  Sometimes, however, it is desirable to alter the normal BIOS scheduler operation, for example:  When deadlines are approaching a thread can temporarily be given higher priority or even exclusive use of the processor  When multiple threads share a resource, priorities can be modified to avoid higher priority threads interrupting critical sections of lower priority threads  To implement time slicing amongst equal priority threads (equal threads are normally “FIFO” serviced)  To allow TSKS to ‘sleep’ for a time  In these cases, API can be invoked to alter the behaviour of the scheduler with respect to HWI, SWI, and TSK as required T TO Technical Training Organization 14

Multi-Threading What kind of control can I have on how hardware interrupts and the idle thread are scheduled by BIOS?  Clock Manager : CLK  Periodic Functions : PRD  Scheduler Control API for:  HWI & IDL  SWI  TSK  Review  Lab T TO Technical Training Organization 15

HWI_disable and _restore API oldCSR = HWI_disable(); //“critical section”... //scheduler inhibited... HWI_restore(oldCSR);  HWI_disable() Creates a period where no asynchronous events may occur  Interrupts that come in during this period will be held off until HWI is re-enabled (if a given interrupt occurs more than once in this period, the additional events will be lost)  HWI_restore() does not necessarily enable interrupts, but instead asserts to state prior to HWI_disable() T TO Technical Training Organization 16

HWI and IDL Scheduler API HWI, IDL APIDescription HWI_enableGlobally enable hardware interrupts HWI_disableGlobally disable hardware interrupts HWI_restoreRestore global interrupt enable state IDL_runMake one pass through idle functions* * Not commonly used, not callable by HWI or SWI T TO Technical Training Organization 17 Interrupt management intrinsics: Faster than the BIOS API Unsigned int_disable_interrupts(); Unsigned int_enable_interrupts(); Void_restore_interrupts(unsigned int);

Multi-Threading What kind of control can I have on how software interrupts are scheduled by BIOS?  Clock Manager : CLK  Periodic Functions : PRD  Scheduler Control API for:  HWI & IDL  SWI  TSK  Review  Lab T TO Technical Training Organization 18

Disabling & Enabling Software Interrupts  Similar to HWI_disable/_restore  Concludes with SWI_enable (not “SWI_restore”)  Acts on SWI scheduling only – HWI continue unchanged  Nestable - number of levels managed by BIOS SWI_disable(); //“critical section”... //SWI scheduler inhibited... SWI_enable(); SWI_disable(); //“critical section”... //SWI scheduler inhibited... SWI_enable(); T TO Technical Training Organization 19

Temporary Elevation of SWI Priority  SWI_raisepri() cannot lower priority (actually disables lower priority levels)  Priority returns to the original value when the SWI exits  Original Priority (“origPrio”) should be a local variable  Priority values are bit positions, not integer numbers (eg: priority 7 would be b)  To elevate a SWI above one (or several other) SWI, use in conjunction with SWI_getpri, as per the example below: origPrio = SWI_raisepri(1<<7); //critical section... //lower prio SWIs inhibited... SWI_restorepri(origPrio); origPrio = SWI_raisepri(SWI_getpri(&swiX)|SWI_getpri(&swiY)); //critical section... //SWI scheduler inhibited... SWI_restorepri(origPrio); For Priority level “X” select 1<<X as the argument to raisepri T TO Technical Training Organization 20

Why Isn’t SWI “LowerPri” Available? LowMedHigh Case 1 : Normal Preemption Case 2 : w. SWI_raisepri() Low Med*V.Hi *raised to ‘Very High’ STACK 4 5 High Case 3 : “lowered” priority? Med High*V.Lo *lowered to ‘Very Low’ x STACK 4 5 Low T TO Technical Training Organization 21

SWI Scheduler API SWI API Description SWI_disable Disable software interrupts SWI_enable Enable software interrupts SWI_getpri Return an SWI’s priority mask SWI_raisepri Temporarily raise an SWI’s priority SWI_restorepri Restore an SWI’s priority to object value SWI_self Return address of SWI’s object T TO Technical Training Organization 22

Multi-Threading What kind of control can I have on how tasks are scheduled by BIOS?  Clock Manager : CLK  Periodic Functions : PRD  Scheduler Control API for:  HWI & IDL  SWI  TSK  Review  Lab T TO Technical Training Organization 23

Disabling & Enabling Task Scheduling  Similar to SWI_disable/_enable  Acts on TSK scheduling only – SWI &HWI continue unchanged  Nestable - number of levels managed by BIOS TSK_disable(); //“critical section”... //TSK scheduler inhibited... TSK_enable(); TSK_disable(); //“critical section”... //TSK scheduler inhibited... TSK_enable(); T TO Technical Training Organization 24

Modification of a Task’s Priority  TSK_setpri() can raise or lower priority  Return argument of TSK_setpri() is previous priority  New priority remains until set again or TSK is deleted and re-created  TSK priority is an integer value: 1 to 15 (unlike SWI, using binary weighted numbers)  To suspend a TSK, set its priority to negative one (-1)  Suspended TSK not part of BIOS TSK scheduling queue  TSK can be activated at any time (by some other thread) via TSK_setpri()  Handy option for statically created TSKs that don’t need to run right away  A TSK can be suspended at any time under BIOS, by itself or another thread origPrio = TSK_setpri(TSK_self(),7); //critical section... //TSK priority increased or reduced... TSK_setpri(TSK_self(),origPrio); T TO Technical Training Organization 25

TSK_yield : Time Slicing TSK_D TSK_C TSK_B TSK_A Time Must be Equal Priority! Running Ready  TSK_yield() instructs the BIOS scheduler to move the current TSK to the end of the priority queue  If another TSK of equal priority is ready, it will then be the active TSK  This API can be invoked at any time by the active TSK or any SWI/HWI  If a PRD calls TSK_yield, time slicing amongst equal priority TSKs is achieved T TO Technical Training Organization 26

TSK_sleep and TSK_tick  TSK_sleep(Uns sleeptime)  Blocks execution of current TSK for n TSK ticks  TSK_tick()  Similar to PRD_tick for PRD SWIs  Advances the task alarm tick by one count  Default - called from PRD_clock (system tick)  If ‘ticks’ are events and not time, TSK_tick can be called from any thread  TSK_itick() is for use inside ISRs w/o dispatcher T TO Technical Training Organization 27

READY RUNNING BLOCKED TERMINATED Task Control Block Model TSK_exit() TSK_sleep() TSK_tick() TSK_yield() BIOS Startup SEM_post() SEM_pend() TSK_setpri() T TO Technical Training Organization 28

TSK Scheduler API TSK API Description TSK_disable Disable DSP/BIOS task scheduler TSK_enable Enable DSP/BIOS task scheduler TSK_self Returns address of task object TSK_getpri Get task priority TSK_setpri Set a tasks execution priority TSK_yield Yield processor to equal priority task TSK_sleep Delay execution of the current task TSK_tick Advance system alarm clock TSK_itick Advance system alarm clock (ISR) TSK_time Return current value of system clock T TO Technical Training Organization 29

Multi-Threading  Questions ? ...  Questions ? ...  Clock Manager : CLK  Periodic Functions : PRD  Scheduler Control API for:  HWI & IDL  SWI  TSK  Review  Lab T TO Technical Training Organization 30

Multi-Threading Adding 2nd thread - dummy load - LED blinker CLK/PRD API to launch dummy thread Use some sched mgmt API to influence performance Adding 2nd thread - dummy load - LED blinker CLK/PRD API to launch dummy thread Use some sched mgmt API to influence performance  Clock Manager : CLK  Periodic Functions : PRD  Scheduler Control API for:  HWI & IDL  SWI  TSK  Review  Lab T TO Technical Training Organization 31

CLK – 100mS fxnLoad() read DIP sw’s call asm fn: load (load amt spec’d by sw values) Audio Out (48 KHz) Lab 7a: Multiple Threads ADC AIC33 Audio In (48 KHz) McBSP DRR FIR.c FIR Code DAC AIC33 McBSP DXR udevCodec coeffs.c Coefficients BIOS provided BIOS\Labs\Algos  Begin with Lab 6 solution  Add Load.c and NopLoop.asm (Algos dir) to project  In TCF file: set up CLK rate, create PRD SWI running at 100mSec rate, calling fxnLoad  Build, load, run; test audio w. range of DIP cases dioCodec IOM SIO PRD SWI fxnLoad() 32 DIP Sw’s: T TO Technical Training Organization 00 none 10 low 01 hi 11 >100% 32 tskProcBuf procBuf while() SIO_reclaim(&sioIn) for (i =0, i<HIST; i ++) pIn [i-HIST] = pPriorIn ][ 2*BUF-HIST ]; if( sw0 == 1 ) FIR(in[ pIn-HIST ],out[ pOut ]) else {pOut[i]=pIn[i]} C:\ dvsdk _1_01_00_15 \ psp _1_00_02_00

Audio Out (48 KHz) Lab 7b: Multiple Threads - Improved ADC AIC33 Audio In (48 KHz) McBSP DRR FIR.c FIR Code DAC AIC33 McBSP DXR udevCodec coeffs.c Coefficients BIOS provided BIOS\Labs\Algos dioCodec IOM SIO CLK – 100mS PRD SWI Function: _ SEM_post Arg0: _mySem TSK tskLoad() SEM_pend(mySem) call fxnLoad fxnLoad() read DIP sw’s call asm fn: load (load amt spec’d by sw values)  Have PRD SWI post SEM  Put call to fxnLoad in TSK while loop  Add SEM pend to TSK while loop  Create SEM for above signalling  Build, load, run; test audio w. range of DIP cases 32 T TO Technical Training Organization DIP Sw’s: 00 none 10 low 01 hi 11 >100% 33 tskProcBuf procBuf while() SIO_reclaim(&sioIn) for (i =0, i<HIST; i ++) pIn [i-HIST] = pPriorIn ][ 2*BUF-HIST ]; if( sw0 == 1 ) FIR(in[ pIn-HIST ],out[ pOut ]) else {pOut[i]=pIn[i]} C:\ dvsdk _1_01_00_15 \ psp _1_00_02_00

T TO Technical Training Organization void fxnLoad(void) { short i; unsigned char mask, dips; static Bool blink = 0; EVMDM6437_I2C_read( I2C_GPIO_GROUP_0, &dips, 1 ); if(hw_sw0 == (dips>>4&1)) {sw0 = hw_sw0 = !(dips>>4&1);} if(hw_sw1 == (dips>>5&1)) {sw1 = hw_sw1 = !(dips>>5&1);} if( ( hw_sw2==(dips>>6&1)) | (hw_sw3== (dips>>7&1)) ){ sw2 = hw_sw2 = !(dips>>6&1); sw3 = hw_sw3 = !(dips>>7&1); } switch(2*sw2+sw3){ case (3) : for (i=0; i< 7; i++){load(5000);} case (2) : for (i=0; i<12; i++){load(5000);} case (1) : load(5500); case (0) : load( 100); } blink^=1; mask = (char)( 0x0F^((1^blink)<<2*sw2+sw3) ); EVMDM6437_I2C_write( I2C_GPIO_GROUP_1, &mask, 1 ); IDL_run(); } Load.c 34

ti Technical Training Organization 38