Home Technique Storage System

Storage System



Introduction

Storagesystemisoneoftheimportantpartsofcomputer.Thestoragesystemprovidestheabilitytowriteandreadinformation(programsanddata)neededbythecomputertoachievethecomputer'sinformationmemoryfunction.Amulti-levelstoragearchitectureofregisters,cache,mainmemory,andexternalmemoryisoftenusedinmoderncomputersystems.

Thecoreofacomputerstoragesystemismemory,whichisanindispensablememorydeviceusedtostoreprogramsanddatainacomputer.

Internalmemory(memoryforshort)mainlystoresprogramsanddataneededbythecomputerforcurrentwork,includinghigh-speedcachememory(Cache,cacheforshort)andmainmemory.Atpresent,themaincomponentofmemoryissemiconductormemory.Externalstorage(referredtoasexternalstorage)mainlyincludesthreeimplementationmethods:magneticstorage,opticalstorage,andsemiconductorstorage.Storagemediaincludeharddisks,opticaldisks,tapes,andmobilestorage.

Themulti-levelstoragearchitectureofmoderncomputersystemsisshowninFigure6-1.Thehigherthetop,theclosertotheCPU,thefasterthememory,thesmallerthecapacity,andthehigherthepriceperbit.Usingthisorganizationmethodcanbettersolvethecontradictionbetweenstoragecapacity,speedandcost,andprovidealayerofstoragethatislogicallyequivalenttothecheapestinpriceandcapacity,andtheaccessspeedisclosetothefastestinthestoragesystem.Storagesystemoflayeredmemory.

Development

Ifthecomputer'sexternalstoragesystemhasbeendevelopedsince1956whenIBMproducedthefirstharddisk,ithasbeendevelopedformorethanhalfacentury.Inthepasthalfcentury,storagemediaandstoragesystemshaveachievedgreatdevelopmentandprogress.

Intheearlydaysofdatastorage,devicessuchasdiskarraysweregenerallyusedasperipherals,andtheserversweredirectlyconnectedforstorage.Inrecentyears,withthedevelopmentofnetworktechnology,thedatareadingrangeoftheserverhasalsobeengreatlyexpanded,graduallyrealizingthecurrentnetworkstorage.Comparedwithtraditionalstorage,theadvantagesofnetworkstoragearemoreprominent.Itisnotonlyconvenienttoinstallandlowincost,butalsoabletoexpandstoragedevicesonalargescale,thuseffectivelymeetingthestoragespacerequirementsofmassivedatastorage.However,networkstorageconsumesalotofnetworkresources,whichisadifficultproblem.Forthisreason,SANstoragearchitecturegraduallyappeared.

Traditionalstoragesystem

Currently,therearethreemainarchitecturesoftraditionalstoragesystems,includingDAS,NASandSAN.

1.DAS(Direct-AttachedStorage,Direct-AttachedStorage)

Asthenameimplies,thisisastoragemethodinwhichstoragemediasuchasharddisksaredirectlyconnectedtothehostthroughabusadapter.Thereisusuallynonetworkequipmentinvolvedbetweenthestoragedeviceandthehost.ItcanbesaidthatDASisthemostprimitiveandbasicstoragearchitecture,anditisalsothemostcommononpersonalcomputersandservers.TheadvantagesofDASareitssimplestructure,lowcost,andhighefficiencyofreadingandwriting.Thedisadvantageisthatithaslimitedcapacityandisdifficulttoshare,whichmakesiteasytoform"informationislands."

2.NAS(Network-AttachedStorage,networkstoragesystem)

NASisanetworkstoragesystemthatprovidesfile-levelaccessinterfaces,usuallyusingnetworkfilessuchasNFS,SMB/CIFS,etc.Sharingagreementforfileaccess.NASsupportssimultaneousaccessbymultipleclientsandprovidesalarge-capacitycentralizedstoragefortheserver,whichalsofacilitatesdatasharingduringtheserviceperiod.

3.SAN(StorageAreaNetwork,storageareanetwork)

Setupadedicatedstoragenetworkbetweenserversandstoragedevicessuchasdiskarraysthroughhigh-speednetworkequipmentsuchasfiberswitchestoprovidehighperformanceStoragesystem.

ThedifferencebetweenSANandNASisthatitprovidesablock-levelaccessinterface,andgenerallydoesnotprovideafilesystematthesametime.Undernormalcircumstances,theserverneedstomaptheSANstoragetoalocaldiskthroughanaccessprotocolsuchasSCSI,anduseitaftercreatingafilesystemonit.Atpresent,mainstreamenterprise-levelNASorSANstorageproductscangenerallyprovideTB-levelstoragecapacity,andhigh-endstorageproductscanalsoprovideuptoseveralpetabytesofstoragecapacity.

Distributedstoragesystem

