Master Linux Fundamentals: From GNU to Kernel Internals Explained
This comprehensive guide covers Linux fundamentals, explaining GNU's role, system components, kernel subsystems, memory addressing, process management, interrupt handling, system calls, synchronization mechanisms, file systems, and device drivers, providing clear answers to common questions for learners and developers.
Linux Operating System Overview
Q1. What is GNU? What is the relationship between Linux and GNU?
GNU stands for "GNU is Not Unix" and is a project of the Free Software Foundation that provides many high‑quality tools such as the Emacs editor and the GNU C/C++ compilers (gcc and g++). Linux uses many GNU tools, and together with the Linux kernel and other free software they form the Linux system or distribution.
Q2. What parts compose a Linux system? Where does the Linux kernel sit?
A Linux system consists of four parts: user processes, the system‑call interface, the Linux kernel subsystem, and hardware. The kernel sits between user processes and hardware, providing the system‑call interface and core kernel services.
Q3. What are the main subsystems of the Linux kernel and their functions?
The kernel includes five major subsystems besides the system call interface: process scheduling, memory management, virtual file system (VFS), networking, and inter‑process communication (IPC). Their primary functions are: 1) Process scheduling: decides which process gets CPU time. 2) Memory management: enables safe sharing of main memory and supports virtual memory. 3) VFS: abstracts various file systems behind a unified interface. 4) Networking: handles network protocols and drivers. 5) IPC: provides mechanisms such as shared memory, message queues, and pipes.
Memory Addressing
Q1. What are physical, virtual, and linear addresses?
Physical address refers to the actual location on the RAM modules. Virtual address is the address space seen by applications, often expressed as segment:offset. Linear address is a contiguous, unsegmented address space ranging from 0 to 4 GB; each linear address is an absolute address within that space.
Q2. How does the MMU translate a virtual address to a physical address in protected mode?
In protected mode the Memory Management Unit (MMU) consists of segmentation and paging components. The segmentation mechanism converts a virtual address to a linear address, and the paging mechanism maps the linear address to a physical address.
Q3. Why are two‑level page tables used for a 32‑bit linear address space?
A two‑level page table reduces memory consumption: the 4 GB space is divided into 1 M pages of 4 KB each, requiring 4 MB for a single‑level table. By using a first‑level page directory and a second‑level page table, the structure fits into 4 KB pages, saving space.
Q4. What is the purpose of the page cache, and why does Linux use paging with a three‑level hierarchy?
The page cache keeps the most recently used 32 page‑table entries, covering about 128 KB of memory. Linux prefers paging because its segmentation model is simple and portable across many architectures; a three‑level paging scheme (PGD, PMD, PT) supports both 32‑bit and 64‑bit processors.
Process
Q1. What are a program and a process, and why introduce the concept of a process?
A program is a file containing executable code and data. A process is the dynamic execution of a program, with its own process image that changes as instructions run. The process concept captures this dynamic execution environment.
Q2. What is a Process Control Block (PCB) and what information does it contain?
In Linux the PCB is the task_struct structure, holding over 80 fields such as state, links, identifiers, IPC info, timing, scheduling data, file system info, virtual memory details, and processor context.
Q3. What are the possible states of a Linux process?
Basic states are running, ready, and blocked. Linux also defines runnable (merged running/ready), sleeping (deep or light), stopped, and zombie states.
Q4. How is a PCB organized?
PCBs can be linked in a process list, stored in hash tables, placed in runnable queues, or kept in wait queues.
Q5. What are the main scheduling algorithms and what factors should a good scheduler consider?
Common algorithms include round‑robin, priority (preemptive and non‑preemptive), multilevel feedback queue, and real‑time scheduling. A good scheduler balances fairness, efficiency, response time, turnaround time, and throughput.
Memory Management
Q1. Why split a process address space into kernel space and user space?
Linux provides a 4 GB virtual address space; the upper 1 GB (0xC0000000‑0xFFFFFFFF) is reserved for the kernel (kernel space) and shared by all processes, while the lower 3 GB (0x00000000‑0xBFFFFFFF) is used by user processes (user space).
Q2. How does Linux implement demand paging?
If a page is not present in physical memory, the kernel allocates and initializes a new page, causing a page‑fault exception. This defers allocation until the process actually accesses the page.
Interrupts and Exceptions
Q1. What are interrupts and exceptions, and how do they differ?
Interrupts are external signals (hardware interrupts) that allow the CPU to respond to I/O events, while exceptions are internal events (faults or traps) generated by the CPU itself.
Q2. What is an interrupt vector and how does Linux allocate them?
Interrupt vectors are 8‑bit identifiers (0‑255) that label interrupt sources. Linux uses vectors 0‑31 for exceptions/NMI, 32‑47 for hardware interrupts, and 48‑255 for software interrupts (e.g., vector 0x80 for system calls).
Q3. What is the Interrupt Descriptor Table (IDT) and a gate descriptor?
In protected mode the IDT replaces the 1 KB real‑mode vector table; each entry is 8 bytes and is called a gate descriptor.
Q4. What types of gate descriptors exist?
Types include interrupt gates (type 110), trap gates (type 111), and system gates used by the kernel for user‑mode access to trap handlers.
System Calls
Q1. What is a system call and why is it introduced?
System calls provide a standardized interface for user‑mode processes to request services from the kernel, improving portability, ease of programming, and system security.
Kernel Synchronization
Q1. What are critical sections, race conditions, and synchronization?
A critical section is code that accesses shared data; a race condition occurs when multiple tasks enter the same critical section simultaneously. Synchronization techniques prevent such races.
Q2. Briefly describe deadlock and how to avoid it.
Deadlock arises from mutual exclusion, non‑preemptibility, hold‑and‑wait, and circular wait. Avoidance methods break one of these conditions, such as allowing preemption or preventing circular wait.
Q3. What causes concurrency in the kernel?
Concurrency stems from interrupts, kernel preemption, sleeping processes that trigger the scheduler, and symmetric multiprocessing.
Q4. Define a semaphore and explain the meaning of down() and up().
A semaphore is a sleeping lock introduced by Dijkstra. The down() operation decrements the count to acquire the semaphore; up() increments the count to release it.
File System
Q1. What is the Linux directory tree and how does it differ from Windows?
Linux has a single root directory (/) with all other directories beneath it, regardless of the number of physical partitions, whereas Windows uses separate drive letters as roots. This unified hierarchy simplifies multi‑user management.
Q2. What is a Virtual File System (VFS) and its interface?
VFS provides a uniform abstraction layer so that user programs can use the same system calls to access different underlying file systems. Its core objects include superblocks, inodes, dentries, and file structures.
Device Drivers
Q1. Why are devices classified as block or character devices?
Linux treats devices as files. Block devices transfer data in fixed‑size blocks (e.g., disks) and are typically used by file systems; character devices transfer data byte‑by‑byte (e.g., keyboards).
Q2. What is a device driver?
A device driver is the software component in Linux that manages and controls hardware controllers.
Q3. What registers are typically found in an I/O port and what are their functions?
I/O ports include control registers, status registers, and data registers. Access can be memory‑mapped or I/O‑mapped.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
