Tuesday, 6 September 2016

File Processes

A program/file in the execution is called a Process. Process is not the same as program. A process is more than a program code. A process is an 'active' entity as opposed to program which is considered to be a 'passive' entity. Attributes held by process include hardware state, memory, CPU etc.

Process memory is divided into four sections for efficient working :
  • The text section is made up of the compiled program code, read in from non-volatile storage when the program is launched.
  • The data section is made up the global and static variables, allocated and initialized prior to executing the main.
  • The heap is used for the dynamic memory allocation, and is managed via calls to new, delete, malloc, free, etc.
  • The stack is used for local variables. Space on the stack is reserved for local variables when they are declared.
fig. File Processing
Processes can be any of the following states :
  • New - The process is in the stage of being created.
  • Ready - The process has all the resources available that it needs to run, but the CPU is not currently working on this process's instructions.
  • Running - The CPU is working on this process's instructions.
  • Waiting - The process cannot run at the moment, because it is waiting for some resource to become available or for some event to occur.
  • Terminated - The process has completed.

File System

A file can be "free formed", indexed or structured collection of related bytes having meaning only to the one who created it. Or in other words an entry in a directory is the file. The file may have attributes like name, creator, date, type, permissions etc.

File Structure

A file has various kinds of structure. Some of them can be :
  • Simple Record Structure with lines of fixed or variable lengths.
  • Complex Structures like formatted document or reloadable load files.
  • No Definite Structure like sequence of words and bytes etc.

Attributes of a File

Following are some of the attributes of a file :
  • Name . It is the only information which is in human-readable form.
  • Identifier. The file is identified by a unique tag(number) within file system.
  • Type. It is needed for systems that support different types of files.
  • Location. Pointer to file location on device.
  • Size. The current size of the file.
  • Protection. This controls and assigns the power of reading, writing, executing.
  • Time, date, and user identification. This is the data for protection, security, and usage monitoring.

File Access Methods

The way that files are accessed and read into memory is determined by Access methods. Usually a single access method is supported by systems while there are OS's that support multiple access methods.
Sequential Access
  • Data is accessed one record right after another is an order.
  • Read command cause a pointer to be moved ahead by one.
  • Write command allocate space for the record and move the pointer to the new End Of File.
  • Such a method is reasonable for tape.
Direct Access
  • This method is useful for disks.
  • The file is viewed as a numbered sequence of blocks or records.
  • There are no restrictions on which blocks are read/written, it can be dobe in any order.
  • User now says "read n" rather than "read next".
  • "n" is a number relative to the beginning of file, not relative to an absolute physical disk location.
Indexed Sequential Access
  • It is built on top of Sequential access.
  • It uses an Index to control the pointer while accessing files.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.