Swapping

Swapping in Operating System

What is Swapping

OS में Swapping एक Memory management scheme है जो Main memory से Secondary memory में एक idle or blocked Process को temporarily swap  करती है जो उन Processes के लिए proper memory utilization और memory availability ko ensure करती है जो execute होने के लिए Ready हैं।

जब वह memory-consuming process termination state में चला जाता है यानी उसका Execution finish हो जाता है जिसके कारण उनके execution के लिए dedicated memory Free हो जाती है तो swapped-out processes को Main Memory में वापस लाया जाता है और उनका Execution Start हो जाता है।

Secondary Memory का वह area जहाँ Swap-out Processes Store होती हैं, swap space कहलाती हैं। swapping method secondary memory में Swap की गई Processes की एक temporary queue बनाती है।

high-priority processes के Case में, low priority वाली Process को Main memory से swap किया जाता है और swap space में Store किया जाता है, फिर high priority वाली Process को पहले execute करने के लिए Main Memory में swap किया जाता है।

एक Operating System के main goals में CPU का Maximum utilization include है। इसका मतलब यह है कि every time एक Process का execution होना चाहिए, CPU को कभी भी Idle नहीं रहना चाहिए और any process starvation or blocking नहीं होना चाहिए।

एक Operating System के ऐसे goals को पूरा करने के लिए Different process management और memory management schemes  को design किया गया है

OS में Swapping secondary memory में  present data तक पहुंच प्राप्त करने और इसे main memory  में transfer करने के लिए की जाती है ताकि इसका उपयोग application programs द्वारा किया जा सके।

यह System के Performance को effect कर सकता है लेकिन यह Memory को manage करके एक से अधिक Process को चलाने में help करता है। इसलिए OS में swapping को memory compaction technique के रूप में भी जाना जाता है।

Swapping की Process में दो Important concepts हैं जो इस प्रकार हैं:

  1. Swap-in
  2. Swap-out

Detailed explanation के लिए ‘OS में Swap In और Swap out’ section  देखें।

Swap In:

Secondary Memory (Hard Drive) से एक Process को remove और execution के लिए इसे main memory (RAM ) में restoring करने की method को Swap In method के रूप में जाना जाता है।

Swap Out:

यह Main memory(RAM) से एक Process को बाहर लाने और इसे Secondary Memory(hard drive) में send करने की एक Method है ताकि higher priority or More Memory Consumption वाली Processes को Swap Out Method के रूप में जाना जाता है।

Advantages of Swapping in OS

  • OS में Swapping करने से Maximum CPU Utilization के goals को achieve करने में help मिलती है।
  • Swapping every process के लिए proper memory availability ensures करती है जिसे execute करने की आवश्यकता होती है।
  • Swapping Process starvation की problems से बचने में help करती है अर्थात एक Process को execution में अधिक समय नहीं लेना चाहिए ताकि next process को execute किया जा सके।
  • CPU Swapping की help से various tasks को एक साथ कर सकता है ताकि Processes Executions से पहले अधिक समय तक wait न करनी पड़े।
  • Swapping  proper RAM(main memory) utilization सुनिश्चित करती है।
  • Swapping Processes के लिए  hard drive में Swapping एक dedicated disk partition बनाता है जिसे swap space कहा जाता है।
  • OS में Swapping एक economical process है
  • Swapping method को Priority-based process scheduling पर apply किया जा सकता है जहां एक high priority process की swapping की जाती है और एक low priority process वाली Process की Swapping की जाती है जिससे performance performance होता है।

Disadvantages of Swapping in OS

  • यदि System bulky swapping activityके दौरान power-cut से deal करता है तो User Program से related  all information खो सकता है।
  • यदि swapping method एक Algorithms का Use करती है जो mark तक नहीं है तो  Page faults की संख्या Increase ki जा सकती है और इसलिए यह complete performanceको कम करता है।
  • ऐसे Case में inefficiency हो सकती है जब swapping process में Participate करने वाली Processes द्वारा Use किए जाने वाले some common resource हों।

Example:

Suppose हमारे पास एक User है जिसकी Process Size 4096KB है। यहां User  के पास एक standard hard disk drive है जिसमें Swapping की transfer rate 4Mbps है। अब हम गणना करेंगे कि data को Main Memory से data को transfer करने में कितना Time  लगता है जो कि Hard disk है जो Secondary Memory है।

process size of the user is 4096Kb  

the transfer rate of data is 4Mbps

Now,

4 Mbps is equal to 4096 kbps 

Time taken to transfer the data = process size of user/ transfer rate of data

Now, coming to the Calculation part:

Time Taken = 4096 / 4096

           = 1 second  

           = 1000 milliseconds 

Previous articleControl Statement in C
Next articleContiguous Memory Allocation

LEAVE A REPLY

Please enter your comment!
Please enter your name here