Кернел

Басицинтродуцтион

Thekernelisthecoreofanoperatingsystem.Itisthefirst-layersoftwareexpansionbasedonhardware,whichprovidesthemostbasicfunctionsoftheoperatingsystem.Itisthebasisfortheworkoftheoperatingsystem.Itisresponsibleformanagingthesystem’sprocesses,memory,devicedrivers,filesandnetworksystems,anddeterminestheperformanceandperformanceofthesystem.stability.

Inthemodernoperatingsystemdesign,inordertoreducetheoverheadofthesystemitself,itisoftencloselyrelatedtothehardware(suchasinterrupthandlers,devicedrivers,etc.),basic,common,andhigheroperatingfrequency.Themodules(suchasclockmanagement,processscheduling,etc.)andkeydatastructuresareseparatedtomakethempermanentinmemoryandprotectthem.Usuallythispartiscalledthekerneloftheoperatingsystem.

Programscanbedirectlytransferredtothecomputerforexecution.Thisdesignshowsthatthedesignerdoesnotwanttoprovideanyhardwareabstractionandoperatingsystemsupport.Itiscommoninthedesignofearlycomputersystems.Finally,someauxiliaryprograms,suchasprogramloaderanddebugger,aredesignedintothecoreofthemachine,orsolidifiedinread-onlymemory.Whenthesechangesoccurred,theconceptoftheoperatingsystemkernelgraduallybecameclear.

(Суммарипицтуресоурце:)

Хисторицалдевелопмент

ThefirstpublicversionofLinuxwasversion0.02inOctober1991.Twomonthslater,InDecember1991,Linuxreleasedversion0.11,whichwasthefirstindependentkernelthatcouldbeusedwithoutrelyingonMinix.

Месец дана након издавања верзије 0.12, у марту, број верзије је скочио на 0.95, што одражава да је систем постајао зрео. Не само да је то био прекретница све док две године касније, у марту 1994.1.0.0 није био завршен.

ФромТхенон, ВестартедтоусетЕтво-ВаинумберсингМетходтомарктхеДевелоптонОфКернелс.евен-НумберЕдКернелс (Суцхас1.0,2.2,2.4,2.6) Модел, АтхеСаметиме, АтхеСаметиме, Тхеодд-нумериакернелверсионс (1.1,2.3) Авеуцтинг-Есецтор "Развој" кернелс.афевмонтхсафтернелвиллбенофаневкернелвиллбегин. Међутим, развој 2.5 није почео све десетине месеци након завршетка 2.4.

Mostofthediscussioncontentofthepost-halloweendocumentisthemainchangesthatusersneedtopayattentionto,andthesystemtoolsthatneedtobeupdated(inordertotakeadvantageofthem).ThosewhocareaboutthisinformationaremainlyLinuxdistributorswhowanttoknowinadvancewhatisinthe2.6kernel,aswellasendusers,whichallowsthemtodeterminewhetherthereareprogramsthatneedtobeupgradedinordertotakeadvantageofthenewcomponents.

TheKernelJanitorsprojectmaintainsalistofminordefectsthatneedtobefixedandsolutions.Mostofthesedefectsolutionsarecausedbytheneedtochangemanypartsofthecodewhenapplyinglargerpatchestothekernel,forexample,someplaceswillaffectthedevicedriver.Thosewhoarenewlyengagedinkerneldevelopmentcanchoosetheitemsinthelistatthebeginningoftheirwork,sothattheycanlearnhowtowritekernelcodethroughsmallprojectsandhavetheopportunitytocontributetothecommunity.

Also,inanotherpre-releaseproject,JohnCherrytrackedtheerrorsandwarningsfoundwhencompilingeachreleasedkernelversion.Thesecompilationstatisticshavebeendecliningovertime,andpublishingtheseresultsinasystematicformmakestheprogressachievedataglance.Inmanycases,someofthesewarningsanderrormessagescanbeusedliketheKernelJanitorslist,becausecompilationerrorsareusuallycausedbysmalldefectsandrequiresomeefforttofix.