Bigdatahasledtoanexplosivegrowthintheamountofdata.Traditionalcentralizedstorage(suchasNASorSAN)can’tperformwellintermsofcapacityandperformance.Meettheneedsofbigdata.Therefore,distributedstoragewithexcellentscalabilityhasbecomethemainstreamarchitectureforbigdatastorage.Distributedstoragemostlyusesordinaryhardwareequipmentastheinfrastructure,sothestoragecostperunitcapacityisalsogreatlyreduced.Inaddition,distributedstoragealsohasdifferentdegreesofadvantagesintermsofperformance,maintainability,anddisastertolerance.

Thekeytechnicalissuesthatadistributedstoragesystemneedstosolveincludescalability,dataredundancy,dataconsistency,globalnamespacecaching,etc.Fromanarchitecturalpointofview,distributedstoragecanbedividedintoTherearetwotypes:C/S(ClientServer)architectureandP2P(Peer-to-Peer)architecture.Ofcourse,therearealsosomedistributedstoragesystemswherethesetwoarchitecturesexistatthesametime.

Anothercommonproblemfacedbydistributedstorageishowtoorganizeandmanagemembernodes,andhowtoestablishthemappingrelationshipbetweendataandnodes.Thedynamicincreaseordepartureofmembernodescanbasicallyberegardedasanormalstateinadistributedsystem.

TheCAPtheoryofdistributedsystemdesignproposedbyEricBrewerin2000pointedoutthatadistributedsystemcannotguaranteethethreeelementsofconsistency,availability,andpartitiontoleranceatthesametime.Therefore,anydistributedstoragesystemcanonlyoptimizetwoofitselementstothegreatestextentbasedonitsspecificbusinesscharacteristicsandspecificneeds.Ofcourse,inadditiontothethreedimensionsofconsistency,availability,andpartitiontolerance,adistributedstoragesystemoftenhasdifferenttrade-offsinfeaturedesignaccordingtospecificservices,suchaswhetheritneedsacachemoduleandwhetheritsupportscommonfiles.Systeminterface,etc.

Cloudstorage

Cloudstorageisanonlinestoragesystemprovidedbythird-partyoperators,suchasonlinestoragesystemsforindividualusersandfile,blockorobjectstoragesystemsforenterprises,etc..Cloudstorageoperatorsareresponsibleforthedeployment,operation,andmaintenanceofdatacenters,andprovidedatastoragepackagestocustomersintheformofservices.Asoneoftheextensionsandimportantcomponentsofcloudcomputing,cloudstorageprovidesdatastorageservicesof"distributionondemandandbillingbyvolume".Therefore,usersofcloudstoragedonotneedtobuildtheirowndatacentersandinfrastructure,nordotheyneedtocareaboutthemanagementandmaintenanceoftheunderlyingstoragesystem,andcandynamicallyexpandorreducetheirdemandforstoragecapacityaccordingtotheirbusinessneeds.

Cloudstorageusesoperatorstocentrallyanduniformlydeployandmanagestoragesystems,whichreducesthecostofdatastorage,therebyloweringthebarrierstoentryforthebigdataindustry,andhelpingsmallandmedium-sizedenterprisestoenterthebigdataindustry.Providespossibilities.Forexample,thewell-knownonlinefilestorageserviceproviderDropboxisbasedontheonlinestoragesystemS3providedbyAWS(AmazonWebServices).Beforetheriseofcloudstorage,itwasalmostimpossibletostartastartuplikeDropbox.

Thestoragesystemsusedbehindcloudstorageactuallymostlyusedistributedarchitecture,andcloudstoragehasalsoencounterednewproblemsandrequirementsindesignduetoitsmorenewapplicationscenarios.Forexample,cloudstoragemostlyneedstosolvehowtosupportmulti-tenantaccessinthemanagementsystemandaccessinterface.Inamulti-tenantenvironment,itisinevitabletosolveaseriesofproblemssuchassecurityandperformanceisolation.Inaddition,cloudstorageisthesameascloudcomputing.Acommonproblemthatneedstobesolvedistheissueoftrust—howtotechnicallyensuretheprivacyandsecurityofenterprisebusinessdataonthethird-partystorageserviceproviderplatform.Itisatechnicalchallengethatmustbesolved.

Storageisprovidedtousersintheformofservices,andcloudstoragegenerallyadherestothecharacteristicsofsimplicityandeaseofuseintheaccessinterface.Forexample,Amazon'sS3storageaccessesdatathroughastandardHTTPprotocolandasimpleRESTinterface.UsersuseHTTPmethodssuchasGet,Put,andDeletetoobtain,store,anddeletedatablocks.Forthesakeofeaseofoperation,AmazonS3servicedoesnotprovideoperationssuchasmodificationorrenaming;atthesametime,AmazonS3servicedoesnotprovideacomplexdatadirectorystructurebutonlyprovidesaverysimplehierarchicalrelationship;userscancreatetheirownDatabucket(bucket),andalldataisstoreddirectlyinthisbucket.Inaddition,cloudstoragehastosolvetheproblemofusersharing.ThedatainAmazonS3storageisdirectlyaccessedandidentifiedthroughauniqueURL.Therefore,aslongasotherusersareauthorized,theycanaccessthroughtheURLofthedata.

