关闭

关闭

关闭

封号提示

内容

首页 uCOSII eBook.pdf

uCOSII eBook.pdf

uCOSII eBook.pdf

上传者: 阿贵 2010-12-18 评分 0 0 0 0 0 0 暂无简介 简介 举报

简介:本文档为《uCOSII eBookpdf》,可适用于IT/计算机领域,主题内容包含PrefaceMyfirstbook,“µCOS,TheRealTimeKernel”isnowyearsoldandthepublisherhas符等。

PrefaceMyfirstbook,“µCOS,TheRealTimeKernel”isnowyearsoldandthepublisherhassoldwellover,copiesaroundtheworldWhenIwasaskedtodoasecondedition,Ithoughtitwouldbeafairlystraightforwardtaskafewcorrectionshereandthere,clarifyafewconcepts,addafunctionortwotothekernel,etcIfyouhaveacopyofthefirstedition,youwillnoticethat“µCOSII,TheRealTimeKernel”isinfactamajorrevisionForsomestrangereason,Iwasn’tsatisfiedwithminorcorrectionsAlso,whenmypublishertoldmethatthistime,thebookwouldbea‘hardcover’,IreallywantedtogiveyouyourmoneysworthInall,Iaddedmorethannewpages,andrewrotethemajorityofthepagesIdidkeepIaddedaportingguidetohelpyouportµCOSIItotheprocessorofyourchoiceAlso,IaddedachapterthatwillguideyouthroughupgradingaµCOSporttoµCOSIIThecodeforµCOSIIisbasicallythesameasthatofµCOSexceptthatitcontainsanumberofnewandusefulfeatures,ismuchbettercommented,andshouldbeeasiertoporttoprocessorarchitecturesµCOSIIoffersallthefeaturesprovidedinµCOSaswellasthefollowingnewfeatures:Afixedsizedblockmemorymanager,Aservicetoallowatasktosuspenditsexecutionforacertainamountoftime(specifiedinhours,minutes,secondsandmilliseconds),Userdefinable‘callout’functionsthatareinvokedwhen:ataskiscreated,ataskisdeleted,acontextswitchisperformed,aclocktickoccursAnewtaskcreatefunctionthatprovidesadditionalfeatures,Stackchecking,AfunctionreturningtheversionofµCOSII,AndmoreµCOSIIGoalsProbablythemostimportantgoalofµCOSIIwastomakeitbackwardcompatiblewithµCOS(atleastfromanapplication’sstandpoint)AµCOSportmightneedtobemodifiedtoworkwithµCOSIIbutatleast,theapplicationcodeshouldrequireonlyminorchanges(ifany)Also,becauseµCOSIIisbasedonthesamecoreasµCOS,itisjustasreliableIaddedconditionalcompilationtoallowyoutofurtherreducetheamountofRAM(iedataspace)neededbyµCOSIIThisisespeciallyusefulwhenyouhaveresourcelimitedproductsIalsoaddedthefeaturedescribedintheprevioussectionandcleanedupthecodeWherethebookisconcerned,IwantedtoclarifysomeoftheconceptsdescribedinthefirsteditionandprovideadditionalexplanationsabouthowµCOSIIworksIhadnumerousrequestsaboutdoingachapteronhowtoportµCOSandthus,suchachapterhasbeenincludedinthisbookforµCOSIIIntendedAudienceThisbookisintendedforembeddedsystemprogrammers,consultantsandstudentsinterestedinrealtimeoperatingsystemsµCOSIIisahighperformance,deterministicrealtimekernelandcanbeembeddedincommercialproducts(seeAppendixF,Licensing)Insteadofwritingyourownkernel,youshouldconsiderµCOSIIYouwillfind,asIdid,thatwritingakernelisnotaseasyasitfirstlooksI’massumingthatyouknowCandhaveaminimumknowledgeofassemblylanguageYoushouldalsounderstandmicroprocessorarchitecturesWhatyouwillneedtouseµCOSIIThecodesuppliedwiththisbookassumesthatyouwillbeusinganIBMPCATorcompatible(Minimum)computerrunningunderDOSxorhigherThecodewascompiledwithBorlandInternational’sCVYoushouldhaveaboutMBytesoffreediskspaceonyouharddriveIactuallycompiledandexecutedthesamplecodeprovidedinthisbookinaDOSwindowunderWindowsTouseµCOSIIonadifferenttargetprocessor(thanaPC),youwillneedtoeitherportµCOSIItothatprocessoryourselfor,obtainonefromµCOSIIofficialWEBsiteathttp:wwwuCOSIIcomYouwillalsoneedappropriatesoftwaredevelopmenttoolssuchasanANSICcompiler,anassembler,linkerlocatorandsomewayofdebuggingyourapplicationTheµCOSStoryManyyearsago,IdesignedaproductbasedonanIntelCatDynalcoControlsandIneededarealtimekernelAtmypreviousemployer,Ihadbeenusingawellknownkernel(let’scallitkernel‘A’)but,foundittobetooexpensivefortheapplicationIwasdesigningWethenfoundalowercostkernel($atthetime)andstartedourdesignwithitLet’scallthiskernel,kernel‘B’WespentabouttwomonthstryingtogetacoupleofverysimpletaskstorunWewerecallingthevendoralmostonadailybasistogethelpmakingthisworkThevendorclaimedthatthiskernelwaswritteninCHowever,wehadtoinitializeeverysingleobjectusingassemblylanguagecodeAlthoughthevendorwasverypatient,wedecidedthatwehadenoughofthisOurproductwasfallingbehindscheduleandwereallydidn’twanttospendourtimedebuggingthislowcostkernelItturnsoutthatwewereoneofthisvendor’sfirstcustomerandthekernelwasreallynotfullytestedanddebugged!Togetbackontrack,wedecidedtogobackandusekernel‘A’Thecostwasabout$fordevelopmentseatandwehadtopayaperusagefeeofabout$foreachunitthatweshipped!Thiswasalotofmoneyatthetime,butitboughtussomepeaceofmindWegotthekernelupandrunninginaboutdays!Threemonthsintotheproject,oneofourengineersdiscoveredwhatlookedlikeabuginthekernelWesentthecodetothevendorandsureenough,thebugwasconfirmedasbeinginthekernelThevendorprovidedadaywarrantybut,thathadexpiredso,inordertogetsupport,wehadtopayanaddition$peryearfor‘maintenance’WearguedwiththesalespersonforafewmonthsthattheyshouldfixthebugsincewewereactuallydoingthemafavorTheywouldn’tbudge!Finally,wegavein,weboughtthemaintenancecontractandthevendorfixedthebugsixmonthslater!Yes,sixmonthslaterWewerefuriousbutmostimportantly,latedeliveringourproductInall,ittookclosetoayeartogetourproducttoworkreliablywithkernel‘A’Imustadmit,however,thatweneverhadanyproblemswithitsinceAsthiswasgoingon,Inaivelythought,“Well,itcan’tbethatdifficulttowriteakernelAllitneedstodoissaveandrestoreprocessorregisters”That’swhenIdecidedtotryitoutandwritemyown(parttimeatnightandonweekends)Ittookmeaboutayeartogetthekerneltobejustasgood(andinsomewaysbetter)thankernel‘A’Ididn’twanttostartacompanyandsellitbecausetherewerealreadyaboutkernelsoutthereso,whyhaveanotheroneIthenthoughtofwritingapaperforamagazineIfirstwenttothe“CUser’sJournal(CUJ)”(thekernelwaswritteninC)which,Ihadheard,wasoffering$perpublishedpagewhenothermagazineswereonlypaying$perpageMypaperhadorsopagesso,thatwouldbeanicecompensationforallthetimeIspentworkingonmykernelUnfortunately,thearticlewasrejected!ThereweretworeasonsFirst,thearticlewastoolongandthemagazinedidn’twanttopublishaseriesSecond,theydidn’twanttohave‘anotherkernelarticle’IthendecidedtoturntoEmbeddedSystemsProgramming(ESP)magazinebecausemykernelwasdesignedforembeddedsystemsIcontactedtheeditorofESP(MrTylerSperry)andtoldhimthatIhadthiskernelIwantedtopublishinhismagazineIgotthesameresponsefromTylerasIdidfromtheCJournal:“Notanotherkernelarticle”Itoldhimthatthiskernelwasdifferent,itwaspreemptive,itwascomparabletomanycommercialkernelsandthathecouldputthesourcecodeontheESPBBS(BulletinBoardService)IwascallingTylertwoorthreetimesaweek(basicallybegginghim)untilhefinallygavein(hewasprobablytiredofhavingmecallhim)anddecidetopublishthearticleMyarticlegotediteddownfrompagestoaboutpagesandwaspublishedintwoconsecutivemonths(MayandJune)ThearticlewasprobablythemostpopulararticleinESPhadoverdownloadsofthecodefromtheBBSinthefirstmonthTylermayhavefearedforhislifebecausekernelvendorswereupsetthathepublishedakernelinhismagazineIguessthatthesevendorsmusthaverecognizedthequalityandcapabilitiesofµCOS(wascalledµCOSthen)Thearticlewasreallythefirstthatexposedtheinternalsofarealtimekernelso,someofthesecretswereoutJustaboutthetimethearticlecameoutinESP,IgotacallbackfromDrBernardWilliamsatRDPublications(publisherofCUJ),monthsaftertheinitialcontactwithCUJHehadleftamessagewithmywifeandtoldherthathewasinterestedinthearticle!!Icalledhimbackandtoldhimsomethinglike:“Don’tyouthinkyouarealittlebitlatewiththisThearticleisbeingpublishedinESP”Berneysaid:“No,No,youdon’tunderstand,becausethearticleissolong,Iwanttomakeabookoutofit”Initially,BerneysimplywantedtopublishwhatIhad(asis)sothebookwouldonlyhaveorsopagesIsaidtohim,“IfIgoingtowriteabook,Iwanttodoitright”IthenspentaboutmonthsaddingcontentstowhatisnowknowasthefirsteditionInall,thebookhadaboutpagestoitIchangedthenameofµCOStoµCOSbecauseESPreadershadbeencallingit‘Mucus’whichdidn’tsoundtoohealthy!Cometothinkofit,maybeitwasakernelvendorthatfirstcameupwiththenameAnyway,µCOS,TheRealTimeKernelwasthenbornSalesweresomewhatslowtostartBerneyandIprojectedthatwewouldsellabouttocopiesinthelifeofthebookbutatthatrate,wewouldbeluckyifitsoldcopiesBerneyinsistedthatthesethingstaketimetogetknownso,hecontinuedadvertisinginCUJforaboutayearAmonthorsobeforethebookcameout,IwenttomyfirstEmbeddedSystemsConference(ESC)inSantaClara,CA(September)IthenmetTylerSperryforthefirsttimeandIshowedhimthefirstdraftcopyofmybookHeveryquicklyglancedatitandsaidsomethinglike:“WouldyouliketospeakatthenextEmbeddedSystemsConferenceinAtlanta”Notknowinganybetter,Isaid“Sure,whatshouldItalkabout”Hesaidwhatabout“Usingsmallrealtimekernels”Isaid“Fine”OnthetripbackfromCalifornia,Iwasthinking“WhatdidIgetmyselfintoI’veneverspokeinfrontofabunchofpeoplebefore!WhatifImakeafoolofmyselfWhatifwhatIspeakaboutiscommonknowledgeThosepeoplepaygoodmoneytoattendthisconference”Forthenextsixmonths,IpreparedmylectureAttheconference,IhadaboutattendeesInthefirsttwentyminutesImusthavelostonepoundofsweatAftermylecture,IhadacrowdofaboutorsopeoplecomeuptomeandsaythattheywereverypleasedwiththelectureandlikedmybookIgotreinvitedbacktotheconferencebutcouldnotattendtheoneinSantaClarathatyear(ie)IwasabletoattendthenextconferenceinBoston()andIhavebeenaregularspeakeratESCeversinceForthepastcoupleofyears,I’vebeenontheconferenceAdvisoryCommitteeInowdoatleastlecturesateveryconferenceandeachhaveaverageattendanceofbetweenandpeople!MylecturesarealmostalwaysrankedamongstthetopoftheconferenceTodate,wesoldwellover,copiesorµCOS,TheRealTimeKernelaroundtheworldIreceivedandansweredwelloveremailsfromthefollowingcountries:In,µCOS,TheRealTimeKernelwastranslatedinJapaneseandpublishedinamagazinecalledInterfaceinJapanµCOShasbeenportedtothefollowingprocessors:AnalogDevicesADxxAdvancedRiscMachinesARM,ARMHitachi,Hxx,SHseriesIntelx(RealandPM),Pentium,PentiumII,,,MCS,,MitsubishiMandMMotorolaPowerPC,K,CPU,CPU,HC,HCPhilipsXASiemensCandTriCoreTexasinstrumentsTMSZilogZandZAndmoreIn,Idecidedtowritemysecondbook:EmbeddedSystemsBuildingBlocks,CompleteandReadytoUseModulesinC(ESBB)andcontainsoverpagesForsomereason,ESBBhasnotbeenaspopularasµCOSalthoughitcontainsasmuchvaluableinformationnotfoundanywhereelseIalwaysthoughtthatitwouldbeanidealbookforpeoplejuststartingintheembeddedworldIn,IopenedtheofficialµCOSWEBsitewwwuCOSIIcomIintendthissitetocontainports,applicationnotes,links,answerstofrequentlyaskedquestions(FAQs),upgradesforbothµCOSandµCOSII,andmoreAllIneedistime!Backin,IneverimaginedthatwritinganarticlewouldhavechangedmylifeasitdidImetalotofveryinterestingpeopleandmadeanumberofgoodfriendsintheprocessIstillanswereverysingleemailthatIreceiveIbelievethatifyoutakethetimetowritetomethenIoweyouaresponseIhopeyouenjoythisbookAcknowledgementsFirstandforemost,Iwouldliketothankmywifeforhersupport,encouragement,understandingandespeciallypatienceManonmusthaveheardthewords“Justonemoreweek!”aboutadozentimeswhileIwaswritingthisbookIwouldalsoliketothankmychildrenJames(age)andSabrina(age)forputtingupwiththelonghoursIhadtospendinfrontofthecomputerIhopeonedaytheywillunderstandIwouldalsoliketothankMrNiallMurphyforcarefullyreviewingmostofthechaptersandprovidingmewithvaluablefeedbackSpecialthankstoMrAlainChebrouandMrBobPaddockforpassingthecodeforµCOSIIthroughafinetoothcombIwouldliketothankallthefinepeopleatRDTechnicalbooksfortheirhelpinmakingthisbookareality,andalsoforputtingupwithmyinsistenceonhavingthingsdonemywayFinally,IwouldliketothankallthepeoplewhohavepurchasedµCOS,TheRealTimeKernelaswellasEmbeddedSystemsBuildingBlocksandwho,bydoingso,haveencouragedmetopursuethisinterestingpasttimeIntroductionThisbookdescribesthedesignandimplementationofmCOSII(pronounced"MicroCOS")whichstandsforMicroControllerOperatingSystemVersionµCOSIIisbasedonµCOS,TheRealTimeKernelwhichwasfirstpublishedinThousandsofpeoplearoundtheworldareusingµCOSinallkindsofapplicationssuchascameras,medicalinstruments,musicalinstruments,enginecontrols,networkadapters,highwaytelephonecallboxes,ATMmachines,industrialrobots,andmanymoreNumerouscollegesandUniversitieshavealsousedµCOStoteachstudentsaboutrealtimesystemsµCOSIIisupwardcompatiblewithµCOS(V)butprovidesmanyimprovementsoverµCOSsuchastheadditionofafixedsizedmemorymanager,userdefinablecalloutsontaskcreation,taskdeletion,taskswitchandsystemtick,supportsTCBextensions,stackcheckingand,muchmoreIalsoaddedcommentstojustabouteveryfunctionandImadeµCOSIImucheasiertoporttodifferentprocessorsThesourcecodeinµCOSwasfoundintwosourcefilesBecauseµCOSIIcontainsmanynewfeaturesandfunctions,IdecidedtosplitµCOSIIinafewsourcefilestomakethecodeeasiertomaintainIfyoucurrentlyhaveanapplication(ieproduct)thatrunswithµCOS,yourapplicationshouldbeabletorun,virtuallyunchanged,withµCOSIIAlloftheservices(iefunctioncalls)providedbyµCOShavebeenpreservedYoumay,however,havetochangeincludefilesandproductbuildfilesto‘point’tothenewfilenamesThisbookcontainsALLthesourcecodeforµCOSIIandaportfortheIntelxprocessorrunninginRealModeandfortheLargeModelThecodewasdevelopedonaPCrunningtheMicrosoftWindowsoperatingsystemExamplesruninaDOScompatibleboxundertheWindowsenvironmentDevelopmentwasdoneusingtheBorlandInternationalCCcompilerversionAlthoughµCOSIIwasdevelopedandtestedonaPC,mCOSIIwasactuallytargetedforembeddedsystemsandcaneasilybeportedtomanydifferentprocessorarchitecturesµCOSIIfeatures:SourceCode:AsImentionedpreviously,thisbookcontainsALLthesourcecodeformCOSIIIwentthroughalotofeffortstoprovideyouwithahighquality‘product’YoumaynotagreewithsomeofthestyleconstructsthatIusebutyoushouldagreethatthecodeisbothcleanandveryconsistentManycommercialrealtimekernelsareprovidedinsourceformIchallengeyoutofindanysuchcodethatisasneat,consistent,wellcommentedandorganizedasµCOSII’sAlso,IbelievethatsimplygivingyouthesourcecodeisnotenoughYouneedtoknowhowthecodeworksandhowthedifferentpiecesfittogetherYouwillfindthistypeofinformationinthisbookTheorganizationofarealtimekernelisnotalwaysapparentbystaringatmanysourcefilesandthousandsoflinesofcodePortable:MostofmCOSIIiswritteninhighlyportableANSIC,withtargetmicroprocessorspecificcodewritteninassemblylanguageAssemblylanguageiskepttoaminimumtomakeµCOSIIeasytoporttootherprocessorsLikeµCOS,µCOSIIcanbeportedtoalargenumberofmicroprocessorsaslongasthemicroprocessorprovidesastackpointerandtheCPUregisterscanbepushedontoandpoppedfromthestackAlso,theCcompilershouldeitherprovideinlineassemblyorlanguageextensionsthatallowyoutoenableanddisableinterruptsfromCµCOSIIcanrunonmostbit,bit,bitorevenbitmicroprocessorsormicrocontrollersand,DSPsAlltheportsthatcurrentlyexistforµCOScanbeeasilyconvertedtoµCOSIIinaboutanhourAlso,becauseµCOSIIisupwardcompatiblewithµCOS,yourµCOSapplicationsshouldrunonµCOSIIwithfewornochangesCheckfortheavailabilityofportsontheµCOSIIWebsiteat‘wwwuCOSIIcom’ROMable:µCOSIIwasdesignedforembeddedapplicationsThismeansthatifyouhavethepropertoolchain(ieCcompiler,assemblerandlinkerlocator),youcanembedµCOSIIaspartofaproductScalable:IdesignedµCOSIIsothatyoucanuseonlytheservicesthatyouneedinyourapplicationThismeansthataproductcanhavejustafewofµCOSII’sserviceswhileanotherproductcanhavethefullsetoffeaturesThisallowsyoutoreducetheamountofmemory(bothRAMandROM)neededbyµCOSIIonaproductperproductbasisScalabilityisaccomplishedwiththeuseofconditionalcompilationYousimplyspecify(through#defineconstants)whichfeaturesyouneedforyourapplicationproductIdideverythingIcouldtoreduceboththecodeanddataspacerequiredbyµCOSIIPreemptive:µCOSIIisafullypreemptiverealtimekernelThismeansthatµCOSIIalwaysrunsthehighestprioritytaskthatisreadyMostcommercialkernelsarepreemptiveandµCOSIIiscomparableinperformancewithmanyofthemMultitasking:µCOSIIcanmanageuptotasks,however,thecurrentversionofthesoftwarereserveseight()ofthesetasksforsystemuseThisleavesyourapplicationwithuptotasksEachtaskhasauniquepriorityassignedtoitwhichmeansthatµCOSIIcannotdoroundrobinschedulingTherearethusprioritylevelsDeterministic:ExecutiontimeofallµCOSIIfunctionsandservicesaredeterministicThismeansthatyou

热点搜索换一换

用户评论(0)

0/200

精彩专题

上传我的资料

每篇奖励 +2积分

资料评价:

/49
仅支持在线阅读

意见
反馈

立即扫码关注

爱问共享资料微信公众号

返回
顶部