English

File Operations

Advertisements
Maharashtra State Board: Class 12

Basic concepts of Memory Allocation & File Operations

Blocking 

Disk systems have a well-defined block size determined by the size of a sector. All disk I/O is in units of one block and all blocks are of same size. In Unix, one block consists of 512 bytes. A file is considered a sequence of blocks. All the basic 1/0 functions operate in blocks. A file of 1949 bytes would be allocated 4 blocks (2048 bytes). The last 99 bytes would be wasted.  This is called blocking. 

Internal Fragmentation 

When a computer allocates memory to a program, sometimes it gives more than the program needs. The leftover space inside the allocated memory is wasted. This  is called internal fragmentation. 

External Fragmentation 

When a computer's memory is broken into many small, separate pieces, it can be difficult to find a big enough piece for a new program. This problem is called external fragmentation. 

Free Space Management 

The file system maintains a free space list to manage disk space, reusing space from deleted files. It allocates space to new files by updating this list, implemented as a bit map where each bit indicates whether a block is free (0) or allocated (1). 

File operations 

Following are the file operations:  

  1. Creating a File: Allocate space and add a directory entry with the file's name and location.
  2. Writing a File: Use a system call to specify the file name and data. Update the write pointer to the next block. 
  3. Reading a File:  Specify the file name and memory location. Update the read pointer to the next block.
  4. Rewinding a File: Reset the current file position to the beginning
  5. Deleting a File: Release file space and invalidate the directory entry. 

Operating systems use a table for open files to avoid constant directory searches. 

Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×