ILinux嵌入式实时操作系统开发与应用By杨立峰Copyright2002杨立峰II感谢感谢我的父母,因为你们教育了我IIIAbstractInthefast-changingworldofscienceandtechnology.Appearedinformationappliances,handheldandwirelessdevices.Therearemanyhardwareandsoftwaredesignchangestakingplace.Manydevicesnowfeature32-bitmicroprocessorsfromIntel,MIPSandMotorola,aswellaslargerLCDgraphicaldisplays.Inordertoleveragethesignificantresultsgainedinthelasttenyears,manydevelopersareturningtousingfriendlyuserinterfaceoperatingsystemswiththesenewembeddeddesigns.OneofthemostpromisingemergingareasseemstoberunningLinuxintheseenvironments,foracoupleofgoodreasons:Linuxonembeddedsystemsbringswithittheentirepowerofdesktopcomputing,alongwithmanysolutionsalreadyrunning.Linux,beingopensource,allowsanyaspectofthesolutiontobefullyunderstoodandthencustomizedforaparticularapplication.Linuxalsosupportsallthenewmicroprocessorstypicallyincludedinembeddeddesigns,includingStrongARM,MIPSandPowerPC.Finally,Linuxisfree,withnoroyaltypaymentsrequiredforitsuse.SousingLinuxasoperatingsystem,withaGUIsystembuilton,seemstobeagoodsolution.ForthehandleddevicesonthemarketsuchasPDA,astothepoorhardwareinolddays,thefunctionwasverysimple;wecouldhardlyseetheGUIandnetworksupport.ButrecentlywefoundthatsomeembeddedoperatingsystemssuchasWindowsCEandPalmOS,havesupportedcompleteGUIfeatures.Withthegreatperformanceimprovementofthehardware,wethinkthattheneedforembeddedOSisurgent.IgotinterestwithLinuxoperatingsystemseveralyearsago.Combinationmyspecialty,ThenIdidsomeresearchforreal-timeLinux.Basedonthesefacts,thisthesisdemonstratesarchitectureandinternalsofLinuxsystemusedonembeddedsystems.Atfirst,thethesisoutlinesthehistoryofembeddedsystemsandreal-timesystems.Chapter2describesrelatedresearchinareaofreal-timeLinuxsystems.Chapter3detailsthedesignandimplementationofreal-timeLinux.Chapter4containadiscussionoftheapplicationmodelofreal-timeLinux.Themeasurementsresultsofreal-timeLinuxperformancecanbefoundinChapter5.Thelastchaptergivessomeconclusionandforesight.Keywords:RealTimeSystem;EmbeddedSystem;RTLinux;LinuxIV摘要伴随着科技不断的日新月异推陈出新。信息家电,手持设备,无线设备等个性化设备的出现,相应的硬件和软件的迅速发展。许多设备都配有Intel,MIPS,摩托罗拉等公司生产的32位微处理器。许多开发商也开始为这些设备提供嵌入式操作系统。嵌入式系统与实时系统将会有越来越重要作用。利用Linux搭建嵌入式操作系统是近年来出现的昀令人振奋的方案。这有多方面的原因。首先,运行在嵌入式系统上的Linux能够提供全功能的桌面计算(DesktopComputing),且由于其开放代码,定制变得非常方便。其次,Linux已经支持大多数嵌入式系统上使用的芯片,包括StrongARM,MIPS和PowerPC。昀后,Linux是免费的,使用Linux不需要付出任何费用。现今风行世界的Linux操作系统,本着开放自由的精神,吸引了全世界的目光,越来越多的程序员加入到它的行列中来。所以利用Linux作为底层操作系统,在其上进行实时化改造,建立一个具有实时应用能力的操作系统是现在日益流行的嵌入式操作系统的解决方案。市场上常见的PDA等小型手持式设备上,以前由于硬件条件等的限制,我们看到功能都非常简单,没有网络、GUI等非常实用方便的功能。但昀近出现的Palm等手持式电脑或者在WindowsCE等面向嵌入式系统的操作系统上,我们已经看到了完整的网络、图形用户界面支持。随着手持式设备的硬件条件的提高,估计嵌入式系统对嵌入式操作系统的需求会越来越迫切。本人长期以来对Linux操作系统比较感兴趣,并结合本专业,对Linux应用于嵌入式实时环境进行了一定的研究。本论文基于这些事实,对面向嵌入式实时环境的Linux系统的体系结构和一些技术内幕做了较深入的探讨。论文首先概述了嵌入式系统及实时系统的发展情况。第二章介绍了在实时Linux领域的相关研究。第三章介绍了典型的实时系统RTLinux的设计与实现,第四章介绍了RTLinux的编程模型和一些应用实例。本文的第五章将对RTLinux的性能进行测试评估。昀后是一点感想和展望。关键词:Linux;RTLinux;实时系统;嵌入式系统。V目录ABSTRACT................................................................................................................I摘要........................................................................................................................II目录.......................................................................................................................III图表及程序目录........................................................................................................V缩略语.......................................................................................................................VI第一章嵌入式实时系统概况.................................................................................11.1嵌入式系统概况..........................................................................................11.1.1嵌入式技术的历史发展.......................................................................11.1.2嵌入式系统的技术特点和应用前景...................................................21.1.3典型的嵌入式系统................................................................................31.2实时系统概况..............................................................................................41.2.1什么是实时系统....................................................................................41.2.2实时操作系统的特点...........................................................................4第二章实时系统的相关研究.................................................................................62.1LINUX的分时特性....................................................................................62.2LINUX的性能测试....................................................................................82.2.1中断延迟测试........................................................................................82.2.2上下文切换测试..................................................................................112.3当前的实时操作系统...............................................................................12第三章嵌入式实时LINUX系统RTLINUX的设计与实现...........................163.1RTLINUX的结构.....................................................................................163.2中断模拟.......