OPERATING SYSTEM
FILE CONCEPT
 Computers can store information on various storage media ,such as magnetic
tapes and optical disks.
 The operating system abstracts from the physical properties of its storage
devices to define a logical storage unit, file.
 Files are mapped by the operating system onto physical devices .These storage
devices are usually non-volatile.
FILE ATTRIBUTES:
 A file is named usually a string of characters ,such as example .c .
 Some systems differentiate between lowercase and uppercase characters in name
,whereas other system do not.
 When a file is named ,it becomes independent of the process ,the user and even
the system that created it.
 The file owner might write the file to a USB disk ,send it as an e-mail
attachment or copy it across a network.
The file attributes vary from one operating system to another system but typically
consist of these:
1.Name
2.Identifier
3.Type
4.Location
5.Size
6.Protection
7.Time,Date and User
File Attribute
 NAME: The symbolic file name is the only information kept in human
readable form.
 IDENTIFIER: This unique tag ,usually a number ,identifies the file within the
file system ;It is non-human readable name for a file.
 TYPE: This information is needed for the systems that support different types
of files.
 LOCATION: This information is a pointer to a device and to the location of
the file on that device.
 SIZE: The current size of the file (in bytes ,words or blocks)and possibly the
maximum allowed size are included in this attribute.
 PROTECTION: Access-control information determines who can do
reading ,writing ,executing and so no.
 TIME,DATE AND USER INFORMATION: This information may be kept for
creating ,last modification and last use .These data can be useful for protection
,security and monitoring.
FILE OPERATIONS:
 A file is an abstract data type .to define properly ,we need to consider the
operations that can be performed on file.
 The operating system can provide system calls to
create ,read ,reposition ,delete and truncate files.
There are six basic operations comprise the minimal set of required file
operations:
File
Operation
1.Creating a file
2.Writing a file
3.Reading a file
4.Repositioning a file
5.Deleting a file
6.Truncating a file
 CREATING A FILE: Two steps are necessary to create a file .First ,space in
the file system must be found for a file .Secondly ,an entry for the file must be
made in the directory.
 WRITING A FILE: To write a file ,make the system call specifying both the
name of the file and the information to be written to the file.
 READING A FILE: to read from a file ,we use the system call that specifies
the name of the file and where the next block of the file should be put.
 REPOSITING THE FILE: The directory is searched for the appropriate
entry ,and the current file position pointer is repositioning to a given
value .This file operation is also called as seek.
 DELETING A FILE: To delete a file ,search the directory for the named
file .Having found the associated directory entry ,release all file space ,so it
can be reused and erase from directory.
 TRUNCATING A FILE: The user may want to erase the content of a file but
keep its attribute.
OPEN FILE TABLE:
o To avoid this constant searching ,many systems require that an open() system
call be made before a file is used .The operating system keeps a table
called ,open file table.
o Create() and delete() operations are system calls that work with closed rather
than open files.
FILE LOCKS:
File locks provide functionality similar to reader-writer locks .There are
two types of locks;
1.SHARED LOCK: Is a skin to a reader in several processes can acquire
the lock concurrently.
2.EXCLUSIVE LOCK: It behaves like a writer lock ,only one process at
a time can acquire these locks.
FILE TYPES:
 If an operating system recognize the type of file ,it can then operate on file in
reasonable ways.
 A common technique for implementing file types include the type as a part of
filename.
 The name is spilt into two parts are name and extension ,usually separated by
comma(,).
 Most operating system allow users to specify a file name as a sequence of
characters followed by a period and terminated by an extension made up of
additional characters.
 EXAMPLE, resume .docx, server .c and Reader Thread.cpp.
 The system uses the extension to indicate the type of file and type of operations
that can be done on that file.
 Only a file with a .com, .exe for the execution of binary files.
COMMON FILE TYPES
FILE TYPES USUAL EXTENTION FUNCTION
Executable Exe ,com ,bin or none Ready to run machine
programs
Object o Compile machine
language ,not linked
Source code C ,cc ,java Source code in various
language
Mark-up Xml ,html Textual data ,documents
Word processor Xml ,docx Various word processor
formats
Library Lib ,a ,so Libraries of routines for
programmers
multimedia Mp3 ,mp4 ,mov Binary file containing
audio or A/V information
FILE STRUCTURE:
 File types also can be used to indicate the internal structure of the file ,source and object
files have structures that match the expectations of the programs that read them.
 For Example ,the operating system requires that an executable file have specific
structure ,so that it can determine where in memory to load the file.
 Some operating system ,extend this idea into a set of system supported file structures ,with
sets of special operations for manipulating files with those structures.
 The disadvantage of having the operating system support multiple file structures the
