Download presentation
Presentation is loading. Please wait.
1
An overview of the kernel structure
3
UNIX File Types Most files on a UNIX system are either regular files or directories, but there are additional types of files. The types are: Regular file. Directory file Block special file Character special file FIFO Socket Symbolic link.
4
File type macros in <sys/stat.h>
Macro Type of file S_ISREG() regular file S_ISDIR() directory file S_ISCHR() character special file S_ISBLK() block special file S_ISFIFO() pipe or FIFO S_ISLNK() symbolic link S_ISSOCK() socket
5
FILE SUBSYSTEM A file system consists of a sequence of logical blocks, each containing 512, 1024, 2048, or any convenient multiple of 512 bytes, depending on the system implementation. The size of a logical block is homogeneous within a file system but may vary between different file systems in a system configuration. Using large logical blocks increases the effective data transfer rate between disk and memory, because the kernel can transfer more data per disk operation and therefore make fewer time-consuming operations. For example, reading 1K bytes from a disk in one read operation is faster than reading 512 bytes twice. However, if a logical block is too large,effective storage capacity may drop.
6
FILE SUBSYSTEM
7
The boot block occupies the beginning of a file system, typically the first sector, and may contain the bootstrap code that is read into the machine to boot, or initialize, the operating system. Although only one boot block is needed to boot the system, every file system has a (possibly empty) boot block. The super block describes the state of a file system - how large it is, how many files it can store, where to find free space on the file system, and other information.
8
The inode list is a list of inodes that follows the super block in the file system.
Administrators specify the size of the inode list when configuring a file system. The kernel references inodes by index into the inode list. The data blocks start at the end of the inode list and contain file data and administrativedata. An allocated data block can belong to one and only one file in the file system.
9
The i-node contains all the information about the file: the file type, the file's access permission bits, the size of the file, pointers to the data blocks for the file, and so on. Most of the information in the stat structure is obtained from the i-node.
12
INTERNAL REPRESENTATION OF A FILE
13
The internal representation of a file is given by an inode,which contains a description of the disk layout of the file data and other information such as -file owner -access permissions -access times. Ex: open(“/fs2/mjb/rje/sourcefile”,1);
14
File sharing The UNIX System supports the sharing of open files among different processes 1.Every process has an entry in the process table. a. The file descriptor flags b. A pointer to a file table entry 2. The kernel maintains a file table for all open files. Each file table entry contains a. The file status flags for the file, such as read, write, append, sync, and non blocking. b. The current file offset. c. A pointer to the v-node table entry for the file 3. Each open file (or device) has a v-node structure that contains information about the type of file and pointers to functions that operate on the file.
16
Two independent processes with the same file open
17
UNIX SYSTEM CALL Typically, UNIX kernels execute the following secure seven steps on a system call: Arguments (if present) for the system call are determined. Arguments (if present) for the system call are pushed in a stack. 3. The state of calling process is saved in a user structure. 4. The process switches to kernel mode. 5. The system call vector is used as an interface to the kernel routine. 6. The kernel initiates the services routine and a return value is obtained from the 7. Kernel service routine. 8. The return value is converted to a c version (usually an integer or a long integer).
19
An Example of a System Call
User process executes a system call open a file. • User process links to a c runtime library for open and sets up the needed parameters in registers. • A S/W trap is executed now and the operation switches to the kernel mode. - The kernel looks up the system call vector to call "open" - The kernel tables are modified to open the file. - Return to the point of call with exit status. • Return to the user process with value and status. • The user process may resume now with modified status on file or abort on error with exit status.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.