Storagevirtualizationisanimportanttechnicalfoundationofcloudstorage.Itisatechnologythatunifiesmultipleisolatedstoragesystemsintoanabstractresourcepoolbyabstractingandencapsulatingthephysicalcharacteristicsoftheunderlyingstoragesystem.Throughstoragevirtualizationtechnology,cloudstoragecanachievemanynewfeatures.Forexample,thelogicalisolationofuserdata,thestreamlinedconfigurationofstoragespace,etc.

Hierarchicalstructure

Thehierarchicalstructureofthestoragesystemcanbedividedintofivelevels:registerset,cache,mainmemory,virtualmemoryandexternalmemory.Amongthem,theregistergroupisalwaysinsidetheCPU,andtheprogrammercanaccessitthroughtheregistername.Thereisnobusoperation,andtheaccessspeedisthefastest;theremaining4levelsarealloutsidetheCPU.Cacheandmainmemoryconstitutetheinternalstoragesystem,andtheprogrammercanaddressthroughthebus.Theaccessspeedofthememoryunitisworsethanthatoftheregister;thevirtualmemoryistransparenttotheprogrammer;theexternalstoragesystemhasalargecapacityandneedstoexchangedatawiththeCPUthroughtheI/Ointerface,andtheaccessspeedistheslowest.

Cachememory

Theoriginalmeaningofcachememory(Cache)referstoatypeofRAMthathasafasteraccessspeedthangeneralrandomaccessmemory(RAM).Generallyspeaking,,Itdoesnotusedynamicrandomaccessmemory(DARM)technologylikethemainmemoryofthesystem,butusesexpensivebutfasterstaticrandomaccessmemory(SRAM)technology.

Thehigh-speedbuffermemoryisaprimarymemorybetweenthemainmemoryandtheCPU.Itiscomposedofastaticmemorychip(SRAM).Ithasasmallcapacitybutamuchfasterspeedthanthemainmemory.ItsmostimportantindicatorIsitshitrate.Theschedulingandtransferofinformationbetweenthecachememoryandthemainmemoryareautomaticallyperformedbythehardware.

Compositionstructure

Thecachememoryismainlycomposedofthefollowingthreeparts:

  1. Cachememorybank:Storetheinstructionsanddatatransferredfromthemainmemory.Storage System

  2. Addressconversioncomponent:Createadirectorytabletoconvertthemainmemoryaddresstothecacheaddress.

  3. Replacecomponent:Whenthecacheisfull,performdatareplacementaccordingtoacertainstrategy,andmodifythedirectorytableintheaddresstranslationcomponent.

Workingprinciple

High-speedmemoryisusuallycomposedofhigh-speedmemory,Lenovomemory,replacementlogiccircuitandcorrespondingcontrolcircuitcomposition.Inacomputersystemwithacachememory,theaddressoftheprocessortoaccessthemainmemoryisdividedintothreefields:rownumber,columnnumber,andgroupaddress.Therefore,themainmemoryislogicallydividedintoseveralrows:eachrowisdividedintoseveralmemorycellgroups;eachgroupcontainsseveralordozensofwords.High-speedmemoryisalsodividedintorowsandcolumnsofmemorycellgroupsaccordingly.Bothhavethesamenumberofcolumnsandthesamegroupsize,butthenumberofrowsinthehigh-speedmemoryismuchsmallerthanthatinthemainmemory.

Lenovomemoryisusedforaddressassociationandhasstorageunitswiththesamenumberofrowsandcolumnsashigh-speedmemory.Whenamemorycellgroupinacertaincolumnandrowofthemainmemoryistransferredtoanemptymemorycellgroupinthesamecolumnofthehigh-speedmemory,thememorycellcorrespondingtotheLenovomemoryrecordstherownumberofthetransferredmemorycellgroupinthemainmemory.

Whentheprocessoraccessesthemainmemory,thehardwarefirstautomaticallydecodesthecolumnnumberfieldoftheaccessaddress,soastocombinealltherownumbersoftheLenovomemorywiththerownumberofthemainmemoryaddressFieldsarecompared.Iftheyarethesame,itindicatesthatthemainmemoryunittobeaccessedisalreadyinthehigh-speedmemory,whichiscalledahit.Thehardwaremapstheaddressofthemainmemorytotheaddressofthehigh-speedmemoryandexecutestheaccessoperation;iftheyarenotthesame,thenIndicatesthattheunitisnotinthehigh-speedmemory,whichiscalledfailure.Thehardwarewillperformtheoperationofaccessingthemainmemoryandautomaticallytransferthemainmemorycellgroupwheretheunitislocatedintotheemptymemorycellgroupinthesamecolumnofthehigh-speedmemory.TherownumberofthegroupinthemainmemoryisstoredintheunitatthecorrespondinglocationoftheLenovomemory.

