22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 1 REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation

REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

  • Upload
    vukhanh

  • View
    226

  • Download
    4

Embed Size (px)

Citation preview

Page 1: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

1

REAL TIME OPERATING SYSTEMS

Lesson-7:File System Organization and

Implementation

Page 2: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

2

1. File1. File

Page 3: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

3

File File

a named entity on a magnetic disc, or optical disc, or system memory or memory stick

contains has the data, characters and text

Page 4: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

4

i) A file may be a named entity that is a structured record named entity as on a disk, which has having random access in the system.

ii) May be a structured record on a RAM analogous to a disk and may also be either called separately called as ‘RAM disk’ or simply ,simply, as a ‘file’ itself (virtual device).

OSes differing abstractions of a fileOSes differing abstractions of a file

Page 5: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

5

(iii) May be an unstructured record of bits or bytes.

(iv) A file device may be a pipe -like device

OSes differing abstractions of a fileOSes differing abstractions of a file

Page 6: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

6

2. File organization in a file system2. File organization in a file system

Page 7: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

7

• File is organized in a way according to a file system, which has set of command functions for operations on the file

File organization in a systemFile organization in a system

Page 8: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

8

Standard set of interfacesStandard set of interfaces

Should a file having integers differ from afile having bytes?

Should a file having bytes differ from filehaving characters?

Due to the differing approaches to deviceand file management interfaces, thedevelopment of a set of standard interfacesmust.

Then only then can systems can be portable.

Page 9: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

9

Two type of file systemsTwo type of file systems─ ─ Block File Block File SystemSystem

Block File System. Its application generates records to be saved into the memory.

First structured into a suitable format and then translated into block-streams.

A file pointer (record) points to a block from the start to the end of the file.

Page 10: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

10

Two type of file systems Two type of file systems ─ ─ Byte Stream File Byte Stream File SystemSystem

Byte Stream File-System. Its application generates record stream.

Stream are to be saved into the memory. These are first structured into a suitable

format and then translated into byte-stream. A file pointer (byte index) points to a byte

from the start index = 0 to N-1 in a file of N bytes

Page 11: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

11

POSIXPOSIX

A standard set of interfaces. File operations are as the operations on a

linear sequence of bytes

Page 12: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

12

POSIXPOSIX

POSIX stands for Portable OperatingSystem Interface IEEE standard for codingthe programs when using the multiplethreads.

The X after I is because of the interfacesbeing similar to ones in UNIX like.

It is according to the definitions at A T & TUNIX System V Interface.

Page 13: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

13

open ( ) write ( ) in the byte stream at the present

pointer position read ( ) from the byte stream present pointer

position lseek (List seek) or set the file pointer in the

byte stream fcntl ( ) close ( )

Set of Command Functions in the Set of Command Functions in the POSIX File SystemPOSIX File System

Page 14: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

14

UNIX and LINUX File Systems UNIX and LINUX File Systems

Unix has a structured file system with an unstructured hardware interface.

Linux supports different standard file-systems for the system

Page 15: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

15

File DeviceFile Device

File devices are block devices in UNIX. Linux permits the use of a block devices as

a char devices also. This is because between block-device to char-device, Linux has an additional interface.

Kernel interface is identical for the char and block devices in Linux and not in UNIX.

Page 16: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

16

RAM diskRAM disk

File on the RAM that is hierarchically organized is is known as RAM disk.

RAM memory storage is analogous to that on the disk and accessing is also analogous to a disk.

For example, path for accessing a file is directory, then subdirectory, then folder and then subfolder. There is hierarchical tree like filing organisation

Page 17: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

17

3. File descriptor3. File descriptor

Page 18: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

18

File descriptorFile descriptor─ fd─ fd

An integer, which returns on opening a fileand which points to a data structure.

Page 19: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

19

File describing data structureFile describing data structure

Identity Creator or Owner State Locks and Protection fields file Info Sharing Permission Count Storing Media Details

Page 20: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

20

SummarySummary

Page 21: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

21

We learntWe learnt• File Manager has functions to create, open,

reads, seek a record, write, and close a file.• A file has a file descriptor.

Page 22: REAL TIME OPERATING SYSTEMS Lesson-7: File System ...€¦ · REAL TIME OPERATING SYSTEMS Lesson-7: File System Organization and Implementation. 2008 Chapter-8 L7: "Embedded Systems

2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

22

End of Lesson 7 of Chapter 8End of Lesson 7 of Chapter 8