Tornado_VxWorks培训教程_供应商官方培训教程(中文版)1

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Tornado&VxWorks••–ResponseTime–SurvivalTime–Throughput••••––––••••••••••()••••“”“”()•RTOS,(PDA)WinCE•RTOSPSOSVxWorksVRTX,VRTXVxWorks,PCQNX•–1.–2.–3.I/O––––––––•–•–•–•–•RateMonatomic/Pacing–deadlineeadline•DeadlineDriven–DeadlineDriven•–•(EmbeddedSystems)••––––•••••–•–“”“”••••–CPU–––taskInit()••••••----expireddelay•----taskSuspend()•----taskResume()/taskActivate()•----taskResume()•----taskResume()•–CPUI/OVxWorks•VxWorksWind•TCB)(TCB)•TCB•––“”context)•VxWorksVxVMIKernelTCBTCBTCBTCBTCBTCBSuspendedPendedTCBDelayedTCBReadyCPUExecuting•TCB•TCB••–––•t1t2t3t2t1ABCDABCDTimeSlicePeriod(Constant-Programmable)t4t2t3t2t1t3t2t1•••VxWorks••••VxWorksprintf•VxWorks••VxWorksI/Obuffer)I/O,VxWorks•VxWorks–•–•VxWorks–•VxWorks4•taskVarLib•POSIX•schedPxLibPOSIX1003.1b•POSIXWind–POSIXWind–POSIXWindPOSIXWindposixPriorityNumberingFALSE–POSIXVxWorksINCLUDE_POSIX_SCHEDPOSIXVxWorks•••••Real-TimeMultitaskingIntroductionTaskBasicsTaskControlErrorStatusSystemTasksOverviewLowlevelroutinestocreateandmanipulatetasksarefoundintaskLib.Donotconfuseexecutablecodewiththetask(s)whichexecuteit.AVxWorkstaskconsistsof:Astack(forlocalstorageofautomaticvariablesandparameterspassedtoroutines).ATCB(forOScontrol)Codeisdownloadedbeforetasksarespawned.Severaltaskscanexecutethesamecode(e.g.,printf()).CreatingaTasktaskSpawnStackTCBPCfoo(){...}CreatingaTaskinttaskSpawn(name,priority,options,stackSize,entryPt,arg1,...,arg10)nameTaskname,ifNULLgivesadefaultname.priorityTaskpriority,0-255.optionsTaskoptionse.g.VX_UNBREAKABLE.stackSizeSizeofstacktobeallocatedinbytes.entryPtAddressofcodetostartexecuting(initialPC)arg1,...,arg10Upto10argumentstoentrypointroutine.ReturnsataskidorERRORifunsuccessful.TaskID’sEfficient32-bithandlefortask.Assignedbykernelwhentaskiscreated.Maybereusedaftertaskexists.Ataskidofzeroreferstotaskmakingcall(self).RelevanttaskLibroutines:taskIdSelf()GetIDofcallingtask.taskIdListGet()FillarraywithID’sofallexistingtasks.taskIdVerify()VerifyataskIDisvalid.Uniquetoeachtask.TaskNamesProvidedforhumanconvenience.Typicallyusedonlyfromtheshell(duringdevelopment).Withinprograms,usetaskIds.Byconvention,startwithat.Defaultisanascendingintegerfollowingat.Promotesinterpretationasataskname.Doesn’thavetobeunique(butusuallyis).RelevanttaskLibroutines.taskName()Getnamefromtid.taskNameToId()Gettidfromtaskname.TaskPrioritiesRangefrom0(highest)to255(lowest).Nohardrulesonhowtosetpriorities.Therearetwo(oftencontradictory)“rulesofthumb”:Shorterdeadline=higherpriority.Moreimportant=higherpriority.Canmanipulateprioritiesdynamicallywith:taskPriorityGet(tid,&priority)taskPrioritySet(tid,priority)TaskStacksAllocatedfrommemorypoolwhentaskiscreated.Fixedsizeaftercreation.Thekernelreservessomespacefromthestack,makingthestackspaceactuallyavailableslightlylessthanthestackspacerequested.Exceedingstacksize(“stackcrash”)causesunpredictablesystembehavior.StackOverflowsPressthecheck-stackbutton:TocheckforastackoverflowusetheBrowser.Examinethehigh-watermarkindicatorinthestackdisplaywindow.High-waterMarkIndicator(UNIX)Note:InthePCBrowserStackCheckWindow,thehighwatermakrtrianglesarenotpresent.Instead,thenumberdisplayedinsideeachstackbaristhatstack’shighwatermark.Thefilledportionofthebarindicatesthecurrentstackusagegraphically.TaskOptionsCanbebitwiseor’edtogetherwhenthetaskiscreated.VX_FP_TASKAddfloatingpointsupport.VX_NO_STACK_FILLDon’tfillstackwith0xee’s.VX_UNBREAKABEDisablebreakpoints.VX_DEALLOC_STACKDeallocatestackandTCBwhentaskexists(automaticallysetforyou).UsetaskOptionsGet()toinquireaboutatask’soptions.UsetaskOptionsSet()tounsetVX_DEALLOC_STACK.TaskCreationDuringtimecriticalcode,taskcreationcanbeunacceptablytimeconsuming.Toreducecreationtime,ataskcanbespawnedwiththeVX_NO_STACK_FILLoptionbitset.Alternatively,spawnataskatsystemstart-up,whichblocksimmediately,andwaitstobemadereadywhenneeded.TaskDeletionDeletesthespecifiedtask.DeallocatestheTCBandstack.AnalogoustoataskDelete()ofself.exit(code)codeparametergetsstoredintheTCBfieldexitCode.TCBmaybeexaminedforpost-mortemdebuggingbyUnsettingtheVX_DEALLOC_STACKoptionor,Usingadeletehook.taskDelete(tid)ResourceReclamationContrarytothephilosophyofsharingsystemresourcesamongalltasks.Canbeanexpensiveprocess,whichmustbetheapplication’sresponsibility.TCBandstackaretheonlyresourcesautomaticallyreclaimed.Tasksareresponsibleforcleaningupafterthemselves.Deallocatingmemory.Releasinglockstosystemresources.Closingfileswhichareopen.Deletingchild/clienttaskswhenparent/serverexits.Real-TimeMultitaskingIntroductionTaskBasicsTaskControlErrorStatusSystemTasksTaskRestarttaskRestart(tid)Taskisterminatedandrespawnedwithoriginalargumentsandtid.Usuallyusedforerrorrecovery.TaskSuspend/ResumetaskSuspend(tid)Makestaskineligibletoexecute.Canbeaddedtopendedordelayedstate.taskResume(tid)Removessuspension.Usuallyusedfordebugginganddevelopmentpurposes.TaskDelayTodelayataskforaspecifiednumberofsystemclockticks.Topollevery1/7second:FOREVER{taskDelay(sysClkRateGet()/7);...}STATUStaskDelay(ticks)UsesysClkRateSet()tochangetheclockrate.Accurateonlyifclockrateisamultipleofse

1 / 74
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功