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 से बचाता है!