Whenafailureoccursandthereisnoemptypositioninthecorrespondingcolumnofthehigh-speedmemory,acertaingroupinthecolumniseliminatedtomakeroomforthenewlytransferredgroup,whichiscalledreplacement.Therulesfordeterminingreplacementarecalledreplacementalgorithms.Commonlyusedreplacementalgorithmsincludeleastrecentlyusedalgorithm(LRU),first-infirst-outmethod(FIFO),andrandommethod(RAND).Thereplacementlogiccircuitperformsthisfunction.Inaddition,whenperformingawriteoperationtothemainmemory,inordertomaintaintheconsistencyofthecontentsofthemainmemoryandthehigh-speedmemory,thehitsandfailuresarehandledseparately.

Addressmappingandconversion

Addressmappingreferstothecorrespondencebetweentheaddressofacertaindatainthemainmemoryandtheaddressinthecacherelation.Herearethreeaddressmappingmethods:

1.Fullyassociativemethod

Theaddressmappingruleofthefully-associatedmethodis:anypieceofthemainmemorycanbemappedtotheCacheAnypiece.Thebasicrealizationideais:1)Themainmemoryandthecachearedividedintodatablocksofthesamesize;2)Acertaindatablockofthemainmemorycanbeloadedintoanyspaceofthecache.

ThedirectorytableisstoredinLenovomemoryandconsistsofthreeparts:theblockaddressofthedatablockinthemainmemory,theblockaddressafterstoringitinthecache,andtheeffectivebit(alsocalledtheloadbit).Sinceitisafullyassociativemethod,thecapacityofthedirectorytableshouldbethesameasthenumberofblocksinthecache.

Theadvantageofthefullassociativemethodisthatthehitrateisrelativelyhigh,andtheCachestoragespaceutilizationrateishigh;thedisadvantageisthatwhenaccessingtherelatedmemory,itmustbecomparedwiththeentirecontenteverytime,andthespeedislowandthecostishigh.Lessapplications.

2.Directassociativemethod

TheaddressmappingruleofthedirectassociativemethodisthatablockinthemainmemorycanonlybemappedtoaspecificblockintheCache.Thebasicrealizationideais:

1)Themainmemoryandthecachearedividedintodatablocksofthesamesize;

2)Themainmemorycapacityshouldbeanintegermultipleofthecachecapacity,andthemainmemoryspaceDivideintoareasaccordingtothecachecapacity,thenumberofblocksineachareaof​​themainmemoryisequaltothetotalnumberofblocksinthecache;

3)AblockofthemainmemorycanonlybestoredinthecachewhenitisstoredinthecachePositionwiththesameblocknumber.

Datablockswiththesameblocknumberineachareaof​​themainmemorycanbetransferredtotheaddresswiththesameblocknumberinthecache,butonlyoneblockcanbestoredinthecacheatthesametime.Sincethetwofieldsofthemainblocknumberandthecacheblocknumberandtheaddressintheblockarecompletelythesame,onlytheareacodeofthetransferredblockcanberecordedwhenthedirectoryisregistered.Thedirectorytableisstoredinhigh-speedandsmall-capacitymemory,andincludestwofields:theareanumberofthedatablockinthemainmemoryandtheeffectivebit.Thecapacityofthedirectorytableisthesameasthenumberofcachedblocks.

Theadvantageofthedirectassociativemethodisthattheaddressmappingmethodissimple.Whenaccessingdata,youonlyneedtocheckwhethertheareacodeisequal,soyoucangetfasteraccessspeedandsimplehardwareequipment;thedisadvantageisthereplacementoperationFrequent,thehitrateisrelativelylow.

3.Group-associativemappingmethod

Theaddressmappingruleofthegroup-associativemappingmethodisthatablockinthemainmemorycanonlybestoredinanyblockofthesamegroupnumberinthecache.Thebasicrealizationideais:

1)Themainmemoryandcachearedividedintoblocksaccordingtothesamesize;

2)Themainmemoryandcachearedividedintogroupsaccordingtothesamesize:

3)Themainmemorycapacityisanintegermultipleofthecachecapacity.Themainmemoryspaceisdividedintoareasaccordingtothesizeofthecachearea.Thenumberofgroupsineachareaof​​themainmemoryisthesameasthenumberofgroupsinthecache;

4)Whenthedatainthemainmemoryistransferredtothecache,thegroupnumbersofthemainmemoryandthecacheshouldbeequal,thatis,ablockineachareacanonlybestoredinthespaceofthesamegroupnumberinthecache,buttheblocksinthegroupcanbearbitrarilyStorage,thatis,thedirectmappingmethodisadoptedfromthegroupinthemainmemorytothegroupinthecache:afullyassociativemappingmethodisadoptedinthetwocorrespondinggroups.

