Page 214 - DCAP103_Principle of operating system
P. 214
Unit 6: File Management
6.2 File Concepts Notes
A file is an abstract data type, a “thing”, which is defined and implemented by the operating
system. The main task of the operating system is to map the logical file concept onto physical
storage devices, such as disks or tapes.
A file
Has a type (.com,.bat,exe,…) which can either be known and managed by the operating system,
or leaving the interpretation to the application process.
Some systems allow different file operations based on type.
For general purpose systems it is more effective to implement only basic types and grant
maximum freedom to the processes.
For specialized systems, i.e. a database system, it “may” be more efficient to implement the
logic in the operating system.
Consists of a sequence of logical records, which can be of type byte, a fixed or variable length
line, or a complex data type (structure).
The O/S becomes bulky and complex if it supports too many file structures.
Assuming a file to be an array of bytes and deferring interpretation to the applications ensures
that the O/S is simplified.
6.2.1 Basic File Operations
• Create: find space for the file and make an entry in the directory.
• Open: find file and determine if it has already been opened. If not open search directory,
cache information, add entry in per-process open-file table. If open check lock and cache
information if lock can be acquired. Increment the open count.
• Close: decrement the open count and remove the file’s entry from the open-file table if
count reaches zero.
• Read: read data from the file.
• Write: write data to the file.
• Delete: search directory, release file space and erase directory entry.
• Reposition: reposition the file position pointer. This is more commonly known as seek.
• Truncate: delete content of a file, but keep file properties.
• Lock: file locks provide concurrency control. A shared lock allows multiple “readers” to
acquire a lock concurrently, while exclusive lock ensures only one “writer” can modify a
file.With mandatory locking the operating system ensures locking integrity, while with
advisory locking the application process ensures that the correct locking strategy is
followed. The Windows operating system uses the mandatory locking strategy.
LOVELY PROFESSIONAL UNIVERSITY 207