Finally,thereisAndrewMorton's"must-fix"list.Sincehehasbeenselectedasthemaintainerofthe2.6kernelaftertherelease,heusedhisprivilegestooutlinetheissuesthathebelievesmosturgentlyneedtoberesolvedbeforethefinal2.6kernelisreleased.Themust-fixlistcontainsthedefectsinthekernelBugzillasystem,thepartsthatneedtobecompleted,andotherknownissues.Iftheseissuesarenotresolved,itwillhinderthereleaseof2.6.Thisinformationcanhelpindicatewhatstepsareneededbeforethenewkernelisreleased;itcanalsoprovidevaluableinformationforthosewhoareconcernedaboutwhenthemuch-anticipated2.6kernelreleasewillbecompleted.

Кернелцлассифицатион

Синглекернел

Monolithickernelisaverybigprocess.Itsinteriorcanbedividedintoseveralmodules(orhierarchicalorother).Butwhenitisrunning,itisasinglebigbinaryimage.Thecommunicationbetweenthemodulesisachievedbydirectlycallingfunctionsinothermodules,ratherthanmessagetransmission.

Thesingle-corestructuredefinesahigh-levelabstractinterfaceontopofthehardware,andusesasetofprimitives(orsystemcalls)toimplementthefunctionsoftheoperatingsystem,suchasprocessmanagement,filesystem,andstorageManagementandsoon,thesefunctionsarecompletedbymultiplemodulesrunninginthecorestate.

Althougheachmoduleservestheseoperationsseparately,thekernelcodeishighlyintegratedanddifficulttowritecorrectly.Becauseallmodulesarerunningonthesamekernelspace,asmallbugcancrashtheentiresystem.However,ifthedevelopmentgoeswell,thesingle-corestructurecanbenefitfromoperatingefficiency.

Manymodernsingle-kernelstructurekernels,suchasLinuxandFreeBSDkernels,cancallmodulesintoexecutionatruntime,whichcanmakeiteasiertoexpandthefunctionsofthekernel,anditcanalsomakethecoreofthekernel.Partbecomesmoreconcise.

Single-corestructureisaveryattractivedesign,duetothecomplexityofthesystemcontrolcodethatimplementsalllow-leveloperationsinthesameaddressspace,andtheefficiencywillbehigherthanthatindifferentaddressspacessome.Thesingle-corestructureistendingtobeeasytodesigncorrectly,soitsdevelopmentwillbefasterthanthemicro-kernelstructure.

Anexampleofasingle-kernelstructure:thetraditionalUNIXkernel-suchastheversionreleasedbytheUniversityofBerkeley,theLinuxkernel.

Мицрокернел

Themicrokernel(Мицрокернелkernel)structureconsistsofaverysimplehardwareabstractionlayerandasetofkeyprimitivesorsystemcalls.TheseprimitivesonlyincludetheestablishmentofThenecessarypartsofasystem,suchasthreadmanagement,addressspace,andinter-processcommunication.

Thegoalofmicrokernelistoseparatetherealizationofsystemservicesfromthebasicoperatingrulesofthesystem.Forexample,theinput/outputlockingserviceoftheprocesscanbeprovidedbyaservicecomponentrunningoutsidethemicrokernel.Theseverymodularuser-modeserversareusedtocompletemoreadvancedoperationsintheoperatingsystem.Thisdesignmakesthedesignofthecorepartofthekerneleasier.Thefailureofaservicecomponentwillnotcausetheentiresystemtocrash.Whatthekernelneedstodoistorestartthiscomponentwithoutaffectingotherparts.

ThemicrokernelputsmanyOSservicesintoseparateprocesses,Suchasfilesystem,devicedriver,andtheprocesscallsOSservicesthroughmessagepassing.Themicro-kernelstructuremustbemulti-threaded.Thefirst-generationmicro-kernelprovidesmoreservicesinthecore,soitiscalledthe"fatmicro-kernel",anditstypicalrepresentativeisMACH.ItisbothGNUHURDandthecoreofAPPLESERVEROS.Itcanbesaidtobethriving.ThesecondgenerationprovidesonlythemostbasicOSservicesforthemicrokernel.ThetypicalOSisQNX.QNXiswell-knowninthetheoreticalworldandisconsideredanadvancedOS..