Theconversionbetweenthemainmemoryaddressandthecacheaddressconsistsoftwoparts:thegroupaddressadoptsthedirectmappingmethodandisaccessedbyaddress;whiletheblockaddressadoptsthefullyassociativemethodandisaccessedbycontent.

Theadvantageofthegroupassociativemappingmethodisthatthecollisionprobabilityoftheblockisrelativelylow,theutilizationrateoftheblockisgreatlyimproved,andthefailurerateoftheblockissignificantlyreduced:thedisadvantageisthatthedifficultyandcostofimplementationarehigherthanthatofthedirectmappingmethod..

Memory

Memory(Memory),alsoknownasinternalmemoryormainmemory,ismadeofsemiconductordevices.ItisoneoftheimportantpartsofacomputerandisdirectlyaddressablebytheCPU.Thestoragespaceischaracterizedbyfastaccessspeed.Allprogramsinthecomputerareruninthememory,sotheperformanceofthememoryhasagreatimpactonthecomputer.ThefunctionofthememoryistotemporarilystorethearithmeticdataintheCPUandthedataexchangedwithexternalstoragesuchasharddisks.Aslongasthecomputerisrunning,theCPUwilltransferthedatathatneedstobecalculatedintothememoryforcalculation,andwhenthecalculationiscompleted,theCPUwilltransmittheresult.

Theprogramsweusuallyuse,suchasWindowsoperatingsystem,typingsoftware,gamesoftware,etc.,aregenerallyinstalledonexternalstoragesuchasharddisks,buttheirfunctionscannotbeusedalone.TheymustbeinstalledOnlywhenitisloadedintothememorytorun,canwereallyuseitsfunctions.Weusuallyenteraparagraphoftextorplayagame,infact,itisalldoneinthememory.Justlikeinastudyroom,thebookshelvesandbookcasesstoringbooksareequivalenttotheexternalstorageofthecomputer,andthedeskwhereweworkisthememory.Usuallywestorealargeamountofdatatobestoredpermanentlyonexternalmemory,andputsometemporaryorasmallamountofdataandprogramsinthememory.Ofcourse,theperformanceofthememorywilldirectlyaffecttheoperatingspeedofthecomputer.

Memoryincludestwotypesofread-onlymemory(ROM)andrandomaccessmemory(RAM).

Read-onlymemory(ROM)

Read-onlymemoryisROM(ReadOnlyMemory)).WhentheROMismanufactured,theinformation(dataorprogram)isstoredandpermanentlystored.Theinformationcanonlyberead,notwritten,andthedatawillnotbelostevenifthemachineispoweredoff.ROMisgenerallyusedtostorebasiccomputerprogramsanddata,suchasBIOSROM.Itsphysicalappearanceisgenerallyadualin-line(DIP)integratedblock.

RandomAccessMemory(RAM)

RandomAccessMemoryisRAM(RandomAccessMemory),whichmeansthatdatacanbereadfromorwrittento.Whenthepowerofthemachineisturnedoff,thedatastoredinitwillbelost.Thememorymodule(SIMM)thatweusuallybuyorupgradeisusedasthecomputer'smemory.ItisasmallcircuitboardthatintegratestheRAMintegratedblockandplugsitintothememoryslotinthecomputertoreducetheRAMintegratedblockoccupancySpace.

Finallyintroducethetwoconceptsofphysicalmemoryandstorageaddressspace.Theyaretwodifferentconcepts,butbecausethereisaverycloserelationshipbetweenthetwo,andtheybothuseB,KB,MB,andGBtomeasuretheircapacity,itiseasytocauseconfusion.Physicalmemoryreferstoaspecificmemorychipthatactuallyexists.Forexample,thememorybarinstalledonthemotherboardandtheROMchiploadedwiththesystemBIOS,thedisplayRAMchiponthedisplaycardandtheROMchiploadedwiththedisplayBIOS,andtheRAMchipsandROMchipsonvariousadaptercardsareallphysicalmemories.Thestorageaddressspacereferstotherangeofmemoryencoding(encodingaddress).Theso-calledencodingistoassignanumbertoeachphysicalstorageunit(abyte),usuallycalled"addressing".Thepurposeofassigninganumbertoastorageunitistofinditeasilyandcompletethereadingandwritingofdata.Thisistheso-called"addressing",sosomepeoplealsocallthestorageaddressspaceaddressingspace.

Thesizeofthestorageaddressspaceandthesizeofthephysicalmemoryarenotnecessarilyequal.Letmegiveanexampletoillustratethisproblem:Thereare17roomsonafloor,andtheirnumbersare801~817.These17roomsarephysical,andtheiraddressspaceusesathree-digitcode,rangingfrom800to899,atotalof100addresses.Itcanbeseenthattheaddressspaceislargerthantheactualnumberofrooms.Formicrocomputersabove386,theaddressbusis32bits,sotheaddressspacecanreach2B,thatis,4GB.

Non-VolatileMemory(NVM)

