top of page
Search

Kernal Functional Overview

  • Writer: Abhilasha
    Abhilasha
  • Jul 11, 2024
  • 4 min read

File System Overview


  • Purpose: Manages how data is stored, retrieved, and updated on a disk.

  • Access: Applications interact with the file system using system calls like open, read, and write.

  • Examples:

  • FAT16, FAT32: Older Windows file systems, suitable for simple storage needs.

  • NTFS: Modern Windows file system, supports large files and security features.

  • ext2, ext3: Common Linux file systems, with ext3 adding journaling for better data reliability.

Types of Files in Unix

  1. Ordinary Files:

  • Store user or application data.

  • Examples: text documents, images, programs.

  1. Directory Files:

  • Organize and catalog other files.

  • Act like folders, containing lists of files and directories.

  1. Special Files (Devices):

  • Represent hardware devices.

  • Allow interaction with peripherals like printers or drives.

  1. FIFO Files (Pipes):

  • Enable communication between processes.

  • Allow data to be passed from one process to another in a sequence.


File System Structure

  1. Boot Block:

  • Contains information needed to start (boot) the system.

  1. Super Block:

  • Holds file system specifications such as:

  • Size of the file system

  • Maximum number of files

  • Number of free blocks

  • Number of free inodes

  1. inode List:

  • Stores information about files (metadata) but not the actual data or file name.

  1. Block List:

  • Contains the actual data of the files.

Here's a simple diagram to illustrate this structure:


| Boot Block |

| Super Block|

| inode List |

| Block List |


  • Boot Block: The first block on the disk, essential for starting the system.

  • Super Block: Contains key information about the file system.

  • inode List: Keeps track of file metadata (permissions, ownership, etc.).

  • Block List: Stores the actual contents of the files.


Inode

  • Identifier: Each file has an inode structure identified by an i-number.

  • Information: The inode contains metadata necessary to access the file, such as permissions, ownership, and size.

  • No File Name: The inode does not store the file name, only the metadata.

This structure allows the file system to manage and locate files efficiently based on their metadata.


Directories

  • File Name: Directories store the names of files.

  • Inode Number: Each file name in a directory is associated with an inode number, which points to the file's inode structure.

This mapping helps the file system locate the file's metadata and data on the disk.


Virtual File System (VFS)

  • Management: VFS manages different file systems, making it easier to handle various types of file systems.

  • Abstraction Layer: It acts as a middle layer between applications and actual file system implementations, simplifying interactions.

  • Structure Description: VFS uses concepts like superblocks and inodes to describe the file system structure, similar to how the Ext2 file system works.

  • Inode Cache: Stores frequently accessed inodes to speed up file access.

  • Directory Cache: Stores directory information to improve lookup performance.


Process Management

  • Time-Sharing System: Unix OS allows multiple processes to run by giving each process a short period (time slice) to execute.

  • Kernel Role: The kernel is responsible for creating, managing, and deleting processes.

Process Creation

  • Fork System Call: Most processes are created using the fork system call, which splits an existing process into a parent and child process.

  • Unique Identifier: Each process is assigned a unique Process ID (PID).

Process Structure

  • task_struct: Each process is represented by a task_struct data structure that includes:

  • State: The current status of the process.

  • Scheduling Information: Details about process scheduling.

  • Identifier: Unique Process ID, among other specifications.

  • task_vector: An array of pointers to task_struct data structures. The number of processes is limited by the size of this array.


Types of Processes

  • Running: Processes that are currently executing or ready to execute.

  • Waiting: Processes that are waiting for an event or resource, such as user input or I/O operation completion.

  • Stopped: Processes that have been paused or halted, often due to receiving a specific signal.

  • Zombie: Processes that have completed execution but still have an entry in the process table, typically waiting for their parent process to retrieve their exit status.


Device Driver

  • Purpose: Device drivers in an operating system manage hardware components, abstracting their complexities from applications.

  • Character Devices: Handle data as a stream of bytes, typical examples include keyboards and mice.

  • Block Devices: Data is accessed in fixed-size blocks, common examples are hard disks.

  • Network Devices: Managed by the kernel for network communication.

Major Number and Minor Number

  • Major Number: Identifies the driver associated with a device type.

  • Minor Number: Differentiates between devices controlled by the same driver, allowing for multiple instances or variations of a device type.


Memory Management

  • Physical Memory Limitation: Actual physical memory (RAM) is limited in size.

  • Virtual Memory: Developed to expand the available memory beyond physical limits.

  • Large Address Space: Provides applications with a larger memory address range than physical memory.

  • Protection: Ensures processes cannot access memory allocated to other processes, enhancing security.

  • Memory Mapping: Allows files and devices to be accessed as if they were memory locations.

  • Fair Physical Memory Allocation: Distributes physical memory fairly among processes.

  • Shared Virtual Memory: Enables multiple processes to share the same memory space for efficient communication.

Swap Memory

  • Purpose: Acts as a configurable partition on disk, serving as an extension of physical memory.

  • Function: Allows the operating system to swap out less frequently used memory pages to disk, freeing up physical RAM for more active processes.



Network Layers

Linux Network Layers

Linux networking is structured into several layers that manage the flow of data and communication protocols within the operating system.

BSD Socket Layer

  • General Interface: Provides an abstract layer for networking and inter-process communication (IPC).

  • Socket Address Families: Defines different types of socket address families, each suited for specific networking protocols:

  • UNIX

  • INET (Internet)

  • AX25

  • IPX

  • APPLETALK

  • X25

What is a Socket?

A socket is a software endpoint that establishes communication between two processes running on the network. It allows data exchange by creating a connection-oriented or connectionless channel.

Example in C:

// File I/O using FILE* main() { FILE *fd; fd = fopen(...); process(fd); fclose(fd); } // Socket communication main() { int sockfd; sockfd = socket(...); process(sockfd); close(sockfd); }

INET Socket Layer

  • Supports Internet Address Family: Interfaces with the BSD socket layer using a set of operations registered within the BSD socket layer.

Types of Sockets

  • Stream Socket: Provides a reliable, sequenced, two-way connection, such as TCP.

  • Datagram Socket: Offers connectionless, unreliable communication, like UDP.

  • Raw Socket: Used for low-level network protocols and often requires special privileges to use.


 
 
 

Recent Posts

See All
PE internals

Linked Libraries and Functions Imported Functions: Definition: These are functions used by a program that are actually stored in...

 
 
 
OS internals

Privilege Separation Concept: Modern operating systems separate user applications (untrusted) from critical operating system components...

 
 
 
Memory Management in short

Address Space CPU Access: To run instructions and access data in main memory, the CPU needs unique addresses for that data. Definition:...

 
 
 

Comments


Subscribe Form

Thanks for submitting!

©2021 by just dump 1. Proudly created with Wix.com

bottom of page