resulting the size of the operating system is cumbersome.
 For Example ,assume that a system supports two types of file:TEXT FILE ,and BINARY
FILE. Now the user want to define an encrypted file to protect the contents from being read
by unauthorized people.
 This scheme provides maximum flexibility but little support. Each application program
must include its own code to interpret an input file as accurate structure.
Internal File structure:
o Disk systems typically have a well-defined block size determined by the size
of the sector.
o All I/O devices performed in units of one block and all blocks are same size.
o It is unlikely that the physical record size will exactly match the length of the
desired logical record.
o Logical records may even vary in length. Packaging a number of logical
records into physical blocks is a common solution to this problem.
o For Example ,the UNIX operating system defines all files to be simple
streams of bytes. Each byte is individually addressable by its offset from the
beginning of the file.
o In this case, logical record size is 1byte.
ACCESS METHODS
Files stores information. When it is used ,this
information must be accessed and read into computer memory
The information in the files can be accessed in several ways:
Sequential Access
Direct Access
Other Access Methods
ACCESS METHODS
SEQUENTIAL ACCESS:
 The simplest access method is sequential access. Information in the file is processed in
order ,one record after the other.
 Reads and write wakeup the bulk of operations on a file. A read operation read next()-
read the next portion of a file automatically.
 Similarly, the write operation write next()-appends to the end of the file and advances
to the end of a new material.
beg----------rewind------------current position---------read/write--------------end
DIRECT ACCESS:
 Another method is direct access (or a relative access). Here, a file is made up of fixed length
logical records that allow programs to read and write records rapidly in no particular order.
 The Direct access method is based on a disk model of a file, since disks allow random access
to any file block.
 For direct access, the file is viewed as a numbered sequence of blocks or records. Thus, we
may read block 14,then red block 53, and then write block 7. There is no restrictions on the
order of reading or writing for a direct access file.
SEQUENTIAL ACCESS IMPLEMENTATION FOR DIRECT
ACCESS
reset Cp=0;
Read next Read=cp;
Cp=cp+1;
Write next Write=cp;
Cp=cp+1;
OTHER ACCESS METHODS:
 Other Access methods can built on top of direct access methods, generally
involve the construction of an index for the file.
 The index like an index in the back of a book, contains pointers to various
blocks.
 To find a file, we first search the index and then use the pointer to access the file
directly and to find the desired record.