Thenon-volatilememory(Non-Volatilememory,NVM)thathasappearedinrecentyearsischaracterizedbyitshighintegrationFeaturessuchashighspeed,lowenergyconsumption,non-volatility,andbyteaddressinghavereceivedwidespreadattention.Academiaandindustryhavedevelopedsomenewnon-volatilestoragemediaandtechnologies,suchasMagneticRAM(MRAM),SpinTransferTorqueRAM(STT-RAM),andPhaseChangeMemory(PhaseChangeMemory,PCM),resistiveRAM(RRAM),ferroelectricRAM(FerroelectricRAM,FeRAM),etc.Themainparametersofseveralmainstreamnewstoragedevicesarelistedinthetable.Itcanbeseenfromthetablethatnon-volatilestoragehasgoodperformanceintermsofintegrationandreadspeed,andisacandidateforconstructingpotentialnewstoragedevices.However,non-volatilestoragealsohasseveralobviousshortcomings:1)Ithasalargewritedelay,whichisanorderofmagnitudelargerthanthecorrespondingstoragemedium,andthewritedelayisgreaterthanthereaddelay,thatis,readandwriteareinconsistent.2)Althoughthereadoperationofnon-volatilestorageisfasterthanthewriteoperation,itisstillslowerthanthereadoperationoftraditionalstoragemedia;3)Thewritelifeofnon-volatilestorageislimited.Inthecaseofcontinuouswriting,thestorageunitisveryItwillsoonexpire.

Disk

Diskisthemostcommonlyusedexternalstorage.Itisaroundmagneticdiskpackedinasquaresealedbox.ThepurposeofthisistopreventthediskThesurfaceisscratched,causingdataloss.Thedatainformationstoredonthediskcanbestoredforalongtimeandcanbeusedrepeatedly.Disksaredividedintofloppydisksandharddisks.Atpresent,floppydiskshavebeenbasicallyeliminated.Computerswidelyuseharddisks.Wecancompareittoalargewarehouseforcomputerstostoredataandinformation.

Typesandcompositionofharddisks

ThetypesofharddisksmainlyincludeSCSI,IDE,andthepopularSATA.Therearecertainstandardsfortheproductionofanykindofharddisk.Withtheupgradeofthecorrespondingstandard,theharddiskproductiontechnologyisalsoupgrading.Forexample,theSCSIstandardhasgonethroughSCSI-1,SCSI-2andSCSI-3.Atpresent,weoftenvisitthewebsiteTheUltral-160seenbytheserverisbasedontheSCSI-3standard.IDEfollowstheATAstandard,andthecurrentpopularSATAisanupgradedversionoftheATAstandard.IDEisaparallelportdevice,whileSATAisaserialport.SATAwasdevelopedtoreplaceIDE.

Generallyspeaking,nomatterwhatkindofharddiskis,itiscomposedofdisk,head,spindle,controlmotor,headcontroller,dataconverter,interface,cache,etc.

TheharddiskstructureisshowninFigure2-6.Alldiscsarefixedonarotatingshaft,whichisthediscspindle.Allthediscsareabsolutelyparallel.Thereisamagneticheadonthestoragesurfaceofeachdisc,andthedistancebetweenthemagneticheadandthediscissmallerthanthediameterofthehair.Alltheheadsareconnectedtoaheadcontroller,andtheheadcontrollerisresponsibleforthemovementofeachhead.Themagneticheadcanmoveradiallyalongtheradiusofthedisc(actuallyitisanobliquetangentialmovement).Eachmagneticheadmustalsobecoaxialatthesametime,thatis,whenviewedfromdirectlyabove,allmagneticheadsoverlapatalltimes(However,thereisalreadyamulti-headindependenttechnology,whichisnotsubjecttothislimitation).Thediscrotatesatahighspeedataspeedofthousandsofrevolutionsperminutetotensofthousandsofrevolutionsperminute,sothatthemagneticheadcanreadandwritedataataspecifiedlocationonthedisc.

Theworkingprincipleofharddisks

1.Disksurface

Thedisksofharddisksgenerallyusealuminumalloymaterialsasthesubstrate,high-speedharddisksItisalsopossibletouseglassasthesubstrate.Eachdiskofaharddiskhastwosides,namelytheupperandlowersides.Generally,eachsidewillbeusedtostoredataandbecomeaneffectivedisksurface.Therearealsoveryfewharddiskswithoddnumberofsides.Eachsucheffectivediskhasadisknumber,whichisnumberedsequentiallyfromtoptobottom,startingfrom0.Intheharddisksystem,thedisksurfacenumberisalsocalledtheheadnumber,becauseeachvaliddisksurfacehasacorrespondingreadandwritehead.Thedisksetofharddiskshas2to14platters,usually2to3platters,sothediskfacenumber(headnumber)is0~3or0~5.

2.Track