Themicrokernelonlyprovidesasmallpartofthehardwareabstraction,andmostofthefunctionsareperformedbyaspecialuser-modeprogram:theserver.Micronucleiareoftenusedintheembeddeddesignofrobotsandmedicaldevices,becausethekeypartsoftheirsystemsareinseparate,protectedstoragespaces.Thisisimpossibleforasingle-coredesign,evenifitusesthewayofloadingmodulesatruntime.

Примери микрокернела: АИКС, БеОС, Л4мицрокернелсериес,.МацхисусединГНУХурдандМацОСКС,Миник,МорпхОС,КНКС,РадиоОС,ВСта.

Хибридкернел

Thehybridkernelisverysimilartothemicro-kernelstructure,exceptthatitscomponentsrunmoreinthecorestatetoobtainfasterexecutionspeed.

Thehybridkernelisessentiallyamicrokernel,butitallowssomemicrokernelstructuretorunintheuserspacecodetoruninthekernelspace,whichmakesthekernelmoreefficient.Thisisacompromise.Thedesignerreferstothetheorythatthemicrokernelstructureofthesystemrunspoorly.However,laterexperimentsprovedthatapuremicrokernelsystemcanactuallybehighlyefficient.Mostmodernoperatingsystemsfollowthisdesigncategory,andtheWindowsoperatingsystemdevelopedbyMicrosoftisagoodexample.ThereisalsoXNU,thekernelrunningonApple'sMacOSX,whichisalsoahybridkernel.

Примери мешовитих језгара: БеОСкернел, ДрагонФлиБСД, РеацтОСкернел

WindowsNT,Windows2000,WindowsXP,WindowsServer2003andWindowsVistaandotheroperatingsystemsbasedonNTtechnology.

Спољашњи језгра

Спољашњи језграsystem,alsoknownasverticalstructureoperatingsystem,isamoreextremedesignmethod.

Theexternalkerneldoesnotprovideanyhardwareabstractoperations,butallowsadditionalruntimelibrariestobeaddedtothekernel,throughwhichapplicationscandirectlyornearlydirectlyoperateonthehardware.

Itsdesignconceptistoletthedesigneroftheuserprogramdecidethedesignofthehardwareinterface.Theouterkernelitselfisverysmall,anditisusuallyonlyresponsibleforservicesrelatedtosystemprotectionandsystemresourcereuse.

Traditionalkerneldesigns(includingsingle-coreandmicro-core)haveabstractedthehardware,hidinghardwareresourcesordevicedriversunderthehardwareabstractionlayer.Forexample,inthesesystems,ifapieceofphysicalstorageisallocated,theapplicationdoesnotknowitsactuallocation.

Thegoaloftheexternalcoreistoallowtheapplicationtodirectlyrequestaspecificphysicalspace,aspecificdiskblock,andsoon.Thesystemitselfonlyguaranteesthattherequestedresourceiscurrentlyfree,andtheapplicationallowsdirectaccesstoit.Sincetheexternalcoresystemonlyprovidesrelativelylow-levelhardwareoperations,anddoesnotprovidehigh-levelhardwareabstractionlikeothersystems,thenadditionalruntimelibrarysupportisneeded.Theseruntimelibrariesrunontheoutercoreandprovidecompletefunctionsforuserprograms.

Intheory,thisdesignallowsvariousoperatingsystemstorunonanexternalcore,suchasWindowsandUnix.Andthedesignercanadjustthefunctionsofeachpartofthesystemaccordingtotheoperatingefficiency.

Theoutercoredesignisstillintheresearchstage,andnocommercialsystemhasadoptedthisdesign.Severalconceptualoperatingsystemsarebeingdeveloped,suchasNemesisfromtheUniversityofCambridge,theCitrixsystemfromtheUniversityofGlasgow,andasystemfromtheSwissAcademyofComputerSciences.MITisalsoconductingsuchresearch.

Поређење једнојезгреног и микро језгра

Single-corestructureisaveryattractivedesign,becauseallcomplexlow-leveloperatingsystemcontrolsareimplementedinthesameaddressspaceTheefficiencyofthecodewillbehigherthantheimplementationinadifferentaddressspace.

