This document discusses memory management techniques used in operating systems. It explains that memory is divided into pages and frames, and the operating system is responsible for allocating frames to processes and swapping pages between memory and storage. When too many processes are active and not enough frames are available, thrashing can occur where the system spends more time swapping pages than executing processes. Page replacement algorithms determine which pages to swap out when new pages need to be allocated. Virtual memory allows processes to be larger than physical memory by swapping pages to disk, but heavy use of swapping can degrade performance.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
81 views9 pages
Operating Systems Function - MEMORY MANAGEMENT
This document discusses memory management techniques used in operating systems. It explains that memory is divided into pages and frames, and the operating system is responsible for allocating frames to processes and swapping pages between memory and storage. When too many processes are active and not enough frames are available, thrashing can occur where the system spends more time swapping pages than executing processes. Page replacement algorithms determine which pages to swap out when new pages need to be allocated. Virtual memory allows processes to be larger than physical memory by swapping pages to disk, but heavy use of swapping can degrade performance.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9
Wolmers Trust High School for Girls
CAPE COMPUTER SCIENCE
Upper !" #o$er Si% Techer& Mrs' McCllum( Ro"!e) Operating Systems Function MEMORY MANAGEMENT Introduction We *!o$ tht the CPU c! +e shre" +) set of processes' As result of the CPU sche"uli!g, $e c! impro-e +oth the utili.tio! of the CPU !" the spee" of the computers respo!se to its users' To relise this i!crese i! perform!ce, ho$e-er, $e must *eep se-erl processes i! memor)/ $e must shre memor)' Memor) is ce!trl to the opertio! of mo"er! computer s)stem' Memor) is lrge rr) of $or"s or +)tes, ech $ith its o$! ""ress' The CPU fetches i!structio!s from memor) ccor"i!g to the -lue of the progrm cou!ter' These i!structio!s m) cuse ""itio!l lo"i!g from !" stori!g to specific memor) ""resses' Mi! memor) is ge!erll) the o!l) storge "e-ice tht the CPU is +le to ""ress "irectl)' 0or e%mple, for the CPU to process "t from "is*, those "t must first +e tr!sferre" to mi! memor) +) the CPU(ge!erte" I1O clls' E2ui-le!tl), i!structio!s must +e i! memor) for the CPU to e%ecute them' 0or progrm to +e e%ecute", it must +e mppe" to +solute ""resses !" lo"e" i!to memor)' As the progrm e%ecutes, it ccesses progrm i!structio!s !" "t from memor) +) ge!erti!g these +solute ""resses' E-e!tull), the progrm termi!tes, its memor) spce is "eclre" -il+le, !" the !e%t progrm c! +e lo"e" !" e%ecute"' Operating Systems responsibiity to Memory Management 3eep trc* of $hich prts of memor) re curre!tl) +ei!g use" !" +) $hom' 4eci"e $hich processes re to +e lo"e" i!to memor) $he! memor) spce +ecomes -il+le' Allocte !" "e(llocte memor) spce s !ee"e"' !irtua Memory 5irtul memor) is tech!i2ue tht llo$s the e%ecutio! of processes tht m) !ot +e completel) i! memor)' The mi! -isi+le "-!tge of this scheme is tht progrms c! +e lrger th! ph)sicl memor)' This tech!i2ue frees progrmmers from co!cer! o-er memor) storge limittio!s' 5irtul memor) is !ot es) to impleme!t, ho$e-er, !" m) su+st!till) "ecrese perform!ce if it is use" crelessl)' 6 Most computers to") h-e somethi!g li*e 78 or 9: meg+)te of RAM -il+le for the CPU to use' U!fortu!tel), tht mou!t of RAM is !ot e!ough to ru! ll of the progrms tht most users e%pect to ru! t o!ce' 0or e%mple, if )ou lo" the operti!g s)stem, ! e(mil progrm, We+ +ro$ser !" $or" processor i!to RAM simult!eousl), 78 meg+)tes is !ot e!ough to hol" it ll' If there $ere !o such thi!g s -irtul memor), the! o!ce )ou fille" up the -il+le RAM )our computer $oul" h-e to s), ;Sorr), )ou c!!ot lo" !) more pplictio!s' Plese close !other pplictio! to lo" !e$ o!e'; With -irtul memor), $ht the computer c! "o is loo* t RAM for res tht h-e !ot +ee! use" rece!tl) !" cop) them o!to the hr" "is*' This frees up spce i! RAM to lo" the !e$ pplictio!' <ecuse this cop)i!g hppe!s utomticll), )ou "o!=t e-e! *!o$ it is hppe!i!g, !" it m*es )our computer feel li*e is hs u!limite" RAM spce e-e! though it o!l) hs 78 meg+)tes i!stlle"' <ecuse hr" "is* spce is so much cheper th! RAM chips, it lso hs !ice eco!omic +e!efit' The re"1$rite spee" of hr" "ri-e is much slo$er th! RAM, !" the tech!olog) of hr" "ri-e is !ot gere" to$r" ccessi!g smll pieces of "t t time' If )our s)stem hs to rel) too he-il) o! -irtul memor), )ou $ill !otice sig!ific!t perform!ce "rop' The *e) is to h-e e!ough RAM to h!"le e-er)thi!g )ou te!" to $or* o! simult!eousl) (( the!, the o!l) time )ou ;feel; the slo$!ess of -irtul memor) is $he! there=s slight puse $he! )ou=re ch!gi!g ts*s' Whe! tht=s the cse, -irtul memor) is perfect' Whe! it is !ot the cse, the operti!g s)stem hs to co!st!tl) s$p i!formtio! +c* !" forth +et$ee! RAM !" the hr" "is*' This is clle" t"ras"ing, !" it c! m*e )our computer feel i!cre"i+l) slo$' #aging The re of the hr" "is* use" for -irtul memor) is clle" swap file +ecuse it s$ps >e%ch!ges? "t, i!formtio!, !" i!structio!s +et$ee! memor) !" storge' A page is the mou!t of "t !" progrm i!structio!s tht c! +e s$p t gi-e! time' The tech!i2ue of s$ppi!g items +et$ee! memor) !" storge, clle" paging, is time(co!sumi!g process for the computer' 8 $asic Met"od% Ph)sicl memor) is +ro*e! i!to fi%e"(si.e" +loc*s clle" 0RAMES' #ogicl memor) is lso +ro*e! "o$! i!to +loc*s of the sme si.e clle" PAGES' Whe! process is +ei!g e%ecute", its pges re lo"e" i!to !) -il+le memor) frmes from the hr" "is* >or the +c*i!g store?' The +c*i!g store is "i-i"e" i!to fi%e"(si.e" +loc*s tht re of the sme si.e s the memor) frmes' Co!si"er the follo$i!g "igrm& Every address generated by the CPU is divided into two parts: a page number (p) and a page offset (d). The page number is used as an index into a page table. The page table contains the base address of each page in physical memory. This base address is combined with the page offset to define the physical address that is sent to the memory unit. FORMAT OF A &OGI'A& A((RESS The pge si.e >li*e the frme si.e? is "efi!e" +) the hr"$re' 7 The si.e of pge is t)picll) po$er of 8 -r)i!g +et$ee! @68 +)tes !" A6B8 +)tes per pge, "epe!"i!g o! the computer rchitecture' The selectio! of po$er of 8 s pge si.e m*es the tr!sltio! of logicl ""ress i!to pge !um+er !" pge offset prticulrl) es)' If the si.e of logicl ""ress i!to spce is 8 m , !" pge si.e is 8 ! ""ressi!g u!its >+)tes or $or"s?, the! the higher(or"er m-n +its of logicl ""ress "esig!te the pge offset' Thus, the logicl ""ress is s follo$s& m-n n A MORE 'ON'RETE E)AM#&E #aging Mode : pge !um+er pge offset p " A #AGING E)AM#&E FOR A *+,$YTE MEMORY -IT. / $YTES #ER #AGE Usi!g pge si.e of : +)tes !" ph)sicl memor) of 78 +)tes >A pges?, it is sho$! ho$ users -ie$ c! +e mppe" i!to ph)sicl memor)' &ogica Address 0 is pge C, offset C' I!"e%i!g i!to the pge t+le, $e fi!" tht pge C is i! frme @' Thus logicl ""ress C mps to ph)sicl ""ress 8C >D>@E:?FC?' -"ere does ogica address * maps to1 @ C 6 8 7 T"ras"ing This is the stte of ! operti!g s)stem tht spe!"s much of its time pgi!g, i!ste" of e%ecuti!g pplictio! soft$re' If prticulrl) pplictio! soft$re stoppe" respo!"i!g !" the hr" "is* +li!*s repete"l), the operti!g s)stem pro++l) is thrshi!g' Thrshi!g is computer cti-it) tht m*es little or !o progress, usull) +ecuse memor) or other resources h-e +ecome e%huste" or too limite" to perform !ee"e" opertio!s' Whe! this hppe!s, ptter! t)picll) "e-elops i! $hich re2uest is m"e of the operti!g s)stem +) process or progrm, the operti!g s)stem tries to fi!" resources +) t*i!g them from some other process, $hich i! tur! m*es !e$ re2uests tht c!=t +e stisfie"' I! -irtul storge s)stem >! operti!g s)stem tht m!ges its logicl storge or memor) i! u!its clle" pges?, thrshi!g is co!"itio! i! $hich e%cessi-e pgi!g opertio!s re t*i!g plce' A s)stem tht is thrshi!g c! +e percei-e" s either -er) slo$ s)stem or o!e tht hs come to hlt' Usull) thrshi!g refers to t$o or more processes ccessi!g shre" resource repete"l) such tht serious s)stem perform!ce "egr"tio! occurs +ecuse the s)stem is spe!"i!g "isproportio!te mou!t of time Gust accessing the shre" resource' Resource ccess time m) ge!erll) +e co!si"ere" s $ste", si!ce it "oes !ot co!tri+ute to the "-!ceme!t of !) process' This is ofte! the cse $he! CPU c! process more i!formtio! th! c! +e hel" i! -il+le RAM/ co!se2ue!tl) the s)stem spe!"s more time prepri!g to e%ecute i!structio!s, th! ctull) e%ecuti!g them' $asic concept 9 If the !um+er of pges llocte" to lo$(priorit) process flls +elo$ the mi!imum !um+er re2uire" +) the computer rchitecture, $e must suspe!" the process e%ecutio!' We shoul" the! pge out its remi!i!g pges, freei!g ll its llocte" frmes' This pro-isio! i!tro"uces s$p(i! s$p(out le-el of i!terme"ite CPU sche"uli!g' There m) +e processes tht "oes !ot h-e He!ough frmes' Although it is tech!icll) possi+le re"uce the !um+er of llocte" frmes to the mi!imum, there is still some >lrger? !um+er of pges tht re i! cti-e use' If the process "oes !ot h-e this !um+er of frmes, it $ill 2uic*l) pge fult' page fault is an interrupt to the software raised by the hardware, when a program accesses a page that is mapped in address space, but not loaded in physical memory. The hardware that detects this situation is the memory management unit in a processor. The exception handling software that handles the page fault is generally part of an operating system. The operating system tries to handle the page fault by making the required page accessible at a location in physical memory or kills the program in case it is an illegal access. At this poi!t, some pges $ill !ee" to +e replce"' Ho$e-er, si!ce ll the pges re i! cti-e use, it must replce pge tht $ill +e !ee"e" gi! right $)' Co!se2ue!tl), it -er) 2uic*l) fults gi!, !" gi!, !" gi!' The process co!ti!ues to fult, replci!g pges for $hich it $ill the! fult !" +ri!g +c* right $)' 'auses o2 T"ras"ing The operti!g s)stem mo!itors the CPU utili.tio!' If CPU utili.tio! is too lo$, $e i!crese the "egree of multiprogrmmi!g +) i!tro"uci!g !e$ process i!to the s)stem' A glo+l pge(replceme!t lgorithm is use", replci!g pges $ith !o regr" to the process to $hich the) +elo!g' page repacement agorit"ms decide 3"ic" memory pages to page out 4s3ap out5 3rite to dis67 3"en a page o2 memory needs to be aocated8 No$ suppose process e!ters !e$ phse i! its e%ecutio! !" !ee"s more frmes' It strts fulti!g !" t*i!g pges $) from other processes' I These fulti!g processes must use the pgi!g "e-ice to s$p pges i! !" out' As the) 2ueue up for the pgi!g "e-ice, the re") 2ueue empties' As processes $it for the pgi!g "e-ice, CPU utili.tio! "ecreses' The CPU sche"uler sees the "ecresi!g CPU utili.tio!, !" i!creses the "egree of multiprogrmmi!g s result' The !e$ process tries to get strte" +) t*i!g pges from ru!!i!g processes, cusi!g more pge fults, !" lo!ger 2ueue for the pgi!g "e-ice' As result, CPU utili.tio! "rops e-e! further, !" the CPU sche"uler tries to i!crese the "egree of multiprogrmmi!g e-e! more' Thrshi!g hs occurre"J The pge fult rte i!creses treme!"ousl)' As result the effecti-e memor) ccess time i!creses' No $or* is getti!g "o!e, +ecuse the processes re spe!"i!g ll their time pgi!g' &imiting T"ras"ing Use local or priority! replacement algorithm. With locl replceme!t, if o!e process strts thrshi!g, it c!!ot stel frmes from !other process !" cuse the ltter to thrsh lso' #re9enting T"ras"ing Pro-i"e process s m!) frmes s it !ee"s' A Additionay% Whe! referri!g to computer, t"ras"ing or dis6 t"ras"ing is term use" to "escri+e $he! the hr" "is* "ri-e is +ei!g o-er$or*e" +) mo-i!g i!formtio! +et$ee! the s)stem memor) !" -irtul memor) e%cessi-el)' Thrshi!g is ofte! cuse" $he! the s)stem "oes !ot h-e e!ough memor), the s)stem s$p file is !ot properl) co!figure", !"1or too much is ru!!i!g o! the computer !" it hs lo$ s)stem resources' Whe! thrshi!g occurs, user $ill !otice the computer hr" "is* "ri-e l$)s $or*i!g !" "ecrese i! s)stem perform!ce' Thrshi!g is +" o! hr" "is* "ri-e +ecuse of the mou!t of $or* the hr" "is* "ri-e hs to "o !" if is left u!fi%e" $ill li*el) cuse ! erl) filure of the hr" "is* "ri-e' To resol-e hr" "is* "ri-e thrshi!g, user c! "o !) of the +elo$' 6' I!crese the mou!t of RAM i! the computer' 8' 4ecrese the mou!t of progrms +ei!g ru! o! the computer' 7' A"Gust the si.e of the s$p file' B
Python Machine Learning: Using Scikit Learn, TensorFlow, PyTorch, and Keras, an Introductory Journey into Machine Learning, Deep Learning, Data Analysis, Algorithms, and Data Science