16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introduction to kernel<br />

Summary<br />

File subsystem controls storage and retrieval of data in user files. Files are organized into file systems, which are<br />

treated as logical devices; a physical de' such as a disk can contain several logical devices.<br />

Each file system has a super block that describes <strong>the</strong> structure and contents of <strong>the</strong> file system. Each file in a file<br />

system is described by an inode that gives <strong>the</strong> attributes of <strong>the</strong> file.<br />

Processes exist in various states and move between <strong>the</strong>m according to well defined transition rules.<br />

The kernel is non-preemptive - a process executing in kernel mode will continue t execute until it enters sleep state<br />

or until it returns to execute in user mode.<br />

It maintains <strong>the</strong> consistency of its data structures by enforcing <strong>the</strong> policy of non-preemption and by blocking<br />

interrupts when executing critical regions of code.<br />

The UNIX kernel views all files as streams of bytes<br />

- ordinary - files that contain info<br />

- directory - list of file names + pointers to inodes<br />

- special - access to peripheral devices<br />

- named pipes<br />

! File allocation<br />

- Files are allocated on a block basis.<br />

- Allocation is dynamic, as needed.<br />

! Inode - disk resident<br />

File mode - 16 bit flag<br />

12-14 File type (regular, directory, character, block, FIFO)<br />

9-11 execution flags<br />

8-6 owner read, write, execute permissions<br />

5-3 group read, write, execute permissions<br />

2-0 o<strong>the</strong>r read, write, execute permissions<br />

Link Count - number of directory reference to this inode<br />

Owner ID - owner of file<br />

Group ID - group associated in file<br />

File Size - number of bytes in file<br />

File Addresses - 13 3-byte of addresses<br />

Last Accessed - Time of last file access<br />

Last Modified - Time of last file modification<br />

Inode Modified - Time of last inode modification<br />

UNIX Block Addressing, Scheme<br />

System V block size is lKb, each block has 256 addresses<br />

direct<br />

indirect<br />

------------------------------------------------------------------------<br />

| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |<br />

------------------------------------------------------------------------<br />

10 single indirect 256 blocks 256K bytes<br />

11 double indirect 65K blocks 65M bytes<br />

12 triple indirect 16M blocks l6G bytes<br />

Lower level file system algorithms<br />

namei<br />

- converts a user-level path name to an inode<br />

- uses iget, iput, and bmap<br />

iget & iput - allocate and release inodes<br />

alloc & free - allocate and free disk blocks for files<br />

ialloc & ifree - assign and free inodes for files<br />

87

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!