Intheearly1990s,thesingle-corearchitecturewasconsideredobsolete.ThedesignofLinuxasasingle-kernelstructureinsteadofamicrokernelhascausednumerouscontroversies.

Single-corestructuretendstobelesserror-proneindesign,soitsdevelopmentwillbefasterthanmicro-kernelstructure.Therearesuccessfulcasesinbothcamps.

AlthoughMachisawell-knownmulti-purposemicrokernel,peoplehavedevelopedseveralothermicrokernels.L3isademonstrativekernel,justtoprovethatthemicro-kerneldesignisnotalwayslowspeed.ItssubsequentversionL4canevenusetheLinuxkernelasoneofitsprocesses,runninginaseparateaddressspace.

QNXisamicrokernelsystemthathasbeendesignedsincethe1980s.ItisclosertotheconceptofmicrokernelsthanMach.Itisusedinsomespecialfields;inthesecases,systemfailureduetosoftwareerrorsisnotallowed.Forexample,themanipulatoronthespaceshuttle,andthemachinethatgrindsthelensofthetelescope,alittlemistakecancausethousandsofdollarsinlosses.

ManypeoplebelievethatbecauseMachcannotsolvesomeoftheproblemsthatwereaddressedwhenthemicrokerneltheorywasputforward,themicrokerneltechnologyisuseless.FansofMachindicatethatthisisaverynarrowview,butunfortunatelyitseemsthateveryoneisbeginningtoacceptthisview.

Предности

Абстрацтхидинг

Thekernelprovidesahardwareabstractionmethodtocompletehardwareoperations,becausetheseoperationsareverycomplex,andhardwareabstractionhidesComplexityprovidesasetofconciseandunifiedinterfacesforapplicationsoftwareandhardware,makingprogramdesigneasier.

СоурцеЦодеМанагемент

Inhistory,therehasneverbeenaformalsourcecodemanagementorrevisioncontrolsystemfortheLinuxkernel.Infact,manydevelopershaveimplementedtheirownmodifiedcontrollers,butthereisnoofficialLinuxCVSarchivethatallowsLinusTorvaldstochecktheaddedcodeandallowotherstoobtainthecode.Fixingthelackofcontrollersoftencreatesa"generationgap"betweenreleaseversions.Noonereallyknowswhatchangeshavebeenadded,whetherthesechangescanbewellintegrated,orwhatnewcontentisworthlookingforwardtointheupcomingrelease..Generally,ifmoredeveloperscanunderstandthosechangesastheyunderstandthechangestheyhavemade,certainproblemscanbeavoided.

Itisverynecessarytouseareal-time,centralizedarchivetosavethelatestupdatestotheLinuxkernel.Everychangeorpatchacceptedbythekernelistrackedasachangeset.Endusersanddeveloperscansavetheirownsourcefilearchivesandupdatethemwiththelatestsetofchangeswithasimplecommandasneeded.Fordevelopers,thismeansthatyoucanalwaysusethelatestcopyofthecode.Testerscanusetheselogicalchangesetstodeterminewhichchangescausedtheproblemandshortenthetimerequiredfordebugging.Evenuserswhowishtousethelatestkernelcandirectlyusethereal-time,centralizedarchive,becauseoncethepartsordefectfixestheyneedareaddedtothekernel,theycanupdateitimmediately.Whenthecodeisintegratedintothekernel,anyusercanprovideimmediatefeedbackanddefectreportsonthecode.

Паралелни развој

Структура језгра (6 фотографија)

AstheLinuxkernelgrows,itbecomesmorecomplexandattractsmoreDevelopersfocusedtheirattentiononthespecializeddevelopmentofspecificaspectsofthekernel,andtherewasanotherinterestingchangeinthewayLinuxwasdeveloped.Duringthedevelopmentofthe2.3kernelversion,inadditiontothemainkerneltreereleasedbyLinusTorvalds,therearesomeotherkerneltrees.

