MindMap Gallery Chapter 4 - Document Management
Detailed mind map of the operating system. The file is a collection of information stored on the computer using the hard disk as the carrier. This picture is suitable for final review of computer-related majors, postgraduate entrance examination study, etc.
Edited at 2023-10-11 11:41:02This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
Chapter 4 - Document Management
1. File system basics
I. File concept
file definition
document
A collection of information stored on a computer using a hard disk as a carrier
File operations
i. Create a file
Allocate memory space
Create an entry for the new file in the directory, which records the file name, location in the file system, etc.
ii. write file
Execute system call
Indicate the file name and the content to be written to the file
A write pointer to the file must be maintained
iii. read file
Execute system call
Indicate the file name and the contents of the file to be read
A read pointer to the file must be maintained
iv. File relocation
file addressing
Set the file location to the specified value, do not read or write
Opening and closing files
open a file
Use the open system call to add the attributes of the specified file (including the location of the external memory) to an entry in the open file table of the memory, and return the number (index pointer) to the user.
The OS maintains a table containing all open files (open-file table)
Precautions
After open is completed, any subsequent operations on the file no longer require the file name, only the pointer returned by open
Related information
file pointer
Keep track of the last file read and write position as a pointer to the current file
File open count
When the open file counter is 0, it means that the file is no longer used and all resources of the file are recycled.
file disk location
Save in memory
access permission
Save in the punch-in file table
II. The logical structure of the file
I. streaming file
unstructured file
Such as binary files or character files
Only through exhaustive search
II. log file
There is a structure file
type
i. sequence file
accomplish
sequential storage
chain storage
advantage
Most efficient when operating in batches
shortcoming
Only sequential files can be stored on disk and work efficiently
It is difficult to add, delete, modify and check a single record
N records are searched N/2 times on average.
ii. index file
accomplish
Fixed length record
variable length record
Only supports sequential search
direction chart
When accessing a file, you must first search the index table
structure
key
logical address
iii. index sequence file
principle
Divide all the records in the sequence file into several groups, and then create an index table for them. Create an index for the first record of each group in the index table, which contains the key value of the record and the pointer to the record.
Find length
Assuming that N records are divided into root N groups, the average search length is root N.
iv. direct file or hash file
The mapping between the record key value and the physical address is implemented by the hash function
III. Directory Structure
1. File Directory
Contains information about the file such as properties, location, ownership, etc.
Folders in Windows
directory file
A file that organizes all file directories
Directory permissions can only be set in NTFS format
2. File control blocks and index nodes
FCB
Purpose
Implement "access by name"
File Directory
An ordered collection of FCBs. An FCB is a file directory entry.
basic structure
Basic information (file name, file physical location and logical structure, physical structure, etc.)
access control information
Usage information
File creation and modification time, etc.
Precautions
FCB must be stored continuously
index node
Fundamental
Store file names and file description information separately
index node
File description information formation
The file directory only stores the file name and the pointer to the i node corresponding to the file.
disk index node
Index nodes stored on disk
Each UNIX file has a unique disk index node
(All devices in UNIX are treated as special files)
File length
in B
3. Directory Structure
I. Single level directory structure
shortcoming
Files cannot have the same name
Not convenient for file sharing
II. Two-level directory structure
Master File Directory (MFD)
Record the user name and the location of the file directory
User File Directory (UFD)
Record the FCB information of the user file
shortcoming
Unable to classify file
III. Multi-level directory structure (tree directory structure)
shortcoming
Search efficiency is low
Not convenient for file sharing
IV. Acyclic graph directory structure
advantage
File sharing enabled
Set a sharing counter for each shared node
Files are actually deleted when the share counter reaches zero
Any changes will be visible to other users
IV. File Sharing
1. hard link
Sharing based on index nodes
(Quick search speed)
Set link count count. When a user shares the file, the count is incremented by 1 and the pointer to the index node is set; when the user no longer needs it, the count is decremented by 1 and the link pointer is deleted.
Precautions
Files can be deleted if and only if count=0
Prevent link pointers from dangling
2. soft link
Sharing based on symbolic links
Pathname to store accessed shared files
(Slow search speed)
When accessing a file, search according to the path name of the file to achieve sharing.
Precautions
1. Only the file owner has a pointer to the index node
Other users only have access to the file.
2. After the file owner deletes the file, other users only fail to access it according to the path, without any other impact.
3. The problem is: after the original file is deleted by the user, and another user creates a file with the same name in its directory, the sharing user of the original file will access the wrong file.
V. File protection
1. Password protection
2. Encryption protection
3. Access control
accomplish
User access rights
file properties
2. File system implementation
I. Directory implementation
linear list
Use file name and pointer to store data block
advantage
the easiest
shortcoming
Can't have the same name
Hash table
Use the file name as the key to obtain the value pointer
advantage
Find quickly
Simple insertion and deletion
shortcoming
Hash table length is fixed
Dependence of hash function on table length
II. File implementation
research content
physical structure
How files are distributed
Disk non-free blocks
File storage space management
Disk free blocks
III. File distribution method
1. continuous allocation
Record in file directory table
file name
start position
length
external fragmentation
("As much as you want, give as much as you want")
2. Link assignment
Adopt discrete allocation method
Resolved external debris
Classification
1. implicit link
Disk blocks are distributed anywhere on the disk. Except for the last disk block, each disk block points to a pointer to the next block.
record in directory table
file name
Starting disk speed number
The last disk block number
shortcoming
To access any disk server, you must access it from the first disk server.
If one disk is damaged, subsequent disks will be inaccessible.
2. explicit link
Extract the end pointer of each disk block and store it separately in a linked list
File Allocation Table (FAT)
Set only one in the disk
Direct access is supported
Each entry stores the next block link pointer (disk block number) of the corresponding block.
The first disk is recorded in the directory
Free disk blocks can also be marked
FAT can realize storage space management
Resident memory after booting
Improved retrieval and memory access efficiency
Precautions
Calculating the space occupied by FAT
The number of digits in the table entry must be an integer multiple of 4
For example, assuming that the disk block size is 1KB, for a 1.2MB floppy disk, the FAT table occupies 1.8KB
3. index allocation
principle
Put all disk numbers of the file together to form an index table (block)
The address of the index block is stored in the directory table
Create a file
First get a piece of free space
Then write its address to the index table
advantage
random access
No external debris
Easy to add and delete
shortcoming
Index table takes up memory
Each file must have an index block
The index block should be as small as possible, but too small to handle large files
Resolve large files
link scheme
Link multiple index blocks together
multi-level index
The Nth level points to the N-1 level index block
Access disk N 1 times
hybrid index
For example, 10 direct address items and 1 primary index, 1 secondary index and a tertiary index
IV. File storage space management
1. free list method
Belongs to continuous allocation method
Create a free disk fast table for all free areas, each free area corresponds to a free table entry
All free areas are arranged in ascending order by starting address
Methods such as first adaptation can also be used
When recycling, the issue of merging the front and rear free areas should also be considered.
Table Structure
The first free disk fast number
Number of free disk blocks
2. free list method
Free disk fast method
Link in units of disk blocks
free extent method
Link in units of panels
An extent contains multiple extents
Each area should also have disk speed information for this area.
3. Bitmap method
Use a binary bit to represent disk block usage
A bitmap is actually a two-dimensional table
Such as Linux
Precautions
When positioning, pay attention to whether rows and columns are numbered starting from 0 or 1.
4. Group linking method
Suitable for large file systems
Such as UNIX
V. How to improve disk IO
1. Read ahead
2. delayed write
3. Virtual disk (RAM)
Emulate disk with memory space
4. RAID (Redundant Array of Inexpensive Disks)
Supports parallel transmission
High reliability
speed up transfer
Unable to expand disk capacity
3. Disk organization and management
I. disk structure
cylinder
Tracks with the same relative position on all disks
magnetic head
Decide the board
sector
Precautions
Disk address structure
i. (cylinder, disk, sector)
ii. reason
Can reduce head movement time
When reading information, all heads move synchronously; when the disk is locked, the corresponding heads are activated
II. Disk scheduling algorithm
I. Disk scheduling time
1. looking for time
Move the head to the specified track
Ts=m*n s
n is the number of tracks, m is the time to cross a track, s is the start-up head wall time
2. delay
Locate from track to target sector
Tr=1/(2r)
r is the rotation speed (rev/time)
3. Transmission time
actual reading time
Tt=b/(r*N)
b is the amount of read data, N is the total data amount of the track
Can be optimized by OS
II. Typical scheduling algorithm
1. FCFS
fair
No "magnetic wall adhesion", the following three algorithms are available
No hunger
2. SF
Process the track closest to the current position each time
have hunger
3. SCAN (elevator dispatch)
The magnetic head reaches the maximum value of the requested track number (not necessarily the two ends of the track) and then returns to the other maximum value of the requested track number.
DefaultLOOK
Not conducive to access requests far away from the head end
4. C-SCAN
After the magnetic head reaches one of the maximum values of the requested track number, it immediately returns to the other maximum value.
DefaultC-Look
III. Other ways to reduce latency
Disk sector alternate numbering
Misaligned naming on the disk
III. Disk management
1. initialization
Low-level format (physical partition)
Divide new disk into sectors
For example, determine the number of digits occupied by the sector check code.
Use special data structures for each sector
The OS records its own data structures on disk
Divide the disk into one or more cylinder partitions (C drive, etc.)
Logically format a physical partition
Create file system (root directory, etc.)
The OS stores the initial file system data structures on disk, including free and allocated space and an initially empty directory.
2. boot block
An initialization program (bootloader) needs to be run when the computer is running
The bootloader is usually stored in ROM
Keep only a small bootloader in ROM
Boot disk (system disk)
Disk with boot partition
A fully functional bootloader installed
3. bad block
Keep the system from using bad blocks
hardware malfunction
OS cannot be repaired