Theory
USB Pendrive નો વિરોધાભાસ
ધારો કે તમે એક મહત્ત્વના college project પર કામ કરી રહ્યા છો. તમે તમારા laptop ના ડાબા USB port માં એક SanDisk pendrive, જમણા port માં એક Logitech mouse plug કરો છો, અને એક cable દ્વારા એક HP LaserJet printer connect કરો છો. ત્રણેય devices બિલકુલ અલગ ઉત્પાદકો પાસેથી આવે છે, સંપૂર્ણપણે અનોખા ભીતરી electronics વાપરે છે, અને મૂળભૂત રીતે અલગ speeds પર કામ કરે છે. તોય, તમારું laptop બિલકુલ એ જ સમયે crash થયા વગર files copy કરે, clicks track કરે, અને pages print કરે છે. એક એકલો Operating System હજારો અનોખા hardware designs ને આરામથી કેવી રીતે command કરે છે? આ જાદુ Device Management subsystem દ્વારા execute કરાય છે.
Theory
International Embassy ના Translators
કલ્પના કરો કે એક mega-city એક વિશાળ global summit ની યજમાની કરી રહી છે. City Mayor (CPU) ને Japan, Greece, અને Egypt થી આવેલા delegates ને orders આપવા છે. Mayor 190 અલગ ભાષાઓ ભાગ્યે જ શીખી શકે. એને ઉકેલવા, દરેક દેશ પોતાના delegate સાથે એક official translator મોકલે છે. Mayor બસ English માં 'Please sit down!' જેવી એક પ્રમાણભૂત command બૂમ પાડે છે, અને દરેક translator એને તરત એ બિલકુલ native બોલીમાં બદલી દે છે જેને એમનો ખાસ delegate સમજે છે. એક Operating System માં, આ native software translators ને Device Drivers કહે છે.
Theory
Device Management ની મૂળ જવાબદારીઓ
દરેક peripheral device computer સાથે physical wires કે wireless ports દ્વારા એક electronic circuit board chip જેને Device Controller કહે છે, ના માધ્યમથી communicate કરે છે. આ જટિલ જાળને વ્યવસ્થિત રાખવા, OS નું I/O (Input/Output) subsystem ચાર પ્રાથમિક operations કરે છે:
1. Tracking Status: એ I/O Traffic Controller નામના એક ભીતરી ledger વાપરતાં સતત દેખરેખ કરે છે કે કયું device મફત છે અને કયું વ્યસ્ત.
2. Enforcing Policies: એ I/O Scheduler વાપરતાં નક્કી કરે છે કે કઈ process એક device મેળવે છે, કેટલા સમય માટે, અને કયા ક્રમમાં.
3. Allocation: એ physically એક device ને એક વિશ્રામ અવસ્થાથી અલગ કરે છે અને એને એક સક્રિય, ચાલતી process ને સોંપે છે.
4. Deallocation: એ device ને પાછું લે છે એક વાર process પોતાનું execution પૂરું કરી લે છે જેથી બીજા programs એને વાપરવા queue માં લાગી શકે.
Formula
Devices ની ત્રણ મુખ્ય શ્રેણીઓ
university exam papers માં, તમને ઘણી વાર devices ને એ આધારે વર્ગીકૃત કરવા કહેવાશે કે એમને કેવી રીતે વહેંચાય છે. આ ત્રણ ખાસ શ્રેણીઓ યાદ રાખો:
1. Dedicated Devices: Hardware જે એક સમયે માત્ર એક process નું હોઈ શકે જ્યાં સુધી એ execution પૂરું ન કરે (જેમ એક physical printer, plotter, કે એક microphone. જો બે programs એક સાથે print કરવાનો પ્રયાસ કરે, text ની lines overlap થઈ જાત!).
2. Shared Devices: Hardware જે interleaving mechanisms વાપરીને સુરક્ષિત રીતે અનેક processes ની એક સાથે સેવા કરી શકે (જેમ એક Hard Disk કે SSD, જ્યાં અલગ files થી data ના chunks ઝડપી વારાફરતી ક્રમમાં વાંચી શકાય).
3. Virtual Devices: એક hybrid યુક્તિ જ્યાં એક dedicated hardware unit ને storage buffer techniques વાપરીને એક shared device ની જેમ વર્તવા બદલાય છે (જેમ અનેક printers અનુકરણ કરવા print spooling વાપરવું).
Think first
Polling વિરુદ્ધ Interrupts: વાત કોણ શરૂ કરે છે?
CPU ને કેવી રીતે ખબર પડે છે કે એક ધીમા keyboard એ છેલ્લે એક user નું keystroke register કરવાનું પૂરું કરી લીધું છે? શું તમે ફેલાવતાં પહેલાં operating systems દ્વારા વપરાતી બે classic engineering methods નું અનુમાન લગાવી શકો?
Show the answer
બે પાયાની methods Polling અને Interrupts છે:
1. Polling (Busy-Waiting): CPU સતત એક અંતહીન loop ચલાવે છે hardware ને પૂછતાં, 'શું તું તૈયાર છે? શું તું હજુ થઈ ગયું? હવે કેવું?' વારંવાર. આ બિલકુલ કંઈ પણ ઉપયોગી ન કરતાં કિંમતી CPU cycles ની વિશાળ માત્રા વેડફે છે.
2. Interrupt-Driven I/O: CPU hardware controller ને કહે છે કે શું કરવું, પછી તરત બીજા મહત્ત્વના user programs execute કરવા switch કરી દે છે. જ્યારે hardware પોતાનું કામ પૂરું કરે છે, એ એક સમર્પિત motherboard wire પર Interrupt નામનો એક electronic alert signal મોકલે છે. CPU તરત પોતાનું હાલનું કામ અટકાવે છે, આવતા device data ને process કરે છે, અને સરળતાથી પોતાના પાછલા task પર પાછું ફરે છે. Interrupts અનંત રીતે વધુ કાર્યક્ષમ છે!
Quiz
કયું component Operating System ની સામાન્યીકૃત commands અને એક ખાસ hardware ટુકડાના electronic registers વચ્ચે software પુલ તરીકે કામ કરે છે?
- RAM Memory Management Unit
- Device Driver
- CPU Core Scheduler
- Physical I/O Port Pins
Show the answer
Device Driver
Device Driver hardware ઉત્પાદક દ્વારા લખાયેલો એક વિશેષ software program છે. એ generic systemic read/write requests ને device-specific electronic operational commands માં અનુવાદિત કરવા સીધું OS kernel માં embed થાય છે.
Think first
SPOOLing નો જાદુ સમજાવ્યો
જો એક physical printer 10 pages પ્રતિ minute ની ધીમી speed પર print કરે છે, અને એક અતિ ઝડપી 4 GHz CPU ને એના માટે સીધું રાહ જોવી પડે, print jobs દરમિયાન પૂરું computer સંપૂર્ણપણે freeze થઈ જાત. OS આ વિશાળ speed mismatch ને કેવી રીતે bypass કરે છે? એના વિશે વિચારો, પછી ફેલાવો.
Show the answer
OS એક શાનદાર technique વાપરે છે જેને SPOOLing (Simultaneous Peripheral Operations On-Line) કહે છે. data ને સીધું દર્દનાક ધીમા printer ને મોકલવાને બદલે, OS print command ને રોકે છે અને data ને ઝડપથી Hard Disk પર એક ઝડપી હંગામી buffer folder (spool) માં લખે છે. CPU તરત બીજી applications ચલાવવા મુક્ત થઈ જાય છે. આ દરમિયાન, એક background system utility ચૂપચાપ disk spool થી વાંચે છે અને data ને printer ને એની પોતાની native ગતિએ ધીરે-ધીરે feed કરે છે. આ user interface ને ખૂબ responsive રાખે છે!
Watch out
પરમ Exam ફાંદો: Driver વિરુદ્ધ Controller
students ઘણી વાર પોતાના જવાબોમાં આ બે શબ્દોને ભૂલથી બદલી નાખીને marks ગુમાવે છે. હંમેશા યાદ રાખો:
• Device Controller Hardware છે (motherboard કે device પર જ લગાવેલો physical electronic chip, જેમ એક Realtek Audio Chip કે Intel Graphics Card Chip).
• Device Driver Software છે (installation file code જેમ .sys કે .dll જે તમે એ silicon chip ને Windows કે Linux સાથે વાત કરવા દેવા download કરો છો). Driver Controller ને command કરે છે!
Summary
Key takeaways
- Device Management high-level user applications અને અનિયમિત physical hardware peripherals વચ્ચે એક સાફ abstraction layer તરીકે કામ કરે છે.
- Device Drivers વિશેષ software અનુવાદ modules છે, જ્યારે Device Controllers equipment ને નિયંત્રિત કરતા physical silicon hardware chips છે.
- મૂળ I/O subsystem tracking (Traffic Controller), scheduling (I/O Scheduler), physical allocation, અને deallocation સંભાળે છે.
- Devices ને વ્યવસ્થિત રીતે Dedicated (single user), Shared (concurrency-friendly), અને Virtual (disk દ્વારા spooled) માં વર્ગીકૃત કરાય છે.
- Interrupts hardware units ને readiness નો સંકેત asynchronously આપવાની પરવાનગી આપે છે, CPU ને આળસુ busy-waiting loops માં cycles વેડફવાથી અટકાવતાં.
- Memory hook: Driver software code છે, Controller silicon hardware છે, Spooling CPU ને ધીમા physical components થી બચાવે છે!