Duringthedevelopmentof2.5,thekerneltreeexploded.Sincetheuseofsourcecodemanagementtoolscanmaintainthesynchronizationandparalleldevelopmentofdevelopment,itispossibletoachievepartialparallelizationofdevelopment.Inorderforotherstotesttheirchangesbeforetheyareaccepted,somedevelopmentneedstobeparallelized.Thosekernelmaintainerswhomaintaintheirowntreesworkonspecificcomponentsandgoals,suchasmemorymanagement,NUMAcomponents,improvedscalability,andcodeforspecificarchitectures,andsometreescollectandtrackcorrectionsformanysmalldefects.

Theadvantageofthisparalleldevelopmentmodelisthatitallowsdeveloperswhoneedtomakemajorchanges,orthosewhomakealargenumberofsimilarchangesforaspecificgoal,tofreelydevelopinacontrolledenvironment,Anddoesnotaffectthestabilityofthekernelusedbyothers.Whenthedevelopershavefinishedtheirwork,theycanreleasepatchesforthecurrentversionoftheLinuxkerneltoimplementthechangestheyhavedonesofar.Inthisway,testersinthecommunitycaneasilytestthesechangesandprovidefeedback.Aftereachparthasbeenproventobestable,thosepartscanbeintegratedintothemainLinuxkernelindividually,orevenallatthesametime.

(Sourceofsomepicturesinthealbumofthekernelstructurediagram:)

ЦодеЦоверагеАналисис

Thenewtoolprovidesthefunctionofcodecoverageanalysisforthekernel.Coverageanalysisshowswhichlinesofcodeinthekernelareexecutedwhenagiventestisrun.Moreimportantly,thecoverageanalysisindicateswhichpartsofthekernelhavenotbeentestedatall.Thisdataisimportantbecauseitpointsoutwhichnewtestsneedtobewrittentotestthosepartsofthekernelsothatthekernelcangetamorecompletetest.

Алотоинформатион

Intheprocessofdevelopingthefuture2.6Linuxkernel,inadditiontotheseautomatedinformationmanagementmethods,differentmembersoftheopensourcecommunityalsocollectandtrackAstaggeringamountofinformation.

Forexample,astatuslistwascreatedontheKernelNewbiessitetokeeptrackofthenewcomponentsofthekernelthathavebeenproposed.Thislistcontainsentriessortedbystatus.Iftheyhavebeencompleted,theyareincludedinwhichkernel,andiftheyhavenotbeencompleted,itwilltakehowlong.LinkstomanyitemsonthelistpointtotheWebsiteofalargeproject,orwhentheitemsaresmall,thelinkpointstoacopyofthee-mailmessageexplainingthecorrespondingpart.

Тестирање

Тестирање апликација

Тестбацкгроунд

Inthepast,LinuxkerneltestingmethodsrevolvedaroundopensourcecodeThedevelopmentmodeliscarriedout.Sincethecodeisreleasedtootherdevelopersforreviewonceitisreleased,therehasneverbeenaformalverificationcyclesimilartootherformsofsoftwaredevelopment.Thetheoreticalbasisbehindthismethodistheso-called"Linuslaw"in"TheCathedralandtheBazaar"(pleaserefertoreferencesforrelevantreferences).Thecontentofthislawis"people'seyesarediscerning."Inotherwords,aintensivereviewcanidentifymostoftherealbigproblems.

However,inreality,thekernelhasmanycomplexinterconnections.Evenwithsufficientreview,manyseriousflawswillstillbemissed.Inaddition,oncethelatestkernelisreleased,enduserscan(andoftendo)downloadanduseit.When2.4.0wasreleased,manypeopleinthecommunityproposedmoreorganizedteststoensuretheintensityofspecifictestsandcodereviews.Organizedtestingincludestheuseoftestplans,repeatabilityinthetestingprocess,andsoon.Usingallthreemethodswillresultinhighercodequalitythanusingonlytwomethodsinitially.

ТестПројецт