The Operating System concepts.. -os.pptx

  • 1.
  • 2.
    FILE CONCEPT  Computerscan store information on various storage media ,such as magnetic tapes and optical disks.  The operating system abstracts from the physical properties of its storage devices to define a logical storage unit, file.  Files are mapped by the operating system onto physical devices .These storage devices are usually non-volatile. FILE ATTRIBUTES:  A file is named usually a string of characters ,such as example .c .  Some systems differentiate between lowercase and uppercase characters in name ,whereas other system do not.  When a file is named ,it becomes independent of the process ,the user and even the system that created it.  The file owner might write the file to a USB disk ,send it as an e-mail attachment or copy it across a network.
  • 3.
    The file attributesvary from one operating system to another system but typically consist of these: 1.Name 2.Identifier 3.Type 4.Location 5.Size 6.Protection 7.Time,Date and User File Attribute
  • 4.
     NAME: Thesymbolic file name is the only information kept in human readable form.  IDENTIFIER: This unique tag ,usually a number ,identifies the file within the file system ;It is non-human readable name for a file.  TYPE: This information is needed for the systems that support different types of files.  LOCATION: This information is a pointer to a device and to the location of the file on that device.  SIZE: The current size of the file (in bytes ,words or blocks)and possibly the maximum allowed size are included in this attribute.  PROTECTION: Access-control information determines who can do reading ,writing ,executing and so no.  TIME,DATE AND USER INFORMATION: This information may be kept for creating ,last modification and last use .These data can be useful for protection ,security and monitoring.
  • 5.
    FILE OPERATIONS:  Afile is an abstract data type .to define properly ,we need to consider the operations that can be performed on file.  The operating system can provide system calls to create ,read ,reposition ,delete and truncate files. There are six basic operations comprise the minimal set of required file operations: File Operation 1.Creating a file 2.Writing a file 3.Reading a file 4.Repositioning a file 5.Deleting a file 6.Truncating a file
  • 6.
     CREATING AFILE: Two steps are necessary to create a file .First ,space in the file system must be found for a file .Secondly ,an entry for the file must be made in the directory.  WRITING A FILE: To write a file ,make the system call specifying both the name of the file and the information to be written to the file.  READING A FILE: to read from a file ,we use the system call that specifies the name of the file and where the next block of the file should be put.  REPOSITING THE FILE: The directory is searched for the appropriate entry ,and the current file position pointer is repositioning to a given value .This file operation is also called as seek.  DELETING A FILE: To delete a file ,search the directory for the named file .Having found the associated directory entry ,release all file space ,so it can be reused and erase from directory.  TRUNCATING A FILE: The user may want to erase the content of a file but keep its attribute.
  • 7.
    OPEN FILE TABLE: oTo avoid this constant searching ,many systems require that an open() system call be made before a file is used .The operating system keeps a table called ,open file table. o Create() and delete() operations are system calls that work with closed rather than open files. FILE LOCKS: File locks provide functionality similar to reader-writer locks .There are two types of locks; 1.SHARED LOCK: Is a skin to a reader in several processes can acquire the lock concurrently. 2.EXCLUSIVE LOCK: It behaves like a writer lock ,only one process at a time can acquire these locks.
  • 8.
    FILE TYPES:  Ifan operating system recognize the type of file ,it can then operate on file in reasonable ways.  A common technique for implementing file types include the type as a part of filename.  The name is spilt into two parts are name and extension ,usually separated by comma(,).  Most operating system allow users to specify a file name as a sequence of characters followed by a period and terminated by an extension made up of additional characters.  EXAMPLE, resume .docx, server .c and Reader Thread.cpp.  The system uses the extension to indicate the type of file and type of operations that can be done on that file.  Only a file with a .com, .exe for the execution of binary files.
  • 9.
    COMMON FILE TYPES FILETYPES USUAL EXTENTION FUNCTION Executable Exe ,com ,bin or none Ready to run machine programs Object o Compile machine language ,not linked Source code C ,cc ,java Source code in various language Mark-up Xml ,html Textual data ,documents Word processor Xml ,docx Various word processor formats Library Lib ,a ,so Libraries of routines for programmers multimedia Mp3 ,mp4 ,mov Binary file containing audio or A/V information
  • 10.
    FILE STRUCTURE:  Filetypes also can be used to indicate the internal structure of the file ,source and object files have structures that match the expectations of the programs that read them.  For Example ,the operating system requires that an executable file have specific structure ,so that it can determine where in memory to load the file.  Some operating system ,extend this idea into a set of system supported file structures ,with sets of special operations for manipulating files with those structures.  The disadvantage of having the operating system support multiple file structures the resulting the size of the operating system is cumbersome.  For Example ,assume that a system supports two types of file:TEXT FILE ,and BINARY FILE. Now the user want to define an encrypted file to protect the contents from being read by unauthorized people.  This scheme provides maximum flexibility but little support. Each application program must include its own code to interpret an input file as accurate structure.
  • 11.
    Internal File structure: oDisk systems typically have a well-defined block size determined by the size of the sector. o All I/O devices performed in units of one block and all blocks are same size. o It is unlikely that the physical record size will exactly match the length of the desired logical record. o Logical records may even vary in length. Packaging a number of logical records into physical blocks is a common solution to this problem. o For Example ,the UNIX operating system defines all files to be simple streams of bytes. Each byte is individually addressable by its offset from the beginning of the file. o In this case, logical record size is 1byte.
  • 12.
    ACCESS METHODS Files storesinformation. When it is used ,this information must be accessed and read into computer memory The information in the files can be accessed in several ways: Sequential Access Direct Access Other Access Methods ACCESS METHODS
  • 13.
    SEQUENTIAL ACCESS:  Thesimplest access method is sequential access. Information in the file is processed in order ,one record after the other.  Reads and write wakeup the bulk of operations on a file. A read operation read next()- read the next portion of a file automatically.  Similarly, the write operation write next()-appends to the end of the file and advances to the end of a new material. beg----------rewind------------current position---------read/write--------------end
  • 14.
    DIRECT ACCESS:  Anothermethod is direct access (or a relative access). Here, a file is made up of fixed length logical records that allow programs to read and write records rapidly in no particular order.  The Direct access method is based on a disk model of a file, since disks allow random access to any file block.  For direct access, the file is viewed as a numbered sequence of blocks or records. Thus, we may read block 14,then red block 53, and then write block 7. There is no restrictions on the order of reading or writing for a direct access file. SEQUENTIAL ACCESS IMPLEMENTATION FOR DIRECT ACCESS reset Cp=0; Read next Read=cp; Cp=cp+1; Write next Write=cp; Cp=cp+1;
  • 15.
    OTHER ACCESS METHODS: Other Access methods can built on top of direct access methods, generally involve the construction of an index for the file.  The index like an index in the back of a book, contains pointers to various blocks.  To find a file, we first search the index and then use the pointer to access the file directly and to find the desired record.