Memory allocation Techniques (Fixed and variable)

Fixed અને variable partitioning નક્કી કરે છે કે operating system RAM ને સ્થાયી, અપરિવર્તનીય slots માં વહેંચે છે કે ચાલતા student programs માટે dynamic, લવચીક જગ્યાઓમાં.

10 min read · 10 cards · 3 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

LabOne Classroom નું સંકટ

કલ્પના કરો કે તમે એક 15 MB Python data analysis script ચલાવવા LabOne server માં log in કરો છો. એ જ સમયે, તમારો classmate એક નાની 2 MB SQL query ચલાવવા માંગે છે. જો LabOne operating system કોઈના log in કરતાં પહેલાં પોતાની physical RAM ને સખ્ત, અપરિવર્તનીય 20 MB slots માં વહેંચી દે, તમારી script perfectly fit થાય છે, પણ તમારો classmate બસ 2 MB code માટે એક પૂરો 20 MB slot બરબાદીથી ઘેરી લે છે. OS કિંમતી megabytes બરબાદ કર્યા વગર RAM માં desk space કેવી રીતે વહેંચી શકે?

Theory

Parking Lot વિરુદ્ધ ખુલ્લું Playground

fixed partitioning ને એક પ્રમાણભૂત college parking lot ની જેમ વિચારો જ્યાં દરેક slot એક મોટી SUV fit કરવા painted છે. ભલે એક student ત્યાં એક નાની bicycle park કરે, એ slot સંપૂર્ણપણે લેવાયેલો છે અને બીજું કંઈ રાખી શકતું નથી. Variable partitioning એક ખુલ્લા ઘાસના playground ની જેમ છે જ્યાં students બિલકુલ પોતાની જરૂરના કદના tents લગાવે છે. એક tent ની અંદર કોઈ જગ્યા બરબાદ થતી નથી, પણ જેમ લોકો સમેટીને જાય, બચેલા gaps નવા tents ના fit થવા બહુ વિચિત્ર બની શકે.

Theory

Fixed વિરુદ્ધ Variable Partitioning

contiguous memory management માં, fixed partitioning system startup દરમિયાન RAM ને static, અપરિવર્તનીય ક્ષેત્રોમાં વહેંચે છે. દરેક ક્ષેત્ર બરાબર એક process રાખે છે. એથી ઊલટું, variable partitioning RAM ને પહેલેથી વહેંચતું નથી. એને બદલે, operating system memory ને મફત space ના એક contiguous block, જેને એક hole કહે છે, થી dynamically allocate કરે છે, LabOne server માં load થતાં એક process દ્વારા માંગેલા બિલકુલ કદ સાથે મેળ ખાતાં.

At a glance

static અને dynamic allocation techniques વચ્ચેના મુખ્ય સંરચનાત્મક સોદા.

FeatureFixed PartitioningVariable Partitioning
Partition Sizeસ્થાયી અને પૂર્વનિર્ધારિતDynamic અને તરત બદલાય છે
Process Limitpartitions ની સંખ્યા બરાબરમાત્ર કુલ RAM કદથી મર્યાદિત
Fragmentationinternal fragmentation થી નુકસાન ઝીલે છેexternal fragmentation થી નુકસાન ઝીલે છે
OS Overheadબહુ ઓછું અને track કરવામાં સરળવધુ કારણ કે એ મફત holes track કરે છે

Think first

એક Fixed Partition બરબાદી ને ટ્રેસ કરવી

ધારો કે LabOne માં 10 MB, 20 MB, અને 30 MB ના 3 fixed slots માં વહેંચાયેલો એક RAM ક્ષેત્ર છે. ત્રણ student programs ક્રમમાં આવે છે: P1 (8 MB), P2 (12 MB), અને P3 (25 MB). ઉકેલ પ્રગટ કરતાં પહેલાં હલ કરો કે દરેક process કયું partition ઘેરે છે અને slots ની અંદર કુલ બરબાદ જગ્યા calculate કરો.

Show the answer

Step 1: P1 (8 MB) 10 MB slot માં fit થાય છે. આ slot ની અંદર બરબાદ જગ્યા 10 minus 8 છે જે 2 MB બરાબર છે.

Step 2: P2 (12 MB) બચેલા 10 MB slot માં fit થઈ શકતું નથી, તો એ 20 MB slot લે છે. અંદર બરબાદ જગ્યા 20 minus 12 છે જે 8 MB બરાબર છે.

Step 3: P3 (25 MB) 30 MB slot લે છે. અંદર બરબાદ જગ્યા 30 minus 25 છે જે 5 MB બરાબર છે.

