मैं विंडोज़ पर इन-यूज फाइलों को क्यों बदल सकता हूं जैसे मैं लिनक्स और ओएस एक्स पर कर सकता हूं?

विषयसूची:

मैं विंडोज़ पर इन-यूज फाइलों को क्यों बदल सकता हूं जैसे मैं लिनक्स और ओएस एक्स पर कर सकता हूं?
मैं विंडोज़ पर इन-यूज फाइलों को क्यों बदल सकता हूं जैसे मैं लिनक्स और ओएस एक्स पर कर सकता हूं?

वीडियो: मैं विंडोज़ पर इन-यूज फाइलों को क्यों बदल सकता हूं जैसे मैं लिनक्स और ओएस एक्स पर कर सकता हूं?

वीडियो: मैं विंडोज़ पर इन-यूज फाइलों को क्यों बदल सकता हूं जैसे मैं लिनक्स और ओएस एक्स पर कर सकता हूं?
वीडियो: How to RUN Android APPS in Windows 10 with BLUE STACKS! - YouTube 2024, अप्रैल
Anonim
 जब आप लिनक्स और ओएस एक्स का उपयोग कर रहे हैं, तो ऑपरेटिंग सिस्टम आपको अभी भी विंडोज़ पर उपयोग में आने वाली फाइल को हटाने से नहीं रोकता है, आपको स्पष्ट रूप से ऐसा करने से रोक दिया जाएगा। क्या देता है? यूनिक्स-व्युत्पन्न सिस्टम पर उपयोग में आने वाली फ़ाइलों को संपादित और हटाएं क्यों नहीं, बल्कि विंडोज़?
जब आप लिनक्स और ओएस एक्स का उपयोग कर रहे हैं, तो ऑपरेटिंग सिस्टम आपको अभी भी विंडोज़ पर उपयोग में आने वाली फाइल को हटाने से नहीं रोकता है, आपको स्पष्ट रूप से ऐसा करने से रोक दिया जाएगा। क्या देता है? यूनिक्स-व्युत्पन्न सिस्टम पर उपयोग में आने वाली फ़ाइलों को संपादित और हटाएं क्यों नहीं, बल्कि विंडोज़?

प्रश्नोत्तर प्रश्न और उत्तर सत्र हमें क्यू एंड ए वेब साइटों के एक समुदाय द्वारा संचालित समूह, स्टैक एक्सचेंज के सुपरयूसर - उपविभाग की सौजन्य देता है।

प्रश्न

SuperUser रीडर the.midget जानना चाहता है कि क्यों लिनक्स और विंडोज इन-उपयोग फ़ाइलों का अलग-अलग व्यवहार करते हैं:

One of the things that has puzzled me ever since I started using Linux is the fact that it allows you to change the name of a file or even delete it while it is being read. An example is how I accidentally tried to delete a video while it was playing. I succeeded, and was surprised as I learnt that you can change just about anything in a file without caring if it’s being used at the moment or not.

तो दृश्यों के पीछे क्या हो रहा है और उसे विंडोज़ में चीजों को हटाना चाहते हैं जैसे वह लिनक्स में कर सकता है?

उत्तर

SuperUser योगदानकर्ताओं ने midget के लिए स्थिति पर कुछ प्रकाश डाला। अजीब लिखते हैं:

जब भी आप विंडोज़ में फ़ाइल खोलते हैं या निष्पादित करते हैं, तो विंडोज़ फ़ाइल को लॉक करता है (यह एक सरलीकरण है, लेकिन आमतौर पर सच है।) एक प्रक्रिया जिसे लॉक किया गया है, तब तक हटाया नहीं जा सकता जब तक कि उस प्रक्रिया को रिलीज़ न किया जाए। यही कारण है कि जब भी विंडोज़ को खुद को अपडेट करना पड़ता है तो आपको इसके प्रभावी होने के लिए रीबूट की आवश्यकता होती है।

दूसरी तरफ, यूनिक्स जैसे ऑपरेटिंग सिस्टम जैसे लिनक्स और मैक ओएस एक्स फ़ाइल को लॉक नहीं करते बल्कि अंतर्निहित डिस्क सेक्टर हैं। यह एक मामूली भेदभाव प्रतीत हो सकता है लेकिन इसका मतलब यह है कि सामग्री के फाइल सिस्टम तालिका में फ़ाइल का रिकॉर्ड किसी भी प्रोग्राम को परेशान किए बिना हटाया जा सकता है जिसमें पहले से ही फ़ाइल खुलती है। इसलिए आप फ़ाइल को तब भी हटा सकते हैं जब यह अभी भी निष्पादित हो रहा है या अन्यथा उपयोग में है और यह तब तक डिस्क पर मौजूद रहेगा जब तक कि कुछ प्रक्रियाओं के लिए खुली हैंडल हो, भले ही फ़ाइल तालिका में प्रवेश हो।

डेविड श्वार्टज़ इस विचार पर विस्तार करते हैं और बताते हैं कि चीजें आदर्श कैसे होनी चाहिए और वे अभ्यास में कैसे हैं:

Windows defaults to automatic, mandatory file locking. UNIXes default to manual, cooperative file locking. In both cases, the defaults can be overriden, but in both cases they usually aren’t.

A lot of old Windows code uses the C/C++ API (functions like fopen) rather than the native API (functions like CreateFile). The C/C++ API gives you no way to specify how mandatory locking will work, so you get the defaults. The default “share mode” tends to prohibit “conflicting” operations. If you open a file for writing, writes are assumed to conflict, even if you never actually write to the file. Ditto for renames.

And, here’s where it gets worse. Other than opening for read or write, the C/C++ API provides no way to specify what you intend to do with the file. So the API has to assume you are going to perform any legal operation. Since the locking is mandatory, an open that allows a conflicting operation will be refused, even if the code never intended to perform the conflicting operation but was just opening the file for another purpose.

So if code uses the C/C++ API, or uses the native API without specifically thinking about these issues, they will wind up preventing the maximum set of possible operations for every file they open and being unable to open a file unless every possible operation they could perform on it once opened is unconflicted.

In my opinion, the Windows method would work much better than the UNIX method if every program chose its share modes and open modes wisely and sanely handled failure cases. The UNIX method, however, works better if code doesn’t bother to think about these issues. Unfortunately, the basic C/C++ API doesn’t map well onto the Windows file API in a way that handles share modes and conflicting opens well. So the net result is a bit messy.

वहां आपके पास है: फ़ाइल को संभालने के लिए दो अलग-अलग दृष्टिकोण दो अलग-अलग परिणाम।

स्पष्टीकरण में जोड़ने के लिए कुछ है? टिप्पणियों में आवाज उठाओ। अन्य तकनीक-समझदार स्टैक एक्सचेंज उपयोगकर्ताओं से अधिक उत्तरों पढ़ना चाहते हैं? यहां पूर्ण चर्चा धागा देखें।

सिफारिश की: