研讨会 软件中断.pptx

上传人:莉*** 文档编号:74454828 上传时间:2023-02-26 格式:PPTX 页数:49 大小:568.01KB
返回 下载 相关 举报
研讨会 软件中断.pptx_第1页
第1页 / 共49页
研讨会 软件中断.pptx_第2页
第2页 / 共49页
点击查看更多>>
资源描述

《研讨会 软件中断.pptx》由会员分享,可在线阅读,更多相关《研讨会 软件中断.pptx(49页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、会计学1研讨会研讨会 软件中断软件中断Learning ObjectivesDescribe the basic concepts of SWIsDemonstrate how to post a SWIDescribe the SWI objectList other SWI post optionsShow how QUEues pass data between threadsAdd a SWI to an HWI-based systemT TOTechnical Training Organization2第1页/共49页HWISWI 2SWI 1IDLtime Highest Pr

2、iorityLowest PriorityRunningReadyT TOTechnical Training OrganizationSoftware InterruptsConceptsPosting a SWISWI ObjectOther SWI PostsQueues-QUELab3第2页/共49页New Paradigm:DSP/BIOS Scheduler New Paradigm:DSP/BIOS Scheduler main()initwhile(1)if(flag=1)processprintf()other.SWI_post is equivalent to settin

3、g ISR flag Scheduler replaces the while loopSWI manager is like if test with no overheadISRget buffer flag=1main()initSWIfilterLOG_printf()HWIget bufferSWI_postIDLother +instrumentationBIOS SchedulerT TOTechnical Training Organization4第3页/共49页Hardware and Software Interrupt SystemT TOTechnical Train

4、ing OrganizationHWIFast response to interruptsMinimal context switchingHigh priority for CPULimited number of HWI possibleSWILatency in response timeContext switch performedSelectable priority levelsExecution managed by scheduler DSP/BIOS provides for HWI and SWI management DSP/BIOS allows the HWI t

5、o post an SWI to the ready queueExecution flow for flexible real-time systems:INT!Hard R/T ProcessPost SWICleanup,RETURNContinue Soft R/T Processing.SWI ReadyHWISWI*buf+=*SPRR;count-;if(count=0)SWI_post(&swiFir);count=COUNT;buf=&buf2;5第4页/共49页DSP/BIOS Preemptive SchedulerHardware Interrupts(HWI)Urge

6、nt response timeOften at“sample rate”Microseconds duty cyclePreemptive or non-preemptiveSoftware Interrupts(SWI)Flexible processing timeOften at“frame rate”Milliseconds duty cyclePreemptiveIdle(IDL)Best EffortSequential ExecutionSWI_ post()ForegroundBackgroundHard Real-timeSoft Real-timeT TOTechnica

7、l Training Organization6第5页/共49页HWISWIIDLBIOS:Prioritized SchedulingHighest PriorityLowest PriorityHWICollect data into frame/buffer,perform minimum processingSWIProcess each datum in bufferIDLRuns when no real-time events are activeHWI preempt SWI-new data is not inhibited by processing of frameRun

8、ning ReadyLegendCollect SamplesPost SWIProcess Buffertime 89123T TOTechnical Training Organization7第6页/共49页State Diagrams:IDL,HWI,SWIn nIDL IDL n nLowest priority-soft real-time-no deadlineLowest priority-soft real-time-no deadlinen nIdle functions executes sequentiallyIdle functions executes sequen

9、tiallyn nPriority at which real-time analysis is passed to hostPriority at which real-time analysis is passed to hostn nHWI&SWIHWI&SWIn nEncapsulations of functions with priorities managed by DSP/BIOS kernelEncapsulations of functions with priorities managed by DSP/BIOS kerneln nRun to completion(ca

10、nnot be suspended or terminated prior to completion)Run to completion(cannot be suspended or terminated prior to completion)n nRuns only once regardless of how many times posted prior to execution Runs only once regardless of how many times posted prior to execution Return from main()InactiveReadyRu

11、nningStartedResumePreemptedStartedResumeInactiveReadyRunningCompletedPostedPreemptedCreatedT TOTechnical Training Organization8第7页/共49页HWISWI 2SWI 1IDLtime Highest PriorityLowest PriorityRunningReadyT TOTechnical Training OrganizationSoftware InterruptsConceptsPosting a SWISWI ObjectOther SWI PostsQ

12、ueues-QUELab9第8页/共49页HWISWI_a(p1)IDLSWI_b(p2)Scheduling RulesHighest PriorityLowest PriorityRunning ReadyLegendSWI_post(&mySwi):Unconditionally post a software interrupt(in the ready state)If a higher priority thread becomes ready,the running thread is preemptedSWI priorities from 1 to 14Automatic c

13、ontext switch(uses system stack)time SWI_post(&SWI_b)T TOTechnical Training Organization10第9页/共49页HWISWI_a(p1)IDLSWI_b(p1)Scheduling RulesHighest PriorityLowest PriorityRunning ReadyLegendProcesses of same priority are scheduled first-in first-outtime SWI_post(&SWI_b)T TOTechnical Training Organizat

14、ion11第10页/共49页HWISWI_a(p1)IDLSWI_b(p2)Posting a SWI from an HWIHighest PriorityLowest PriorityProblem:Scheduler not aware of interrupt!If ISR posts a higher priority SWI,the scheduler will run that SWI in the context of the HWI-not usually desiredRunning ReadyLegendSWI_post(&SWI_b)time?T TOTechnical

15、 Training Organization12第11页/共49页HWISWI_a(p1)IDLSWI_b(p2)Using the Dispatcher with HWIHighest PriorityLowest PrioritySolution:Use the Dispatcher Some APIs that may affect scheduling:SWI_post,SWI_andn,SWI_dec,SWI_inc,SWI_or,SEM_post,PIP_alloc,PIP_free,PIP_get,PIP_put,PRD_tickRunning ReadyLegendSWI_po

16、st()time T TOTechnical Training Organization13第12页/共49页Scheduling Strategiesn nMost important“Deadline Monotonic”Most important“Deadline Monotonic”n nAssign higher priority to the most important processAssign higher priority to the most important processn nRate monotonic analysisRate monotonic analy

17、sisn nAssign higher priority to higher frequency eventsAssign higher priority to higher frequency eventsn nEvents that execute at the highest rates are assigned highest Events that execute at the highest rates are assigned highest prioritypriorityn nAn easy way to assign priorities in a system!An ea

18、sy way to assign priorities in a system!n nSystems under 69%loaded Systems under 69%loaded guaranteed guaranteed to run successfully to run successfully(proofs for this in published papers)(proofs for this in published papers)n nAlso allows you to determine scheduling boundsAlso allows you to determ

19、ine scheduling boundsn nDynamic prioritiesDynamic prioritiesn nRaise process priority as deadline approachesRaise process priority as deadline approachesT TOTechnical Training Organization14第13页/共49页DSP/BIOS:Priority-Based SchedulingHWI 1HWI 2SWI 3SWI 2SWI 1MAINIDLESWI_post(&swi_name);int2rtnpost2 r

20、tnint1post3rtnpost1rtnrtnrtnClick here to skip animationT TOTechnical Training Organization15第14页/共49页Another Scheduling ExampleHWI 1HWI 2SWI 3SWI 2SWI 1MAINIDLErtnint1post2 rtnpost1 rtnrtnint2int2rtnrtnpost2 rtnrtnrtnpost3post1The BIOS Execution Graph provides this kind of information to assist in

21、temporal debuggingT TOTechnical Training Organization17第16页/共49页HWISWI 2SWI 1IDLtime Highest PriorityLowest PriorityRunningReadyT TOTechnical Training OrganizationSoftware InterruptsConceptsPosting a SWISWI ObjectOther SWI PostsQueues-QUELab18第17页/共49页Creation of SWI with Configuration ToolCreating

22、a new SWI1.right click on SWI mgr2.select“Insert SWI”3.type SWI name4.right click on new SWI5.select“Properties”6.indicate desired functionprioritymailbox valueSWI_Obj.fxnprioritymailboxarg0arg1.T TOTechnical Training Organization19第18页/共49页SWI Attributes:Manage SWI Propertiesn nAllows programmer Al

23、lows programmer to inspect and modify to inspect and modify key SWI object valueskey SWI object valuesn nDo not modify fields on preempted or ready to run SWIDo not modify fields on preempted or ready to run SWIrecommendedrecommended:implement during lower priority thread:implement during lower prio

24、rity thread n nPriority range is 1 to 14,inclusivePriority range is 1 to 14,inclusiven nExampleExample-changing a SWIs priority to 5:-changing a SWIs priority to 5:extern SWI_Obj swiProcBuf;SWI_Attrs attrs;SWI_getattrs(&swiProcBuf,&attrs);attrs.priority=5;SWI_setattrs(&swiProcBuf,&attrs);fxnarg0arg1

25、prioritymailboxSWI_AttrsSWI_Obj.fxnprioritymailboxarg0arg1.getset20第19页/共49页SWI Structures(from swi.h and fxn.h)typedef struct SWI_Attrs SWI_Fxnfxn;Argarg0;Argarg1;Intpriority;Unsmailbox;SWI_Attrs;typedef struct SWI_Obj Intlock;Ptrready;Unsmask;priority Ptrlink;Unsinitkey;reset value for SWI mailbox

26、Unsmailbox;SWI mailbox-used with SWI_or,etcFXN_Objfxnobj;Intstslock;STS_Obj*sts;implicit SWI statistical object SWI_Obj;typedef struct FXN_Obj Fxnfxn;Argarg1;Argarg0;FXN_Obj;SWI_Attrs contains the most commonly used SWI object elementsSWI_getattrs and SWI_setattrs allow well defined access to these

27、elementsSWI object can be directly access also,if desired,as per these examples:myValue=mySwi.fxnobj.arg1;mySwi.fxnobj.arg0=7;T TOTechnical Training Organization21第20页/共49页Managing Thread Priorities via GCONFDrag-and-drop SWIs in list to vary priorityPriorities range from 114Scheduler is invoked whe

28、n SWI is postedWhen scheduler runs,control is passed to the highest priority threadEqual priority SWIs run in the order postedT TOTechnical Training Organization22第21页/共49页HWISWI 2SWI 1IDLtime Highest PriorityLowest PriorityRunningReadyT TOTechnical Training OrganizationSoftware InterruptsConceptsPo

29、sting a SWISWI ObjectOther SWI PostsQueues-QUELab23第22页/共49页SWI Post and SWI Mailbox Overviewn nIf the value of the mailbox is needed by the SWI,use If the value of the mailbox is needed by the SWI,use SWI_getmbox()which returns the value of the mailbox when the SWI_getmbox()which returns the value

30、of the mailbox when the SWI was posted.SWI was posted.n nNote:this is a shadow value for use within the SWI BIOS Note:this is a shadow value for use within the SWI BIOS manages a second mailbox for the next posting of the SWImanages a second mailbox for the next posting of the SWIn nAfter each posti

31、ng,the mailbox is reset to the initial condition After each posting,the mailbox is reset to the initial condition specified in the SWI objectspecified in the SWI object Mailbox function Bitmask Counter Not Used Always PostSWI_orSWI_incSWI_post Post on mailbox=0 SWI_andnSWI_decT TOTechnical Training

32、OrganizationAPIAllows you to:SWI_incKnow how many times the SWI was posted before it ranSWI_decPost N times before the SWI is scheduled a countdownSWI_orSend a single value to the SWI when posting-signatureSWI_andnOnly post the SWI when multiple posters all have posted24第23页/共49页SWI API Summary SWI_

33、postPost a software interrupt SWI_andnClear bits from SWIs mailbox;post if becomes 0 SWI_orOr mask with value contained in SWIs mailbox field SWI_incIncrement SWIs mailbox value SWI_decDecrement SWIs mailbox value;post if becomes 0 SWI_getattrsCopy SWI attribute from SWI object to a structure SWI_se

34、tattrsUpdate SWI object attributes from specified structure SWI_getmboxObtain the value in the mailbox prior to SWI run SWI APIDescription SWI_createCreate a SWI SWI_deleteDelete a SWI SWI_disableDisable software interrupts SWI_enableEnable software interrupts SWI_getpriReturn a SWIs priority mask S

35、WI_raisepriRaise a SWIs priority SWI_restorepriRestore a SWIs priority SWI_selfReturn current SWIs object handleMod 11Mod 7T TOTechnical Training Organization25第24页/共49页T TOTechnical Training OrganizationSoftware InterruptsConceptsPosting a SWISWI ObjectOther SWI PostsQueues-QUELab26第25页/共49页msg1msg

36、2msg3QUE_Objstruct MyMessage QUE_Elem elem;first field for QUE Int x1000;array/structure sent not copy based!Message1;typedef struct QUE_Elem struct QUE_Elem *next;struct QUE_Elem *prev;QUE_Elem;Queue ConceptsQUE message is anything you like,starting with QUE_Elem QUE_Elem is a set of pointers that

37、BIOS uses to manage a double linked listItems queued are NOT copied only the QUE_Elem ptrs are managed!QUE_put(hQue,*msg3)add message to end of queue(writer)*elem=QUE_get(hQue)get message from front of queue(reader)msg1msg2msg3QUE_ObjHow do you synchronize reader and writer?T TOTechnical Training Or

38、ganization27第26页/共49页Queue UsageT TOTechnical Training OrganizationQUE Propertiesany number of messages can be passedatomic API assure correct sequencingno intrinsic semaphoreUsing QUEDeclare the QUE via the config toolDefine(typedef)the structure to queue 1st element must be“QUE_Elem”Fill the messa

39、ge(s)to QUE with the desired dataSend the data to the queue via QUE_put(&myQue,msg);Acquire data from the queue via info=QUE_get(&myQue);Application ConsiderationsTwo queues are needed to circulate messages between two threadstypedef struct MsgObj QUE_Elem elem;short *pInBuf;short *pOutBuf;MsgObj,*M

40、sg;toDevQtoProcQSWIputgetgetputHWIMain(init)putput1235428第27页/共49页Queue Lab StepsT TOTechnical Training Organization28GCONF:1.Declare 2 QUEues called toDev and toProcABOVE MAIN:2.Declare 2 Input Buffers and 2 Output Buffers3.Define a message structure to send over the QUEs:-first element of a QUE me

41、ssage must be of type QUE_Elem-payload in this lab will be 2 pointers(*pIn,*pOut)4.Declare,as globals,an array of two messages of the type created aboveIN MAIN:5.Initialize the pointers in message 1 to point to in/out buffers 16.Initialize the pointers in message 2 to point to in/out buffers 27.Prim

42、e the toDev QUE with the two messagesHWI CODING:8.At the top of the HWI,if the current buffer size drops to 0:-get a new message from the toDev QUE-extract the input buffer pointer from the message-extract the output buffer pointer from the message-as before,each time the HWI is posted:-fill 1 new i

43、nput buffer word-output 1 output buffer word9.At the bottom of the HWI,if the current buffer is full:-send the message with the current pointer set to the SWI via the toProc QUE-zero the buffer size counterSWI CODING:10.At the top of the SWI,get a message from the toProc QUE-extract the input buffer

44、 pointer from the message-extract the output buffer pointer from the message-as before,FIR filter the input buffer&store results to the output buffer11.At the end of the SWI,return the message to the HWI via the toDev QUE第28页/共49页QUE API Summary QUE_putAdd a message to end of queue atomic write QUE_

45、getGet message from front of queue atomic read QUE_enqueueNon-atomic QUE_put QUE_dequeueNon-atomic QUE_get QUE_headReturns ptr to head of queue(no de-queue performed)QUE_emptyReturns TRUE if queue has no messages QUE_nextReturns next element in queue QUE_prevReturns previous element in queue QUE_ins

46、ertInserts element into queue in front of specified element QUE_removeRemoves specified element from queue QUE_new.QUE APIDescription QUE_createCreate a queue QUE_deleteDelete a queueMod 11T TOTechnical Training Organization29第29页/共49页HWISWI 2SWI 1IDLtime Highest PriorityLowest PriorityRunningReadyT

47、 TOTechnical Training OrganizationSoftware InterruptsConceptsPosting a SWISWI ObjectOther SWI PostsQueues-QUELab30第30页/共49页Block FIR Filter OverviewRead block of data to input bufferA/DSPHWI0000012345.9596979899T TOTechnical Training Organization31第31页/共49页xc0+xc1+xc2+xc3+xc4=Block FIR Filter Overvi

48、ewRead block of data to input bufferConvolve 1st N samples with coefficientsStore result to 1st location of output bufferA/DSPHWI00000012345.9596979899T TOTechnical Training Organization32第32页/共49页xc0+xc1+xc2+xc3+xc4=Block FIR Filter OverviewRead block of data to input bufferConvolve 1st N samples w

49、ith coefficientsStore result to 1st location of output bufferRepeat convolution advanced by 1 sampleStore result to 2nd location of output bufferA/DSPHWI010000012345.9596979899T TOTechnical Training Organization33第33页/共49页xc0+xc1+xc2+xc3+xc4=Block FIR Filter OverviewRead block of data to input buffe

50、rConvolve 1st N samples with coefficientsStore result to 1st location of output bufferRepeat convolution advanced by 1 sampleStore result to 2nd location of output bufferRepeat for BLOCKSIZE iterationsA/DSPHWI0120000012345.9596979899T TOTechnical Training Organization34第34页/共49页xc0+xc1+xc2+xc3+xc4=B

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > PPT文档

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com