Step 4: partitions ની અંદર કુલ બરબાદ જગ્યા 2 plus 8 plus 5 છે જે 15 MB બરાબર છે. આ slot-ની-અંદર બરબાદી internal fragmentation કહેવાય છે.

Quiz

જો LabOne server પર એક 4 MB process એક 16 MB fixed partition માં load થાય, એ partition ની અંદર બચેલા 12 MB નું શું થાય છે?

  1. OS આપોઆપ એને એક બીજા 12 MB process ને સોંપી દે છે
  2. એ સંપૂર્ણપણે locked અને કોઈ પણ બીજા process દ્વારા અનુપયોગી રહે છે
  3. partition memory બચાવવા dynamically 4 MB સુધી સંકોચાઈ જાય છે
  4. એ તરત secondary backing store space માં બદલાઈ જાય છે
Show the answer

એ સંપૂર્ણપણે locked અને કોઈ પણ બીજા process દ્વારા અનુપયોગી રહે છે

fixed partitioning માં, એક slot એક સમયે માત્ર એક process રાખી શકે છે. ભલે process slot ના એક નાના અંશનો ઉપયોગ કરે, એ slot નો બાકીનો ભાગ સંપૂર્ણપણે locked અને બરબાદ છે. એ સંકોચાઈ શકતું નથી કે બીજી process સ્વીકારી શકતું નથી. આ internal fragmentation પેદા કરે છે.

Watch out

Fragmentation Interchange નો ફાંદો

university exams માં marks ગુમાવવાનો એક પાકો રસ્તો એ ગૂંચવવું છે કે internal અને external fragmentation ક્યાં થાય છે. આ સખ્ત નિયમ યાદ રાખો: fixed partitioning internal fragmentation તરફ લઈ જાય છે કારણ કે જગ્યા એક પૂર્વનિર્ધારિત box ની અંદર બરબાદ થાય છે. Variable partitioning external fragmentation તરફ લઈ જાય છે કારણ કે જૂના programs ખતમ થઈને LabOne ની RAM માંથી નીકળતાં allocated blocks ની બહાર બેતરતીબ નાના holes વિકસે છે.

Think first

Dynamic Growth ની સમસ્યા

ધારો કે એક variable partition માં ચાલતા એક student program ને એક નવી data array load કરવા અચાનક 5 MB વધારાની RAM જોઈએ. જો એના હાલના block થી તરત અડીને કોઈ મફત જગ્યા નથી, શું એક contiguous variable partition બસ જગ્યાએ જ વધી શકે? પ્રગટ કરતાં પહેલાં contiguous allocation ના નિયમ વિશે વિચારો.

Show the answer

ના, એ જગ્યાએ વધી શકતું નથી. કારણ કે variable allocation માટે જરૂરી છે કે એક process RAM નો એક એકલો સતત block ઘેરે, જો અડીને આવેલી જગ્યા પહેલેથી કોઈ બીજા student ના program દ્વારા લેવાયેલી છે, OS ને કાં તો એક બિલકુલ નવો મોટો hole શોધવો પડશે, પૂરી process ત્યાં move કરવી પડશે, કે program ને એક out of memory error થી crash કરવો પડશે.

Theory

ખરી દુનિયાની Memory અને Unit 4

જોકે આધુનિક operating systems ઉન્નત paging techniques વાપરે છે, આ પાયાના partition mechanics ને સમજવું મહત્ત્વનું છે. જ્યારે આપણે Unit 4 માં આપણી Linux installation lab દરમિયાન hard drives partition કરીએ છીએ તમે fixed layout નું એક રૂપ જોશો. ત્યાં, તમે system boot કરતાં પહેલાં એક એકલી disk ને સ્પષ્ટ, અપરિવર્તનીય partitions જેમ root અને swap માં વહેંચશો.

Summary

Key takeaways

  • Fixed partitioning startup પર અપરિવર્તનીય memory સીમાઓ set કરે છે, સક્રિય tasks ની સંખ્યા મર્યાદિત કરતાં.
  • Variable partitioning દરેક process દ્વારા માંગેલા બિલકુલ કદના આધારે dynamically slots બનાવે છે.
  • Fixed partitioning slots ની અંદર બચેલી જગ્યાના કારણે internal fragmentation થી નુકસાન ઝીલે છે.
  • Variable partitioning slots વચ્ચે વિખરાયેલા holes ના કારણે external fragmentation થી નુકસાન ઝીલે છે.
  • Contiguous allocation નો અર્થ દરેક process ને RAM ના એક એકલા અતૂટ block માં રહેવું પડે.
  • Memory hook: Fixed partitions અંદર જગ્યા બરબાદ કરે છે: variable holes બહાર gaps છોડે છે!

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from File and Memory Management

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Memory allocation Techniques (Fixed and variable) · Operating System · Gri-Learn