File Access Methods (Sequential, Direct)

File access methods નક્કી કરે છે કે data storage થી કેવી રીતે read કે write થાય છે: કાં તો એક fixed linear line માં record-દર-record, કે કોઈ પણ ખાસ block address પર તરત સીધું jump કરીને.

10 min read · 10 cards · 3 checks

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


Theory

Music Search નો સંઘર્ષ

કલ્પના કરો કે તમે LabOne માં બેઠા તમારા Python lab ની એક 2 કલાકની lecture recording ની અંદર એક ખાસ section શોધી રહ્યા છો. જો video player તમને માત્ર timeline પર ક્યાંય click કર્યા વગર second-દર-second fast forward કે rewind કરવા દે, તમને એ એક ખાસ error message શોધવા કેટલો સમય લાગત? હવે એની સરખામણી એક એકલા mouse click થી સીધા 45મી minute પર jump કરવા સાથે કરો. operating systems એક file માંથી પસાર થવાની બંને શૈલીઓને support કેમ કરે છે?

Theory

Cassette Tape વિરુદ્ધ Jukebox

sequential access ને એક જૂના cassette tape ની જેમ વિચારો. જો તમે 4થું song સાંભળવા માંગો, તમારે પહેલાં songs 1, 2, અને 3 થી physically wind કરવું પડશે. કોઈ shortcut નથી. Direct access એક digital jukebox કે એક CD player ની જેમ છે. દરેક song નો એક બિલકુલ address કે index number હોય છે. તમે keypad પર 4 type કરી શકો છો, અને laser head તરત 4થા track ની શરૂઆત પર jump કરે છે, બાકી બધું સંપૂર્ણપણે છોડતાં.

Theory

Sequential અને Direct Access Methods

એક operating system અલગ file access methods આપે છે એના પર આધાર રાખતાં કે માહિતીને કેવી રીતે retrieve કરવાની જરૂર છે. sequential access માં, માહિતી ક્રમમાં process થાય છે, એક record બીજા પછી. એક read કે write operation આપોઆપ એક file pointer આગળ વધારે છે. direct access (કે random access) માં, એક file ને blocks કે records ના એક numbered sequence તરીકે જોવાય છે. program પોતાના બિલકુલ block address ને નિર્દિષ્ટ કરીને કોઈ પણ block પર તરત read કે write કરી શકે છે, એ પહેલાં કોઈ પણ block વાંચ્યા વગર.

At a glance

sequential અને direct file access methods વચ્ચેના મુખ્ય સંરચનાત્મક અને operational તફાવત.

FeatureSequential AccessDirect Access
Pointer Movementએક fixed linear ક્રમમાં એક સમયે એક record move કરે છેએક address pointer દ્વારા કોઈ પણ block number પર તરત jump કરે છે
Hardware AnalogyMagnetic tape systems કે continuous stream logsHard disk drives કે આધુનિક solid state storage units
Performance Lookupfile માં દૂર સ્થિત ખાસ records શોધવા ધીમુંખૂબ ઝડપી, physical location છતાં constant time
LabOne Use Caseએક પૂરી C source code file ઉપરથી નીચે compile કરવીroll number થી એક student attendance database table query કરવી

Think first

Pointer Operations ને ટ્રેસ કરવા

એક exam પ્રશ્ન પૂછે છે: 'LabOne પર એક database file માં 100 student records છે. જો system pointer અત્યારે Record 5 પર છે અને તમારે Record 50 વાંચવો છે, sequential અને direct access બંને હેઠળ જરૂરી record reads calculate કરો.' ઉકેલ પ્રગટ કરતાં પહેલાં પગલાં મનમાં હલ કરો.

Show the answer

Sequential Access માટે:

1. OS jump કરી શકતું નથી. એને Record 5 વાંચવો પડશે, પછી 6 પર move કરવું, પછી 7, અને આગળ.