TheearliestcontributortotheorganizedtestingofLinuxwastheLinuxТестПројецт(LinuxТестПројецт,LTP).ThepurposeofthisprojectistoimprovethequalityofLinuxthroughmoreorganizedtestingmethods.Partofthistestprojectisthedevelopmentofautomatedtestsuites.ThemaintestsuitedevelopedbyLTPisalsocalledLinuxtestproject.Whenthe2.4.0kernelwasreleased,theLTPtestsuitehadonlyabout100tests.Withthedevelopmentandmaturityofthe2.4and2.5versionsofLinux,theLTPtestsuiteisalsodevelopingandmaturing.Currently,theLinuxtestprojectincludesmorethan2,000tests,andthisnumberisstillgrowing.

Регресија тестирање

Inthe2.5developmentcycle,anotheritemusedintheLinuxtestprojectistousetheLTPtestsuitetoperformregressiontestingontheLinuxkernelformultipledays.PeopleuseBitKeepertocreateareal-time,centralizedarchivetogetasnapshotoftheLinuxkernelatanytime.WhenBitKeeperandsnapshotswerenotused,testershadtowaituntilthekernelwasreleasedbeforetheycouldstarttesting.Aslongasthekernelischanged,thetestercanperformthetest.

Anotheradvantageofusingautomatedtoolstoperformregressiontestingthatlastsformanydaysisthatthechangesaresmallcomparedtotheprevioustest.Ifanewregressiondefectisfound,itisusuallyeasytodetectwhichchangethedefectmayhavecaused.

Similarly,becauseitisthelatestchange,itstillhasadeepimpressioninthedeveloper'smind-hopethiswillmakeiteasierforthemtorememberandrevisethecorrespondingcode.PerhapstheLinusLawshouldhavesuchaconclusionthatsomedefectsareeasiertofindthanothers,becausethosearetheonesdiscoveredanddealtwithbythekernelregressionteststhatlastedformanydays.Thesetestscanbeperformeddailyduringthedevelopmentcycleandbeforetheactualrelease,whichallowstesterswhoonlyfocusonthefullreleaseversiontofocusonmoreseriousandtime-consumingdefects.

Ектенсиблетестинг

AnotherteamcalledOpenSourceDevelopmentLabs(OSDL)hasalsomadeimportantcontributionstoLinuxtesting.Soonafterthe2.4kernelwasreleased,OSDLcreatedasystemcalledScalableTestPlatform(STP).STPisanautomatedtestplatformthatallowsdevelopersandtesterstorunthetestsprovidedbythesystemonOSDLhardware.Developerscanevenusethissystemtotesttheirownkernel-specificpatches.Theextensibletestplatformsimplifiestheteststeps,becauseSTPcanbuildthekernel,setupthetest,runthetest,andcollecttheresults.Thengettheresultsforin-depthcomparison.Manypeoplecannotaccesslargesystems,suchasSMPmachineswith8processors.ThroughSTP,anyonecanruntestsonlargesystemslikethis.Anotheradvantageofthissystem(STP)liesinthis.

Трацкингдефецтс

Sincethereleaseof2.4,oneofthebiggestimprovementstotheorganizedtestingoftheLinuxkernelisdefecttracking.Inthepast,defectsfoundintheLinuxkernelwerereportedtotheLinuxkernelmailinglist,tothemailinglistofspecificcomponentsorspecificsystems,ordirectlytotheindividualwhomaintainedthepartofthecodewherethedefectwasfound.WiththeincreaseinthenumberofpeopledevelopingandtestingLinux,theshortcomingsofthissystemwerequicklyexposed.Inthepast,unlesspeople'sreportsondefectscouldbemaintainedsurprisingly,defectswereoftenmissed,forgottenorignored.

OSDLhasinstalledadefecttrackingsystemtoreportandtrackdefectsintheLinuxkernel.Thesystemisconfiguredsothatwhenacomponent’sdefectisreported,themaintainerofthatcomponentwillbenotified.Themaintainercaneitheracceptandfixthedefect,orreassignthedefect(ifitisfinallydeterminedthatitisactuallyadefectinanotherpartofthekernel),orexcludeit(ifitisfinallydeterminedthatitisnotarealdefect,suchasamisconfiguredsystem).Thedefectsreportedtothemailinglistarealsoindangerofbeinglost,asmoreandmoree-mailsarefloodingtothatlist.However,inthedefecttrackingsystem,thereisalwaysarecordofeachdefectanditscurrentstatus.

Related Articles
TOP