Thediskisdividedintomanyconcentriccirclesduringlow-levelformatting.Theseconcentriccircletracksarecalledtracks,andinformationisrecordedonthesetracksintheformofpulsetrains.middle.Thetracksarenumberedsequentiallyfromtheoutsidetotheinside,startingfrom0.Eachharddiskhas300~1024tracksoneachsurface,andthenewlarge-capacityharddiskhasmoretracksoneachsurface.Eachtrackdoesnotrecorddatacontinuously,butisdividedintosegmentsofarcs.Theangularvelocitiesofthesearcsarethesame,butbecausetheradiallengthisdifferent,thelinearvelocityisalsodifferent.Thelinearvelocityoftheouterringishigherthanthatoftheinnerring.Thelinearvelocityislarge,thatis,underthesamerotationspeed,thelengthofthearcdrawnbytheouterringinthesameperiodoftimeisgreaterthanthelengthofthearcdrawnbytheinnerring.Eacharciscalledasector,andsectorsarenumberedstartingfrom1,andthedataineachsectorisreadorwrittenasaunitatthesametime.Thetracksareinvisible,justsomemagnetizedareasonthedisksurfacethataremagnetizedinaspecialway,andtheplanninghasbeencompletedwhenthediskisformatted.

3.Cylinder

Thesametrackonalldisksformsacylinder,usuallycalledacylinder.Themagneticheadoneachcylindergoesfromtoptobottomandfrom0Startnumbering.Datareading/writingisperformedonacylinder,thatis,whentheheadreads/writesdata,theoperationstartsfromhead0inthesamecylinder,andthenoperatesondifferentdisksurfacesofthesamecylinder,thatis,thehead,onlyinthesamecylinder.Afterallthemagneticheadsonthesurfacehavebeenread/written,themagneticheadtransferstothenextcylinder(thecylinderthatisconcentricandtheninward),becausetheselectionofthemagneticheadonlyneedstobeswitchedelectronically,andtheselectionofthecylindermustbemechanicallySwitching,thespeedoftheheadmovingtotheadjacenttrackduringelectronicswitchingismuchfasterthanthatduringmechanicalswitching.Therefore,datareading/writingisperformedonthecylinderinsteadofthedisksurface,therebyimprovingtheread/writeefficiencyoftheharddisk.

Thenumberofcylindersofaharddiskdrive(orthenumberoftracksperdisk)dependsonthewidthofeachtrack(alsorelatedtothesizeofthehead),andalsodependsonthepositioningmechanismThesizeofthestepbetweentracks.

4.Sector

Theoperatingsystemstoresinformationontheharddiskintheformofsectors(Sector).Eachsectorincludestwomainparts:sectoridentifierandstorageThedatasegmentofthedata(usually512B).

Sectoridentifier,alsocalledsectorheader,includesthreenumbersthatmakeupthethree-dimensionaladdressofthesector:1)Disknumber:thehead(ordisk)wherethesectorislocated2)Cylindernumber:Track,determinetheradialdirectionofthehead:3)Sectornumber:Thepositiononthetrack,alsocalledtheblocknumber,whichdeterminesthepositionofthedataonthediskcircle.

Thesectorheaderalsoincludesafield,inwhichthereisamarkthatidentifieswhetherthesectorcanreliablystoredata.Someharddiskcontrollersalsorecordpointersinthesectorheader,whichcandirectthedisktoareplacementsectorortrackwhentheoriginalsectoriswrong.Finally,thesectorheaderendswithacyclicredundancycheck(CRC)value,sothatthecontrollercancheckthereadoutofthesectorheadertoensureaccuracy.

Thedatasegmentofasectorisusedtostoredatainformation,includingdataanderrorcorrectioncodes(ECC)fordataprotection.Duringtheinitialpreparation,thecomputerfills512virtualinformationbytes(thestoragelocationoftheactualdata)andtheECCnumberscorrespondingtothesevirtualinformationbytesintothispart.

Accessprinciple

Stack

ThestackisaspaceforrecordingthecallingpathandparameterswhentheClanguageprogramisrunning:includingthefunctioncallingframe,passingparameters,andsavingReturnaddressandprovidelocalvariablespace.

Basicknowledgeofstack

1.Stackrelatedregisters

1)esp:thepointerofthetopofthestack;

2)ebp:baseaddresspointer(ebpisusedtorecordthecurrentfunctioncallbaseaddressinClanguage);

3)cs:eippointstotheaddressofthenextinstruction,therearetwocases;

(1)Sequentialexecution:alwayspointtothenextinstructionwithconsecutiveaddresses;

(2)Jump/branch:Whensuchaninstructionisexecuted,thevalueofcs:eipWillbemodifiedaccordingtoprogramneeds;

4)call:pushthecurrentvalueofcs:eipontothetopofthestack,cs:eippointstotheentryaddressofthecalledfunction;

5)ret:Popthevalueofcs:eiporiginallystoredherefromthetopofthestackandputitintocs:eip;

