File Concept, Operations on File

एक file संबंधित records का एक abstract logical संग्रह है जो physical storage पर map किया जाता है, programmer से जटिल hardware sectors छुपाते हुए।

10 min read · 10 cards · 2 checks

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


Theory

अदृश्य Cabinet

जब आप अपने C program को हमारे साझा college server, LabOne, पर lab2.c के रूप में save करते हैं, आप इसे एक directory folder में बैठे एक अकेले, साफ़-सुथरे document के रूप में सोचते हैं। पर अगर आप server room के अंदर असली magnetic platter या electronic chips को देखते, आपका code बेतरतीब physical sectors में binary digits के रूप में बिखरा है। fragmented bits का एक विशाल संग्रह आपके compiler को एक अकेली निरंतर notebook कैसे दिखता है?

Theory

Library Catalog Card

एक file को एक printed library book की तरह सोचिए। student के लिए, यह एक title, author, और size वाली एक अकेली निरंतर कहानी है। पर physical building के लिए, वह किताब दूर shelves में store किए individual pages में टूटी है। operating system master librarian की तरह काम करता है: यह उन सारे बिखरे pages को एक साथ लपेटता है, उन पर एक logical title tag चिपकाता है, और कहता है, 'shelf numbers की चिंता मत करो, बस title पढ़ो।'

Theory

File Concept परिभाषित

औपचारिक रूप से, एक file संबंधित जानकारी का एक नामित संग्रह है जो secondary storage पर record किया जाता है। operating system के नज़रिए से, एक file सबसे छोटी logical storage unit है: data secondary storage पर तब तक नहीं लिखा जा सकता जब तक इसे एक file के अंदर लपेटा न जाए। यह एक निरंतर logical address space दर्शाता है जो system software द्वारा physical storage tracks और blocks पर map किया जाता है।

At a glance

हर logical file entry के लिए file system द्वारा बनाए रखे मूल attributes।

File Attributeउद्देश्यLabOne Server उदाहरण
Nameuser सुविधा के लिए मानव पठनीय identifierlab2.c
Identifierdata track करता अनोखा system tag numberInode 45219
Typeभीतरी format extension निर्दिष्ट करता है.c या .out
Locationphysical disk block addresses की ओर pointerBlocks 1024 से 1028

Follow along

छह मूल Lifecycle Operations

  1. Create OS ख़ाली disk space allocate करता है और directory structure में एक नया name pointer entry जोड़ता है।
  2. Write system file name और data निर्दिष्ट करता है, यह track करने के लिए एक सक्रिय write pointer रखते हुए कि अगला byte कहाँ जाता है।
  3. Read system मौजूदा read pointer position से data पढ़ता है और tracking pointer head आगे बढ़ाता है।
  4. Reposition एक file seek के रूप में भी जाना जाता है, यह data पढ़े या लिखे बिना मौजूदा position pointer बदलता है।
  5. Delete OS directory खोजता है, सारे allocated disk blocks release करता है, और directory entry मिटाता है।
  6. Truncate system file की सामग्री शून्य bytes तक साफ़ करता है पर इसके attributes और directory name बरक़रार रखता है।

Quiz

जब कई student sessions LabOne पर एक साझा textbook file एक साथ पढ़ते हैं, operating system हर एक individual program के लिए इसकी reading position track करने के लिए कौन सा भीतरी marker बनाए रखता है?

  1. एक physical hardware track address
  2. एक current file position pointer
  3. एक global disk sector index number
  4. एक file format extension string
Show the answer

एक current file position pointer

operating system हर open process के लिए एक स्वतंत्र current file position pointer बनाए रखता है। यह pointer track करता है कि अगला read या write operation कहाँ होगा, एक student की position को दूसरे से अलग करते हुए।

Watch out

Missing Close का जाल

university exams में एक classic ग़लती file lifecycles सूचीबद्ध करते समय close operation भूलना है। students सोचते हैं कि delete या create ही एकमात्र बड़े tasks हैं। पर अगर एक program स्पष्ट रूप से close call नहीं करता, सक्रिय file pointers और भीतरी system table buffers RAM में locked रहते हैं। यह LabOne पर memory resources बर्बाद करता है और अगर server अप्रत्याशित रूप से restart होता है तो स्थायी data corruption पैदा कर सकता है।

Think first

एक File Delete बनाम Truncate करना

मान लीजिए एक student एक अस्थायी file के अंदर सारे log messages साफ़ करना चाहता है पर भविष्य के automated scripts के लिए filename बरक़रार रखना चाहता है। क्या उन्हें file delete करनी चाहिए या truncate करनी चाहिए? tap करने से पहले logical फ़र्क़ का मन में विश्लेषण कीजिए।

Show the answer

उन्हें file truncate करनी होगी। Deleting file name, attributes, और entry pointer को directory structure से पूरी तरह हटाता है, एक recreation चरण की ज़रूरत रखते हुए। Truncating file name, permissions, और ownership बरक़रार रखता है, पर file size को शून्य पर reset करता है और इसके stored data blocks को वापस मुफ़्त disk pool में release करता है।

Theory

System Calls और बाद के Semesters

आप इन बिल्कुल operations को Unit 4 में raw programming commands इस्तेमाल करते हुए execute करेंगे। cat, rm, और touch जैसी utilities जादुई tools नहीं हैं: वे आज हमने पढ़े बुनियादी operating system algorithms के इर्द-गिर्द सीधे scripts हैं। अपने चौथे semester के data structures course में, आप memory index maps बनाएँगे जो बिल्कुल दर्पण की तरह दिखाते हैं कि ये logical file pointers physical storage sectors में कैसे अनुवादित होते हैं।

Summary

Key takeaways

  • एक file सबसे छोटी नामित logical storage unit है जो physical secondary storage devices पर map की जाती है।
  • operating system physical tracks, sectors, और sector सीमाओं को applications से पूरी तरह छुपाता है।
  • name, identifier, type, और location जैसे file attributes directory records के अंदर सुरक्षित रूप से track किए जाते हैं।
  • छह मूल system operations हैं create, write, read, reposition, delete, और truncate।
  • System tables multi-user access states साफ़-सुथरे track करने के लिए current file pointers बनाए रखती हैं।
  • Memory hook: इसे Create करो, open करो, seek करो, lock करो, close करो, और protect करो!

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

File Concept, Operations on File · Operating System · Gri-Learn