FileDirectory
FileDirectory
Files
Directories
Review
• Memory Manager
– coordinate how the different types of memory are used
– keep track memory to allocate and release areas of main
memory to processes
– manage swapping between main memory and disk
• No Memory Abstractions
– Single program
• One OS, only one process
• Special register is used to protection between OS and process
• Disadvantages: slow
– Multiple program
• One OS, many processes locate in memory
• Divided into fixed size block
• Disadvantages
– Internal fragmentations
– Two programs both reference absolute physical memory
static relocation
Review
• Memory Abstractions
– Multiple processes locate in memory (both primary and secondary)
– Base and Limit Registers
• Multiple processes locate in memory and protection
• Base contains the first address of process in memory, Limit contains the
length of process, the process owns private address space
• Disadvantages
– External fragmentation (Defragment)
– Slow
– Swapping
• Multiple processes with ready processes locate in memory and passive
processes locate in HDD – swap file area
• Swap out/ in operator
• Disadvantages
– External fragmentation
– Process can not grow in memory and the swap area on the disk is full
data segment upward, stack segment downward
Review
• Memory Abstractions
– Memory Management with Bitmaps
• The memory divides units with same size that has a bit corresponding bit
in the bitmap (0: free, 1: occupied)
• Disadvantages
– Slow when searching the bitmap to find a run of k consecutive 0 bits in
the map (small)
– External fragment (large size)
– Memory Management with Linked Lists
• Maintain a linked list of allocated (P) and free memory (H)
• Allocating algorithms
– First, Next, Best, Worst, Quick Fit
– Virtual Memory
• Software/ Process sizes larger than memory
• Overlays
– Developer splits program to many overlays
– Disadvantages: developer‘s knowledge is important
Review
• Memory Abstractions
– Virtual Memory
• Paging
– Address space is broken up into pages
– Physical memory is divided up into page frames
– Virtual address vs. Physical address, manage address space with bit
– MMU transfers Virtual address p, d; then it looks up page table
following the index to get the page frame; the page frame combines
with d to determine the physical address
– Page fault: the program references a part of its address space that is
not in physical memory
– Page table
» Load to collection registers, load to memory using base register,
using TLB
» Excessive large page table: multilevel page, inverted page table,
inverted page table with hash or TLB
» Entry: Caching disabled, Referenced, Modified, Protection,
Present/absent, page frame number
• Memory Abstractions
Review
– Virtual Memory
• Paging
– Page replace algorithms
» Optimal: the page will be the latest one accessed in the future
» NRU: the page has lowest class that combines R and M bit
» FIFO: the page at the head of queue
» Second Chance: old page has not been not referenced in the
previous clock interval (R = 0). If R of page equals 1, R is reset
to 0 and put the tail of the queue.
» Clock (circular queue) : the page being pointed to by the hand is
inspected. If R = 0, page is evicted. Otherwise, R is reset to 0, the
pointer points next
» LRU: the page at the end of the list is replaced, the list must be
updated at each memory reference
» NFU, Aging (using bit): The page with the lowest counter
» Working set model, working set clock (circular queue): Third
Chance with Second Chance using age > τ with bit R
» Terminology: Thrashing, Locality of Reference, Demand paging,
prepaging, working set, page fault rate
Review
• Design Issues
– Local vs Global Policies
• Local: page frames are static allocated among current processes
(thrashing or waste memory)
• Global: page frames are dynamically allocated among runnable
processes (thrashing to others process)
– Solution
» Monitor the size of working set of all processes using aging bit
» The allocation is updated dynamically using PFF algorithms with
To periodically determine the number of running processes,
Giving each process a minimum number of frames
– Load Control
• Swapping and Considering not only process size and paging rate but also
its characteristics
– Page Size
• Optimizing the size of the page and the location of page table
Review
• Design Issues
– Separate Instruction and Data Spaces
• Sharing code, library, read only memory
• Copy on write
– Memory Mapped File
• Paging the file as process
– Cleaning Policy
• Using two-handed clock
– Front hand is controlled by the paging daemon
– Back hand is used for page replacement algorithm as in the standard clock algorithm
• Implementation Issues
– Instruction Backup
• A hidden internal is used to store the PC before each instruction is
executed
• A second register is used to store the registers auto-incremented or auto-
decremented, and by how much
• When the fault instruction is restarted, the OS can unambiguously undo
all the effects of it
Review
• Implementation Issues
– Locking Pages in Memory
• Lock pages engaged in I/O in memory so that they will not be removed
• Do all I/O to kernel buffers & copy the data to use pages later
– Backing Store
• Associated with each process is the disk address of its swap area, that is
where on the swap partition its image is kept (that also kept in process table)
• Paging to a static swap area vs. Backing up pages dynamically
– Segmentation
• Is a logical entity and Consists of a linear sequence addresses, from 0 to
some maximum that can grow and shrink independently without
effecting each other
• To specify an address in the segmented memory, the <segment-number,
offset> is used
• Implementing
– Segment table
– Segmentation with Paging
Objectives
• Files
– File Naming
– File Structure
– File Types
– File Access
– File Attributes
– File Operations
– An Example Program using File System Calls
• Directories
– Single-Level Directories Systems
– Hierarchical Directory Systems
– Path Names
– Directory Operations
Overview
• Problems
– While a process is running, it can store a limited amount of
information within its own address space. However, the storage
capacity is restricted to the size of the virtual address space
– The information is lost when the process terminates
– It is frequently necessary for multiple processes to access (parts of) the
information at the same time
• There are 3 essential requirements for long-term information
storage
– It must be possible to store a very large amount of information
– The information must be survive the termination of process using it
– Multiple processes must be able to access the information concurrently
• Disk and its 2 operation (read, write) are used to solve the long-term
storage problem
Files
Definition
• Are the abstraction (objects and mechanism), that models
in a convenient way the information stored and read it
back on hardware devices and are managed by OS
• Are logical units of information (created by processes)
• Processes can read existing files&create new ones if need be
• Information stored in files must be persistent (not be
affected by process creation and termination)
• File system
– The OS’s component that manages the information stored on the
storage devices and provides the users access to that information
in a convenient way
– Hides the complexity of storage hardware devices
– Provides the users a uniform logical view of the information
stored on these devices, based on the concept of file
– Maps files onto physical devices
Files
Naming
• When a process creates a file, it gives the file a name.
• When the process terminates, the file continues to exist
and can be accessed by other process using its name
• File name = string of characters
• The exact rules for file naming vary somewhat from
system to system
– Distinction between upper and lower letters
– Limit of name length
– Extension (optional)
• Provides some information about the file’s content structure
• Is used to register with OS and specify for each program owns that
extension
• Ex: hello.c; hello.bat, hello.txt
Files
Structure
• There are 3 common way possibilities
– An unstructured sequence of bytes
• Byte sequences (maximum flexibility)
• Can put any thing they want and name file any way
– Record sequence
• A file is a sequence of fixed length record, each with some internal
structure
• Provides read, write, and append operation
– Tree
• A file consists of a tree of records, not necessarily all the same length,
each containing a key field in a fixed position in the record
• The tree is sorted on the key field, to allow rapid searching for a
particular key
• Provides the get operation to get the record with specifies key
• OS decides the new record’s position
Files
Structure
Q&A
Next Lecture
• File System Implementation