File Managementإدارة الملفات
مقدمة الفصل
ماذا ستتعلم في هذا الفصل
- Files and file management systems: properties, operations and objectives.
- File organisation: criteria and types.
- File directories: elements, structures and naming; file sharing, access rights and user classes.
- Record blocking and secondary storage management: preallocation, portion size, contiguous, chained and indexed allocation.
أقسام الفصل
- 1Files and file management systemsالملفات وأنظمة إدارة الملفات
- 2File organisation: criteria and typesتنظيم الملفات: المعايير والأنواع
- 3File directories: contents and elementsالأدلة: محتواها وعناصرها
- 4Directory structures and namingهياكل الأدلة والتسمية
- 5File sharing: access rights and user classesمشاركة الملفات: حقوق الوصول وفئات المستخدمين
- 6Record blockingتكتيل السجلات
- 7Secondary storage management: preallocation and portionsإدارة التخزين الثانوي: التخصيص المسبق والأجزاء
- 8Contiguous, chained and indexed allocationالتخصيص المتجاور والمتسلسل والمفهرس
تلميح: استخدم أسهم لوحة المفاتيح للتنقل بين الشرائح.
Files and file management systemsالملفات ونظام إدارتها
- Files are the central element to most applications; the file system is one of the most important parts of the OS to a user.
Desirable properties of files (slide 3)
- Long-term existence
- Sharable between processes
- Structure
System utility programs that run as privileged applications, concerned with secondary storage; it provides services in the use of files, so the programmer does not need to develop file management software.
Typical operations (slide 5)
- Create
- Delete
- Open
- Close
- Read
- Write
Objectives and elements of file managementأهداف إدارة الملفات
Files and file management systems
- 1Meet the data management needs of the user
- 2Guarantee that the data in the file are valid
- 3Optimize performance
- 4Provide I/O support for a variety of storage device types
- 5Minimize lost or destroyed data
- 6Provide a standardized set of I/O interface routines to user processes
- 7Provide I/O support for multiple users (if needed)
File management concerns
- Directory management
- User access control
- File structure
- Access method
- Records
Operating system concerns
- Blocking
- Disk scheduling
- File allocation
- Free storage management
File organisationتنظيم الملفات
The logical structure of records, determined by the way in which files are accessed.
Criteria (slide 11)
- Short access time
- Ease of update
- Economy of storage
- Simple maintenance
- Reliability
- Priority will differ depending on the use (e.g., read-only CD vs hard drive); some criteria may even conflict.
Types (slide 12) — usually variations of
- Pile
- Sequential file
- Indexed sequential file
- Indexed file
- Direct, or hashed, file
Directory contents and elementsعناصر الدليل
File directories: contents and elements
- A directory contains information about files (attributes, location, ownership).
- The directory itself is a file owned by the operating system.
- It provides the mapping between file names and the files themselves.
| Groupالمجموعة | Elements (slides 15–17)العناصر |
|---|---|
| Basic information |
|
| Address information |
|
| Usage information |
|
Directory structuresهياكل الأدلة
Simple listقائمة بسيطة
- A list of entries, one for each file (sequential file, name as key)
- No help in organizing the files
- User must avoid using the same name for two files
Two-levelمستويان
- One directory for each user and a master directory
- Master holds an entry per user (address and access control information)
- Does not provide structure for collections of files
Hierarchical (tree)هرمي (شجري)
- Master directory with user directories underneath
- Each user directory may have subdirectories and files
- Find a file by following the directory path
Directory operations (slide 19)
- Search
- Create files
- Deleting files
- Listing directory
- Updating directory
- In a tree, duplicate filenames are possible if they have different pathnames (slide 22).
Access rightsحقوق الوصول
- File sharing has two issues: access rights and management of simultaneous access.
- Access rights are often a hierarchy where one right implies the previous ones.
| Rightالحق | The user can…يستطيع المستخدم… |
|---|---|
| None | May not even know of the file's existence |
| Knowledge | Only determine that the file exists and who its owner is |
| Execution | Load and execute a program but cannot copy it |
| Reading | Read the file for any purpose, including copying and execution |
| Appending | Add data to the file but cannot modify or delete any of its contents |
| Updating | Modify, delete, and add to the file's data |
| Changing protection | Change access rights granted to other users |
| Deletion | Delete the file |
User classes and simultaneous accessفئات المستخدمين
File sharing: access rights and user classes
Usually the file's creator; usually has full rights.
Rights may be explicitly granted to specific users.
A set of users identified as a group.
Everyone.
Simultaneous access (slide 30)
- Lock the entire file when it is to be updated, or lock individual records during the update.
- Mutual exclusion and deadlock are issues for shared access.
Record blockingتكتيل السجلات
- Records are the logical unit of access; blocks are the unit for I/O with secondary storage.
Fixed-length records; an integral number of records are stored in a block; unused space at the end of a block is internal fragmentation.
Records are packed into blocks with no unused space; some records may span multiple blocks, continued by a pointer to the successor block.
No spanning; wasted space in most blocks because the remainder of a block cannot be used if the next record is larger than the remaining unused space.
المسألة
Illustrative numbers (not from the slides): fixed blocking with 2,048-byte blocks and 300-byte records.
خطوات الحل
- An integral number of records per block: 2048 / 300 = 6.8 → 6 records.
- Used space: 6 × 300 = 1,800 bytes.
النتيجة
6 records per block; 2,048 − 1,800 = 248 bytes at the end of each block are internal fragmentation.
Allocating space to filesتخصيص المساحة
Secondary storage management: preallocation and portions
- The operating system is responsible for allocating blocks to files, and must keep track of the space available.
File allocation issues (slide 41)
- 1. When a file is created, is the maximum space allocated at once?
- 2. Space is added in contiguous portions — what size should a portion be?
- 3. What data structure should be used to keep track of the file portions?
Needs the maximum size for the file at the time of creation; it is difficult to reliably estimate, so sizes tend to be overestimated so as not to run out of space.
Two extremes: a portion large enough to hold the entire file, or one block at a time — a trade-off between single-file efficiency and overall system efficiency.
Contiguous and chained allocationالمتجاور والمتسلسل
Contiguous, chained and indexed allocation
Contiguousمتجاور
- A single set of blocks is allocated at the time of creation
- One FAT entry: starting block and length
- External fragmentation will occur → need to perform compaction
Chainedمتسلسل
- Allocation on the basis of the individual block
- Each block contains a pointer to the next block
- One FAT entry: starting block and length
- No external fragmentation; best for sequential files
Indexed allocationالمفهرس
- The file allocation table contains a separate one-level index for each file.
- The index has one entry for each portion allocated to the file.
- The file allocation table contains the block number for the index.
Fixed-size blocks
- Allocating by blocks eliminates external fragmentation
Variable-sized blocks
- Improves locality
- Both cases require occasional consolidation.
الخلاصة
أنهيت الدرس
الخطوة التالية: ثبّت المعلومات بالبطاقات، ثم اختبر نفسك بالأسئلة.
ما راجعته في هذا الدرس
- Files and file management systemsالملفات وأنظمة إدارة الملفات
- File organisation: criteria and typesتنظيم الملفات: المعايير والأنواع
- File directories: contents and elementsالأدلة: محتواها وعناصرها
- Directory structures and namingهياكل الأدلة والتسمية
- File sharing: access rights and user classesمشاركة الملفات: حقوق الوصول وفئات المستخدمين
- Record blockingتكتيل السجلات
- Secondary storage management: preallocation and portionsإدارة التخزين الثانوي: التخصيص المسبق والأجزاء
- Contiguous, chained and indexed allocationالتخصيص المتجاور والمتسلسل والمفهرس