6)iret:Popthecs:eipandflagsoriginallystoredherefromthetopofthestackValue,putitincs:eipandflagregister.

2.Stackoperation

1)push:thepointeronthetopofthestackisreducedby4bytes(32bits):

2)pop:thepointeronthetopofthestackisincreased4bytes(32bits).

Theuseofthestackduringthefunctioncall

TheoperationofthestackduringthefunctioncallisshowninFigure3.AmainfunctioncallsaForsub-functions,thespecificstepsofthecallingprocessaredescribedasfollows:

  1. Beforethecallisexecuted,esppointstothetopofthestack,andebppointstothebottomofthestack;

  2. Whenthecallisexecuted,theoriginalvalueofcs:eipissavedtothetopofthestack,andthenthevalueofcs:eippointstotheentryaddressofthecalledprogram;

  3. Enterthecalledprogram,Thefirstinstruction:pushl%ebp,thesecondinstruction:movl%esp,%ebp;

  4. Enterthecalledprogram,andthenthestackcanbepushedintothestack,etc.Normaloperation;

  5. Exitthecalledprogram,thefirstinstructionismovl%ebp,%esp,thesecondinstructionispopl%ebp,andthethirdinstructionisret.Atthistime,exitfromthecalledprogramandrestoretheaddresstoeipthroughret.

Theprincipleoflocality

TheprincipleoflocalityreferstowhatisaccessedwhentheCPUaccessesthememory,whetheritisaninstructionordataaccessThestorageunitsareclusteredinasmallcontinuousarea.

Localityusuallyhastwoforms:

Temporallocality:Ifaninformationitemisbeingaccessed,itislikelytobeaccessedagaininthenearfuture.Programloops,stacks,etc.arethecausesoftemporallocality.

Spatiallocality:Theinformationthatwillbeusedinthenearfutureislikelytobeclosetotheinformationcurrentlyinuseinthespatialaddress.

Alllevelsofmoderncomputersystems,fromhardwaretooperatingsystems,toapplications,aredesignedusingtheprincipleoflocality.Atthehardwarelevel,theprincipleoflocalityallowscomputerdesignerstosaverecentlyreferencedinstructionsanddataitemsbyintroducingasmallandfastcachememory,therebyincreasingthespeedofaccesstothemainmemory.Attheoperatingsystemlevel,thelocalityprincipleallowsthesystemtousemainmemoryasthemostrecentlyreferencedcacheinthevirtualaddressspace.Thelocalityprinciplealsoallowsthesystemtousethemainmemorytocachethemostrecentlyuseddiskblocksinthediskfilesystem.Theprincipleoflocalityalsoplaysanimportantroleinthedesignofanapplication.Forexample,aWebbrowserplacesarecentlyciteddocumentonalocaldisk,usingtemporallocality.AlargenumberofWebserversstorerecentlyrequesteddocumentsinfront-enddiskcaches.Thesecachescansatisfyuserrequestsforthesedocumentswithoutanyinterventionfromtheserver.

Thefollowingthreeexamplesareusedtoillustratethelocalityoftheprogram'sdatareference.

Example1:

intsumvec(intv[N])

{

inti=0,sum=0;

for(inti=0;i

{

sum+=v[i];

}

returnsum;

}

Intheabovecode,thevariablesumisreferencedonceineachloopiteration,whichhastimelocality.Fortheelementsofthearrayv,theyarestoredaccordingtothemTheorderinthememoryisreadsequentially,soithasspatiallocality,buteacharrayelementisonlyaccessedonce,soithasnotemporallocality.ItcanbeseenthatthesumvecfunctionhasbothspatiallocalityandtimefordataaccessLocality.

Example2:

intsumarrayros(intv[M][N])

{

inti=0;j=0;sum=0;

for(i=0;i

for(j=0;j

{

sum+=v[i][j];

}

returnsum;

}

Intheabovecode,Theelementsofarrayvareaccessedaccordingtothestepsize1,soithasgoodspatiallocality(arrayelementsarestoredinroworder).

Example3:

intsumarrayros(intv[M][N])

{

inti=0;j=0;sum=0;

for(j=0;j

for(i=0;i

{

sum+=v[i][j];

}

returnsum;

}

Intheabovecode,theelementsofthearrayvareaccessedaccordingtothestepsizeN,soitsspatiallocalityVerybad.Insummary,thefollowingconclusionscanbedrawn:

1)Programsthatrepeatedlyrefertothesamevariablehavegoodtimelocality;

2)ForthosewithasteplengthofkTheprograminthereferencemode,thesmallerthestepsize,thebetterthespatiallocality.Theprogramthatjumpsaroundinthememorywithlargesteps,thespatiallocalitywillbepoor;

3)ForinstructionfetchingInotherwords,theloophasgoodtemporalandspatiallocality.Thesmallertheloopbody,themoreloopiterations,thebetterthelocality.

This article is from the network, does not represent the position of this station. Please indicate the origin of reprint
TOP