2. 5 થી 50 જવા, એને ક્રમિક રીતે 45 અલગ records વાંચીને પસાર થવું પડશે.

Direct Access માટે:

1. program block number 50 નિર્દિષ્ટ કરતું એક seek command જારી કરે છે.

2. file system block 50 માટે physical disk address સીધું compute કરે છે.

3. read head તરત block 50 પર move કરે છે, બિલકુલ 1 record read operation ની જરૂર રાખતાં.

Quiz

કયું file operation direct access files માં ભારે વપરાય છે પણ એક વિશુદ્ધ sequential file access mode માં સંપૂર્ણપણે ગેરહાજર કે અર્થહીન છે?

  1. Open
  2. Read
  3. Seek
  4. Close
Show the answer

Seek

file pointer ને એક મનસ્વી block number પર ફરી position કરતું એક seek operation direct access માટે મૂળ જરૂરિયાત છે. એક સખ્ત sequential file માં, તમે વચ્ચેનો data વાંચ્યા વગર આગળ skip કે head reposition કરી શકતા નથી, seek operations ને ગેરકાયદેસર બનાવતાં.

Watch out

Storage Media ની ગૂંચવણ

semester exams માં એક સામાન્ય ભૂલ એ લખવી છે કે sequential files માત્ર magnetic tapes પર store થઈ શકે છે. આ ખોટું છે. જ્યારે magnetic tapes માત્ર sequential access કરી શકે છે, hard drives અને solid state drives sequential અને direct access બંને files store કરી શકે છે. ઉદાહરણ તરીકે, LabOne પર તમારી log files એક ઝડપી hard drive પર sequentially store થાય છે કારણ કે તમે માત્ર એમના અંતે લખો છો, એટલા માટે નહીં કે disk તમને એમ કરવા મજબૂર કરે છે.

Think first

સાચી Method પસંદ કરવી

એ text editor program વિશે વિચારો જે તમે LabOne માં તમારા assignments લખવા વાપરો છો. જ્યારે તમે એક file ખોલો છો, એ line 1 થી અંત સુધી બધું તમારી screen પર load કરે છે. text editor internally file વાંચવા કઈ access method વાપરી રહ્યો છે? tap કરતાં પહેલાં વિચારો.

Show the answer

text editor sequential access વાપરે છે. એક file ખોલતાં કે save કરતાં, application પૂરા document ને બિલકુલ પહેલા character થી છેલ્લા byte સુધી સતત read કે write કરે છે. પૂરી file load કરતાં storage ની વચ્ચે એક બેતરતીબ block address પર jump કરવાની જરૂર નથી.

Theory

Database Systems અને ભવિષ્યના Semesters

તમે તમારા Semester 3 Database Management Systems course માં direct access સતત વાપરશો. જ્યારે તમે એક ખાસ ID વાળા student ને શોધતું એક SQL query execute કરો છો, database એ બિલકુલ record ને milliseconds માં pinpoint કરવા direct access index maps વાપરે છે. જો એ એને બદલે sequential access વાપરત, દરેક એક query પૂરા LabOne server ને ધીમો કરીને ઘસડાવા પર લાવી દેત જેમ એ લાખો અસંબંધિત rows scan કરત.

Summary

Key takeaways

  • Sequential access file records ને એક સખ્ત linear ક્રમમાં process કરે છે, pointer આપોઆપ આગળ વધારતાં.
  • Direct access programs ને એક address કે index વાપરતાં કોઈ પણ numbered block કે record પર તરત jump કરવા દે છે.
  • Sequential access source code વાંચવા કે continuous application logs લખવા આદર્શ છે.
  • Direct access લાખો entries વચ્ચે ઝડપી lookups માંગતી database applications માટે જરૂરી છે.
  • hard drives જેવું hardware બંને access patterns support કરી શકે છે, જ્યારે magnetic tapes સખ્તાઈથી sequential છે.
  • Memory hook: Sequential એક line માં ચાલવું છે, direct point પર jump છે!

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