1. Linux & Kernel Fundamentals
Basic
- What is Linux?
- What is the Linux kernel?
- What is the difference between Linux and the Linux kernel?
- What is the kernel space and user space?
- Why is user space separated from kernel space?
- What happens when a user-space application calls a system call?
- What is a system call?
- What is the difference between system call and library call?
- What is a kernel module?
- What is a loadable kernel module (LKM)?
- Why do we use kernel modules?
- What is the difference between built-in driver and loadable driver?
- What is
insmod? - What is
rmmod? - What is
modprobe? - Difference between
insmodandmodprobe. - What is
lsmod? - What is
modinfo? - What is
/lib/modules? - What is
sysfs? - What is
procfs? - Difference between
/procand/sys.
2. Linux Device Driver Fundamentals
- What is a device driver?
- Why do we need device drivers?
- What are the different types of Linux drivers?
- What is a character driver?
- What is a block driver?
- What is a network driver?
- Difference between character and block drivers.
- What is a device?
- What is a device number?
- What is a major number?
- What is a minor number?
- Why are major and minor numbers required?
- What is
dev_t? - What is
MAJOR()? - What is
MINOR()? - What is
MKDEV()? - What is dynamic device number allocation?
- Difference between static and dynamic major number allocation.
Important APIs
alloc_chrdev_region()
register_chrdev_region()
unregister_chrdev_region()
Know why, when and how each is used.
3. Character Device Driver
This is one of the highest-priority interview areas.
Questions
- How do you write a basic character driver?
- What are the steps to create a character driver?
- What is
struct file_operations? - What is
struct file? - What is
struct inode? - What is
struct cdev? - Difference between
inodeandfile. - What is
file_operations? - Explain:
open()read()write()close()ioctl()poll()mmap()llseek()
- How does a user-space
read()reach the driver’sread()function? - How does a user-space
write()reach the driver’swrite()function? - What is
private_data? - How do you store driver-specific information in
private_data? - What is
copy_to_user()? - What is
copy_from_user()? - Why can’t we directly dereference a user-space pointer from kernel space?
- Difference between
copy_to_user()andmemcpy(). - What does
copy_to_user()return? - What does
copy_from_user()return? - What happens if user-space passes an invalid pointer?
4. Device Driver Registration
Know the complete sequence.
Character driver
alloc_chrdev_region()
↓
cdev_init()
↓
cdev_add()
↓
class_create()
↓
device_create()
↓
/dev/mydevice
Interview questions:
- Explain this entire flow.
- What does
cdev_init()do? - What does
cdev_add()do? - What is a Linux device class?
- What does
class_create()do? - What does
device_create()do? - Who creates
/dev/mydevice? - What is
udev? - Difference between
device_create()andclass_create(). - How do you remove a character device cleanly?
5. Kernel Module Programming
Prepare these very well.
- What is a kernel module?
- What is
module_init()? - What is
module_exit()? - What happens during module insertion?
- What happens during module removal?
- What is
MODULE_LICENSE()? - What is
MODULE_AUTHOR()? - What is
MODULE_DESCRIPTION()? - What is
MODULE_DEVICE_TABLE()? - What is
EXPORT_SYMBOL()? - Difference between:
EXPORT_SYMBOLEXPORT_SYMBOL_GPL
- Can a kernel module call user-space functions?
- Can kernel code use
printf()? - Why do we use
printk()/pr_info()? - What is
dmesg? - How do you debug a module that fails to load?
- What does “Unknown symbol” mean?
- What is symbol resolution?
6. Kernel Memory Management
Very important for experienced Embedded Linux interviews.
- How does kernel memory allocation work?
- Difference between user-space
malloc()and kernelkmalloc(). - What is
kmalloc()? - What is
kzalloc()? - What is
kcalloc()? - What is
vmalloc()? - Difference between
kmalloc()andvmalloc(). - What is
kfree()? - What is
vfree()? - What are GFP flags?
- What is
GFP_KERNEL? - What is
GFP_ATOMIC? - Difference between
GFP_KERNELandGFP_ATOMIC. - Why can’t you sleep in atomic context?
- What is physically contiguous memory?
- What is virtually contiguous memory?
- What is DMA?
- What is DMA-coherent memory?
- What is a memory leak?
- How can you detect kernel memory leaks?
7. Kernel Virtual Memory
- What is virtual memory?
- Virtual address vs physical address.
- What is kernel virtual address?
- What is physical address?
- What is
virt_to_phys()? - What is
phys_to_virt()? - What is
ioremap()? - Why do we need
ioremap()? - Difference between normal RAM and I/O memory.
- What is
readl()? - What is
writel()? - Difference between:
*ptr = value;
and
writel(value, ptr);
8. Device Tree
For modern Embedded Linux, this is extremely important.
- What is Device Tree?
- Why do we need Device Tree?
- What problem does Device Tree solve?
- What is DTS?
- What is DTSI?
- What is DTB?
- What is DTBO?
- How does Linux use Device Tree?
- What is a Device Tree node?
- What is a Device Tree property?
- What is
compatible? - What is
reg? - What is
interrupts? - What is
clocks? - What is
gpio? - What is
gpios? - What is
status = "okay"? - What does
status = "disabled"mean? - What is
#address-cells? - What is
#size-cells? - What are phandles?
- What is
&label? - What is Device Tree overlay?
- How does driver match with Device Tree?
- Explain
of_match_table. - What is
MODULE_DEVICE_TABLE(of, ...)? - What happens when
compatiblematches? - How do you read a Device Tree property from a driver?
- What is
of_property_read_u32()? - What is
of_get_named_gpio()? - What is
devm_*?
Very common interview question
How does a Device Tree node get connected to a driver?
Know this flow:
Device Tree
↓
compatible
↓
Driver of_match_table
↓
Kernel matching
↓
probe()
↓
Device initialized
9. Platform Driver
Extremely important.
- What is a platform driver?
- What is a platform device?
- Why are platform drivers used?
- What is
struct platform_driver? - What is
probe()? - What is
remove()? - When is
probe()called? - When is
remove()called? - What is
platform_device? - Difference between platform driver and platform device.
- What is platform driver matching?
- How does Device Tree match with platform driver?
- What is
platform_get_resource()? - What is
platform_get_irq()? - What is
devm_ioremap_resource()? - What is
devm_kzalloc()? - Why are
devm_*APIs useful? - What happens automatically when a device is removed?
10. Interrupts
Very high priority.
- What is an interrupt?
- Hardware interrupt vs software interrupt.
- What is IRQ?
- What is ISR?
- What is interrupt context?
- What is
request_irq()? - What is
free_irq()? - Explain interrupt handler.
- What is
irqreturn_t? - What is
IRQ_HANDLED? - What is
IRQ_NONE? - What is shared IRQ?
- What is
IRQF_SHARED? - Why can’t you sleep inside an ISR?
- Can you call
kmalloc(GFP_KERNEL)inside ISR? - Why do we use
GFP_ATOMICin interrupt context? - What is top half?
- What is bottom half?
- Why do we need bottom halves?
- What is a tasklet?
- What is a workqueue?
- Difference between tasklet and workqueue.
- What is threaded IRQ?
- Difference between hard IRQ and threaded IRQ.
- What is
request_threaded_irq()? - Which operations are allowed in interrupt context?
- How do you handle a long interrupt operation?
11. Synchronization
One of the most frequently tested areas.
- Why do we need synchronization?
- What is a race condition?
- What is a critical section?
- What is a mutex?
- What is a spinlock?
- Difference between mutex and spinlock.
- When should you use a mutex?
- When should you use a spinlock?
- Can you sleep while holding a spinlock?
- Can you sleep while holding a mutex?
- Can mutex be used inside ISR?
- Can spinlock be used inside ISR?
- What is semaphore?
- Mutex vs semaphore.
- What is completion?
- What is atomic operation?
- What is
atomic_t? - What is
atomic_inc()? - What is
atomic_dec()? - What is deadlock?
- What is priority inversion?
- What is lock ordering?
- What is recursive locking?
- What happens if the same spinlock is acquired twice?
12. Wait Queues
- What is a wait queue?
- Why are wait queues used?
- What is
wait_event()? - What is
wait_event_interruptible()? - What is
wake_up()? - Difference between
wake_up()andwake_up_interruptible(). - Why should a driver put a process to sleep?
- What is blocking I/O?
- What is non-blocking I/O?
- What does
O_NONBLOCKmean? - How do you implement blocking
read()? - How do you wake up a blocked process?
Example concept:
Application
↓
read()
↓
No data available
↓
Process sleeps
↓
Hardware interrupt
↓
Data available
↓
wake_up()
↓
Process resumes
13. Poll / Select / Epoll
- What is
poll()? - Why do drivers implement
poll()? - What is
select()? - What is
epoll()? - How does application know that device data is available?
- What is
poll_wait()? - Difference between blocking
read()andpoll(). - How do you implement
poll()in a driver?
14. I/O Control – ioctl
Very common.
- What is
ioctl()? - Why do we use ioctl?
- When should you use
read/writevsioctl? - How do you implement ioctl?
- What is
_IO()? - What is
_IOR()? - What is
_IOW()? - What is
_IOWR()? - Why are ioctl command numbers required?
- How do you pass a structure from user space to kernel?
- How do you safely copy ioctl data?
- What security problems can ioctl introduce?
15. I2C Driver
For embedded interviews, very important.
- What is I2C?
- How does I2C work?
- What are SDA and SCL?
- What is I2C slave address?
- What is ACK/NACK?
- What is repeated START?
- What is an I2C adapter?
- What is an I2C client?
- What is
struct i2c_driver? - What is
struct i2c_client? - What is
struct i2c_adapter? - What is
probe()in an I2C driver? - What is
remove()? - What is
i2c_transfer()? - What is
i2c_master_send()? - What is
i2c_master_recv()? - What is SMBus?
- I2C vs SMBus.
- How does Device Tree describe an I2C device?
- How does an I2C driver bind to a device?
16. SPI Driver
- What is SPI?
- SPI signals:
- MOSI
- MISO
- CLK
- CS
- SPI master vs slave.
- What is SPI mode?
- What are CPOL and CPHA?
- What is
struct spi_driver? - What is
struct spi_device? - What is
spi_transfer? - What is
spi_message? - Difference between I2C and SPI.
- How does SPI driver communicate with hardware?
- How is SPI device represented in Device Tree?
- How does SPI driver matching happen?
17. GPIO Driver
- What is GPIO?
- Input vs output GPIO.
- What is GPIO descriptor?
- What is the GPIO subsystem?
- How do you request a GPIO?
- How do you configure GPIO direction?
- How do you read GPIO?
- How do you write GPIO?
- What is
gpiod_get()? - What is
gpiod_set_value()? - What is
gpiod_get_value()? - Why is descriptor-based GPIO preferred over legacy GPIO APIs?
- How do you define GPIO in Device Tree?
18. Pin Control
- What is pinctrl?
- Why is pinctrl required?
- What is pin multiplexing?
- What is pin configuration?
- What is
pinctrl-0? - What is
pinctrl-names? - What happens if pinmux is incorrectly configured?
- How does Device Tree configure pins?
19. DMA
Important for high-performance embedded systems.
- What is DMA?
- Why do we need DMA?
- CPU vs DMA data transfer.
- What is DMA buffer?
- What is DMA mapping?
- What is
dma_map_single()? - What is
dma_unmap_single()? - What is
dma_alloc_coherent()? - What is cache coherency?
- What is DMA streaming mapping?
- What is coherent DMA?
- What happens if CPU cache and DMA memory are inconsistent?
- What is DMA mask?
- What is
dma_set_mask_and_coherent()?
20. Device Model
- What is Linux device model?
- What is
struct device? - What is a bus?
- What is a driver?
- What is a device?
- What is a class?
- What is kobject?
- What is sysfs?
- What is bus-driver-device relationship?
- Explain:
Bus
├── Device
└── Driver
- What is device binding?
- What is driver binding?
- What is
bind/unbind?
21. Kernel Threads
- What is a kernel thread?
- Why do we need kernel threads?
- How do you create a kernel thread?
- What is
kthread_run()? - What is
kthread_stop()? - Difference between kernel thread and user-space thread.
- Can a kernel thread sleep?
- How do you stop a kernel thread safely?
22. Workqueues
- What is a workqueue?
- Why use workqueues?
- What is deferred work?
- What is
work_struct? - What is
INIT_WORK()? - What is
schedule_work()? - What is
flush_work()? - Workqueue vs kernel thread.
- Workqueue vs tasklet.
23. Timers
- What is a kernel timer?
- Why are timers used?
- What is
struct timer_list? - What is
timer_setup()? - What is
mod_timer()? - What is
del_timer()? - Can timer callback sleep?
- Timer vs delayed work.
- How do you implement periodic work?
24. Power Management
Important for automotive/embedded.
- What is Linux power management?
- What is suspend/resume?
- What is runtime PM?
- What is system suspend?
- What are:
suspend()resume()
- What is runtime suspend?
- What is runtime resume?
- What is
pm_runtime_get_sync()? - What is
pm_runtime_put()? - Why is runtime PM important in embedded systems?
- How do you handle device state during suspend/resume?
25. Error Handling
- How do you handle errors in kernel drivers?
- What are kernel error codes?
- Why do kernel functions return negative values?
- What is
PTR_ERR()? - What is
IS_ERR()? - What is
ERR_PTR()? - Difference between NULL pointer and ERR_PTR.
- What is
dev_err()? - What is
dev_warn()? - What is
dev_info()? - How do you clean up resources if probe fails halfway?
Very important pattern
Resource 1 acquired
↓
Resource 2 acquired
↓
Resource 3 fails
↓
Release Resource 2
↓
Release Resource 1
↓
Return error
26. Device-Managed Resources
- What is
devm_kzalloc()? - What is
devm_ioremap_resource()? - What is
devm_request_irq()? - Why use
devm_*functions? - When are managed resources automatically released?
- Difference between
kzalloc()anddevm_kzalloc().
27. Memory-Mapped I/O
- What is MMIO?
- What is a memory-mapped register?
- How does CPU access hardware registers?
- What is
ioremap()? - What are
readb/readw/readl? - What are
writeb/writew/writel? - Why shouldn’t normal pointer dereferencing be used for MMIO?
- What is register polling?
- What is register masking?
- How do you set/clear a register bit safely?
28. C Concepts for Driver Interviews
Because Linux drivers are heavily based on C, prepare:
- Pointer
- Pointer to pointer
- Function pointer
- Callback function
- Structure
- Union
- Structure padding
- Bit fields
- Bit manipulation
volatileconststaticexterninlinetypedef- Macro
- Preprocessor
- Memory alignment
- Endianness
- Signed vs unsigned
- Race conditions
- Stack vs heap
- Function pointers
- Linked lists
- Circular buffers
Especially know:
volatile
const
static
and:
struct
union
enum
typedef
29. Linked Lists in Kernel
- Why does Linux use linked lists?
- What is
struct list_head? - What is an intrusive linked list?
- What is
INIT_LIST_HEAD()? - What is
list_add()? - What is
list_del()? - What is
list_for_each()? - What is
container_of()? - Why is
container_of()important? - Explain how Linux retrieves a parent structure from
list_head.
30. container_of()
This is a favorite interview question.
struct device_data {
int value;
struct list_head list;
};
Question:
If you have a pointer to
list, how do you getdevice_data?
Answer:
container_of()
Know how offsetof() works as well.
31. Concurrency & Race Conditions
Prepare real scenarios:
- What is a race condition?
- How can two processes access the same driver?
- How can interrupt and process context race?
- How do you protect shared data?
- Mutex vs spinlock.
- Atomic variables.
- Memory barriers.
- What is
smp_mb()? - What is
READ_ONCE()? - What is
WRITE_ONCE()? - What is lock contention?
- What is deadlock?
- How do you debug deadlock?
32. Atomic Context vs Process Context
Very important.
Process context
Can generally:
Sleep
Schedule
Acquire mutex
kmalloc(GFP_KERNEL)
Wait for resources
Interrupt/atomic context
Cannot sleep.
Generally use:
Spinlock
GFP_ATOMIC
Atomic operations
Interview question:
Why can’t an interrupt handler sleep?
You should be able to explain this clearly.
33. Debugging Linux Drivers
- How do you debug a kernel driver?
- What is
dmesg? - What is
printk? - What is dynamic debug?
- What is ftrace?
- What is tracepoint?
- What is
debugfs? - What is
sysfs? - How do you debug kernel panic?
- What is Oops?
- What is kernel panic?
- Difference between Oops and kernel panic.
- What is NULL pointer dereference?
- How do you find the source line of a crash?
- What is
addr2line? - What is
gdb? - What is KGDB?
- What is KASAN?
- What is lockdep?
- What is kmemleak?
34. Kernel Crash Scenarios
Interviewers may give scenarios.
Example
Driver crashes with NULL pointer dereference. What will you do?
Expected approach:
Check dmesg
↓
Find faulting address
↓
Find call stack
↓
Identify source line
↓
Check pointer initialization
↓
Check probe/remove sequence
↓
Fix and reproduce
Other scenarios:
- Kernel panic during module insertion.
- Driver probe is never called.
read()blocks forever.- Interrupt never occurs.
- I2C device isn’t detected.
- SPI communication fails.
/dev/mydeviceisn’t created.- Driver loads but doesn’t bind.
- DMA data is corrupted.
- System freezes when driver is unloaded.
35. Sysfs
- What is sysfs?
- Why does sysfs exist?
- How does driver expose attributes?
- What is
struct device_attribute? - What are
show()andstore()? - What is
DEVICE_ATTR()? - Difference between sysfs and procfs.
- When should you use sysfs?
- Why shouldn’t sysfs be used for large data transfers?
36. Procfs
- What is
/proc? - What information does
/procprovide? - Can a driver create
/procentries? - Difference between
/procand/sys. - When would you use procfs?
37. Debugfs
- What is debugfs?
- Why is debugfs used?
- Difference between sysfs and debugfs.
- Should production applications depend on debugfs?
- How can a driver expose debugging information through debugfs?
38. User Space ↔ Kernel Space
Very important.
Know these mechanisms:
System calls
↓
ioctl
↓
read/write
↓
mmap
↓
poll/select/epoll
Questions:
- How does user space communicate with driver?
- Why can’t user space directly access kernel memory?
- What is a system call?
- What happens during
read()? - What happens during
write()? - What happens during
ioctl()? - What is
mmap()? - Why use
mmap()? - What is zero-copy?
39. mmap in Device Drivers
- What is
mmap()? - Why map kernel/device memory to user space?
- How does driver implement mmap?
- What is zero-copy?
- What are the security risks of mmap?
- Difference between
read/writeandmmap.
40. Block Drivers
For advanced interviews:
- What is a block device?
- Character vs block device.
- What is a block layer?
- What is a request queue?
- What is bio?
- What is I/O scheduler?
- What is
/dev/sda? - What is
/dev/mmcblk0? - What is NVMe?
- Basic Linux storage stack.
41. Network Drivers
If the job requires networking:
- What is a network driver?
- What is
struct net_device? - What is NAPI?
- What is interrupt-driven packet reception?
- Why is NAPI used?
- What is
sk_buff? - What is TX/RX ring?
- What is DMA in network drivers?
- What happens when an Ethernet packet arrives?
- Explain Linux network stack.
42. Boot Process + Driver
Very common in Embedded Linux.
Know:
Power ON
↓
Boot ROM
↓
Bootloader
↓
Kernel
↓
Device Tree
↓
Kernel initialization
↓
Driver initialization
↓
Root filesystem
↓
init/systemd
↓
User application
Questions:
- What happens after power-on?
- What is BootROM?
- What is U-Boot?
- What does U-Boot do?
- How does U-Boot load Device Tree?
- How does kernel start?
- When are drivers initialized?
- What is
initcall? - What is root filesystem?
- What happens if the driver is built into the kernel?
43. Kernel Build System
- What is Kconfig?
- What is Makefile in kernel?
- What is
.config? - What is
menuconfig? - What is
defconfig? - What is
CONFIG_*? - Built-in vs module:
CONFIG_DRIVER=y
CONFIG_DRIVER=m
CONFIG_DRIVER=n
- Difference between
y,m, andn. - How do you enable a driver?
- How do you build an external module?
44. Cross Compilation
For Embedded Linux:
- What is cross compilation?
- Why do we cross compile?
- Host vs target.
- What is cross compiler?
- What is
ARCH? - What is
CROSS_COMPILE? - How do you build a kernel for ARM?
- How do you build an external driver for another architecture?
- What is kernel build directory?
- Why must module and kernel versions/configuration match?
45. Linux Driver + Yocto
Since Embedded Linux jobs often combine these skills:
- What is Yocto?
- What is BitBake?
- How do you add a kernel driver to Yocto?
- What is a recipe?
- What is a layer?
- What is
SRC_URI? - What is
inherit module? - How do you compile an external kernel module using Yocto?
- How do you add a Device Tree change?
- How do you enable a kernel configuration?
- What is
KERNEL_MODULE_AUTOLOAD? - What is
IMAGE_INSTALL? - Difference between built-in driver and module in Yocto.
- How do you debug a driver build failure in BitBake?
46. Real-Time / Automotive Driver Questions
For automotive Embedded Linux, prepare:
- What is PREEMPT?
- What is PREEMPT_RT?
- What is real-time Linux?
- What is interrupt latency?
- What is scheduling latency?
- What is priority inversion?
- What is CPU affinity?
- What is
SCHED_FIFO? - What is
SCHED_RR? - What is
SCHED_OTHER? - How do you reduce driver latency?
- How do you handle high-frequency interrupts?
- How do you handle DMA buffers?
- How do you debug intermittent audio/data loss?
47. Most Important Scenario Questions
These are particularly useful for interviews:
Scenario 1
Driver is loaded but
probe()isn’t called. Why?
Possible areas:
compatible mismatch
Device Tree disabled
driver not registered
wrong bus
missing device
module not loaded
Scenario 2
/dev/mydevicedoesn’t exist. What do you check?
Driver loaded?
↓
Major/minor allocated?
↓
cdev_add() successful?
↓
class_create()?
↓
device_create()?
↓
udev?
Scenario 3
Interrupt isn’t coming.
Check:
Device Tree IRQ
↓
IRQ number
↓
request_irq()
↓
Hardware interrupt enable
↓
GPIO/pinmux
↓
Interrupt controller
↓
ISR
Scenario 4
I2C device doesn’t respond.
Check:
Power
↓
SDA/SCL
↓
Pull-ups
↓
Pinmux
↓
I2C address
↓
Bus speed
↓
Device Tree
↓
I2C controller
↓
Driver
Scenario 5
System freezes randomly.
Think about:
Deadlock
Race condition
Spinlock issue
Interrupt storm
Memory corruption
Use-after-free
NULL pointer
DMA corruption
48. Must-Know Kernel APIs
Try to recognize these immediately:
kmalloc()
kzalloc()
kfree()
copy_to_user()
copy_from_user()
mutex_lock()
mutex_unlock()
spin_lock()
spin_unlock()
wait_event()
wake_up()
request_irq()
free_irq()
ioremap()
iounmap()
readl()
writel()
alloc_chrdev_region()
cdev_init()
cdev_add()
class_create()
device_create()
platform_driver_register()
platform_driver_unregister()
devm_kzalloc()
devm_request_irq()
request_threaded_irq()
schedule_work()
kthread_run()
kthread_stop()
dma_alloc_coherent()
dma_map_single()
dma_unmap_single()
49. Top 30 Questions You MUST Prepare
If your interview is soon, prioritize these:
- What is a Linux device driver?
- Kernel space vs user space.
- Character vs block driver.
- Major/minor number.
file_operations.inodevsfile.cdev.alloc_chrdev_region().cdev_add().class_create()anddevice_create().copy_to_user()/copy_from_user().- Kernel module lifecycle.
- Device Tree.
compatibleproperty.- Device Tree → driver →
probe(). - Platform driver.
probe()andremove().- Interrupt handling.
- Top half vs bottom half.
- Workqueue vs tasklet.
- Mutex vs spinlock.
- Process context vs interrupt context.
- Wait queue.
kmalloc()vsvmalloc().GFP_KERNELvsGFP_ATOMIC.- MMIO and
ioremap(). - I2C driver architecture.
- SPI driver architecture.
- DMA.
- Driver debugging using
dmesg, ftrace, debugfs, etc.
Recommended interview preparation order
C fundamentals
↓
Linux fundamentals
↓
Kernel/User space
↓
Kernel modules
↓
Character drivers
↓
Device model
↓
Device Tree
↓
Platform drivers
↓
Interrupts
↓
Synchronization
↓
Wait queues
↓
Memory management
↓
I2C
↓
SPI
↓
GPIO
↓
DMA
↓
Power management
↓
Debugging
↓
Yocto + Driver
↓
Real-world scenarios
Linux Internals Interview Questions – Complete A-Z
1. Linux Architecture
- What is Linux?
- What is the Linux kernel?
- Explain Linux architecture.
- What are the major components of Linux?
- What is kernel space?
- What is user space?
- Why are user space and kernel space separated?
- What happens when a user application starts?
- What happens when a Linux command is executed?
- What happens when you execute
./a.out? - What is the role of the shell?
- What is the role of the kernel?
- What is GNU/Linux?
- What is monolithic kernel?
- Is Linux a monolithic kernel?
- What is a modular monolithic kernel?
- Monolithic vs microkernel.
- What are the advantages of Linux’s architecture?
- What are kernel subsystems?
- Explain the Linux kernel at a high level.
Know this architecture
User Applications
↓
Libraries
↓
System Calls
↓
Linux Kernel
┌───────────────┐
│ Process Mgmt │
│ Memory Mgmt │
│ VFS │
│ Networking │
│ IPC │
│ Drivers │
│ Scheduler │
└───────────────┘
↓
Hardware
2. Boot Process
- What happens when a Linux system powers ON?
- What is Boot ROM?
- What is firmware?
- What is a bootloader?
- What is U-Boot?
- What does U-Boot do?
- How does bootloader load the kernel?
- How does bootloader load Device Tree?
- What is
Image? - What is
zImage? - What is
uImage? - What is FIT image?
- What is initramfs?
- What is root filesystem?
- What is
/sbin/init? - What is systemd?
- What happens after kernel decompression?
- What is
start_kernel()? - What happens inside
start_kernel()? - How does Linux initialize devices?
- What are initcalls?
- What is
early_initcall()? - What is
subsys_initcall()? - What is
module_init()? - How does Linux finally start user space?
Embedded Linux boot flow
Power ON
↓
Boot ROM
↓
Bootloader
↓
DRAM Initialization
↓
Load Kernel
↓
Load Device Tree
↓
Kernel
↓
start_kernel()
↓
Kernel Initialization
↓
Root Filesystem
↓
init/systemd
↓
User Applications
3. Process Internals
This is one of the most important Linux Internal topics.
- What is a process?
- What is a program?
- Program vs process.
- What happens when a process is created?
- What is PCB?
- What is
task_struct? - What information is stored in
task_struct? - What is PID?
- What is PPID?
- What is TGID?
- What is TID?
- What is a process ID namespace?
- What is process state?
- Explain:
- Running
- Runnable
- Sleeping
- Stopped
- Zombie
- What is a zombie process?
- What is an orphan process?
- What happens to an orphan process?
- What is
init/PID 1? - What is
fork()? - What is
vfork()? - Difference between
fork()andvfork(). - What is
clone()? - How does Linux create a process?
- What happens internally during
fork()? - What is
exec()? - Difference between
fork()andexec(). - What is
wait()? - What is
waitpid()? - Why does a parent call
wait()? - What is process termination?
- What happens when
exit()is called? - What is
_exit()? exit()vs_exit().- What is process hierarchy?
- What is a process tree?
- What is
pstree? - What is process context?
4. Threads
- What is a thread?
- Process vs thread.
- Why use threads?
- What resources are shared between threads?
- What resources are private to each thread?
- Do threads have separate address spaces?
- What is a kernel thread?
- User thread vs kernel thread.
- What is
pthread_create()? - What is
pthread_join()? - What is thread cancellation?
- What is thread-local storage?
- What is TLS?
- How does Linux implement threads?
- What is
clone()? - Why are Linux threads often described as tasks?
- What is a thread group?
- What is TGID?
- What is TID?
5. CPU Scheduling
Very frequently asked.
- What is process scheduling?
- Why do we need a scheduler?
- What is the Linux scheduler?
- What is context switching?
- What happens during a context switch?
- Process context vs interrupt context.
- What is preemptive scheduling?
- What is cooperative scheduling?
- What is scheduling latency?
- What is time slice?
- What is priority?
- What is nice value?
- What is
nice? - What is
renice? - What is CFS?
- What is the Completely Fair Scheduler?
- What is
SCHED_NORMAL? - What is
SCHED_FIFO? - What is
SCHED_RR? - What is
SCHED_DEADLINE? - FIFO vs Round Robin.
- Real-time scheduling vs normal scheduling.
- What is starvation?
- What is priority inversion?
- How is priority inversion handled?
- What is CPU affinity?
- What is
taskset? - What is CPU isolation?
- What is load balancing?
- How does Linux select the next task?
- What is a runqueue?
- What is scheduler tick?
- What is tickless Linux?
- What is
CONFIG_NO_HZ?
6. Context Switching
- What is context switching?
- Why does context switching happen?
- What is saved during context switch?
- What is restored?
- Process context switch vs thread context switch.
- What is register context?
- What is stack context?
- What is address-space switching?
- Why is context switching expensive?
- What happens to CPU cache during context switching?
- What is TLB?
- Does every context switch flush the TLB?
- How does ASID/PCID help?
- What is voluntary context switching?
- What is involuntary context switching?
- How can you measure context switches?
7. System Calls
One of the most important Linux internals topics.
- What is a system call?
- Why are system calls needed?
- User function vs system call.
- Library call vs system call.
- What happens internally when
read()is called? - What happens when
write()is called? - What happens when
open()is called? - What happens when
fork()is called? - What happens when
execve()is called? - What is system call number?
- How does kernel identify a system call?
- What is syscall entry?
- What is syscall return?
- What is trap instruction?
- What is privilege-level transition?
- What happens to CPU registers during syscall?
- How does user space return from kernel space?
- What is
strace? - How can
stracehelp debug applications? - Can user space directly call kernel functions?
- Why can’t user space access kernel memory directly?
8. CPU Privilege Levels
- What is privilege?
- User mode vs kernel mode.
- What is ring 0?
- What is ring 3?
- Why does Linux use different privilege levels?
- What happens during user → kernel transition?
- What happens during kernel → user transition?
- What is a trap?
- What is an exception?
- What is an interrupt?
- Interrupt vs exception vs trap.
9. Virtual Memory
Extremely important.
- What is virtual memory?
- Why does Linux use virtual memory?
- Virtual address vs physical address.
- What is address space?
- What is process address space?
- What is virtual address space?
- What is page?
- What is page frame?
- What is page table?
- What is multi-level page table?
- Why are multi-level page tables used?
- What is MMU?
- What is TLB?
- Why do we need TLB?
- What is page fault?
- Minor vs major page fault.
- What happens during a page fault?
- What is demand paging?
- What is lazy allocation?
- What is copy-on-write?
- How does
fork()use copy-on-write? - What is memory mapping?
- What is
mmap()? - What is anonymous memory?
- What is file-backed memory?
- What is shared memory?
- What is private memory?
- What is memory overcommit?
- What is ASLR?
- What is memory protection?
10. Process Address Space
Know this diagram:
High Address
+------------------+
| Kernel Space |
+------------------+
| Stack |
| ↓ |
| |
| ↑ |
| Heap |
+------------------+
| BSS |
| Data |
| Text |
+------------------+
Low Address
Questions:
- What is text segment?
- What is data segment?
- What is BSS?
- What is heap?
- What is stack?
- Heap vs stack.
- Where are global variables stored?
- Where are static variables stored?
- Where are local variables stored?
- Where are string literals stored?
- What causes stack overflow?
- What is stack frame?
- What is function call stack?
- What is ASLR?
- How does shared library memory appear in process address space?
11. Memory Allocation
- What is
malloc()? - What happens internally during
malloc()? malloc()vscalloc().malloc()vsrealloc().- What is
brk()? - What is
sbrk()? - What is
mmap()used for in memory allocation? - How does glibc allocate memory?
- What is memory fragmentation?
- Internal vs external fragmentation.
- What is memory leak?
- How do you find memory leaks?
- What is
valgrind? - What is AddressSanitizer?
- What is double free?
- What is use-after-free?
- What is dangling pointer?
12. Kernel Memory Management
- What is
kmalloc()? - What is
kzalloc()? - What is
vmalloc()? kmalloc()vsvmalloc().- What is
GFP_KERNEL? - What is
GFP_ATOMIC? - Why can’t
GFP_KERNELbe used in interrupt context? - What is the buddy allocator?
- What is SLAB?
- What is SLUB?
- What is SLOB?
- Why does Linux use slab allocation?
- What is an object cache?
- What is page allocator?
- What is high memory?
- What is low memory?
- What is physically contiguous memory?
- What is virtually contiguous memory?
13. Buddy Allocator
- What is buddy system?
- Why is buddy allocator used?
- What is an order?
- What is an order-0 page?
- How does buddy splitting work?
- How does buddy merging work?
- What is external fragmentation?
- Why can’t large physically contiguous allocations always succeed?
- What is compaction?
14. Slab / SLUB Allocator
- Why do we need slab allocator?
- What is a slab?
- What is a cache?
- What is an object?
- Slab vs page allocator.
- SLAB vs SLUB.
- Why is SLUB commonly used?
- What is
kmem_cache_create()? - What is
kmem_cache_alloc()? - What is
kmem_cache_free()?
15. Page Cache
- What is page cache?
- Why does Linux use page cache?
- How does
read()interact with page cache? - How does
write()interact with page cache? - What is buffered I/O?
- What is direct I/O?
- What is
O_DIRECT? - What is dirty page?
- What is writeback?
- What is
fsync()? - What is
sync()? - What is
fdatasync()? - What is writeback cache?
- What happens if RAM becomes full of cached data?
16. File Descriptors
- What is a file descriptor?
- Why does Linux represent devices/files using file descriptors?
- What is FD 0?
- What is FD 1?
- What is FD 2?
- What happens when
open()is called? - What is a file descriptor table?
- What is an open file description?
- What is
struct file? - What is an inode?
- FD vs inode vs file.
- What happens when
close()is called? - What happens if two processes share an FD?
- What happens after
fork()? - What is
dup()? - What is
dup2()? - What is
dup3()? - What is FD inheritance?
17. VFS – Virtual File System
Very important for Linux internals.
- What is VFS?
- Why does Linux need VFS?
- What is a filesystem?
- What is an inode?
- What is a dentry?
- What is
struct file? - What is
super_block? - Explain:
Process
↓
System Call
↓
VFS
↓
Filesystem
↓
Block Layer
↓
Device Driver
↓
Hardware
- What is inode cache?
- What is dentry cache?
- What is pathname lookup?
- What happens during
open("/home/test.txt")? - What is
namei? - What is mount?
- What is superblock?
- Hard link vs symbolic link.
- What happens when a file is deleted?
- Can a deleted file still be open?
18. Filesystem Internals
- What is ext4?
- What is inode?
- What is directory entry?
- What is block?
- What is filesystem block size?
- What is journaling?
- Why is journaling needed?
- What happens after sudden power failure?
- What is
fsck? - What is mount?
- What is unmount?
- What is
/etc/fstab? - What is root filesystem?
- What is tmpfs?
- What is procfs?
- What is sysfs?
- What is devtmpfs?
- What is debugfs?
- What is overlayfs?
- What is NFS?
19. IPC – Inter-Process Communication
- What is IPC?
- Why is IPC needed?
- What are the IPC mechanisms?
- Pipe
- FIFO
- Message queue
- Shared memory
- Semaphore
- Signal
- Socket
- Pipe vs FIFO.
- Message queue vs shared memory.
- Shared memory vs pipe.
- Which IPC mechanism is fastest?
- Why is shared memory fast?
- How do you synchronize shared memory?
20. Pipes
- What is a pipe?
- How does
pipe()work? - Anonymous pipe vs named pipe.
- What is FIFO?
- What happens if pipe buffer is full?
- What happens if no reader exists?
- Is pipe unidirectional?
- How is pipe implemented inside kernel?
21. Signals
- What is a signal?
- Why are signals used?
- What is
SIGINT? SIGTERMvsSIGKILL.SIGSTOPvsSIGCONT.- What is
SIGSEGV? - What is
SIGCHLD? - What happens when a signal is generated?
- What is signal handler?
- Can you catch
SIGKILL? - Can you catch
SIGSTOP? - Signal vs interrupt.
- What is signal masking?
- What is pending signal?
- What is blocked signal?
- What is
sigaction()? - Why is
sigaction()preferred over oldsignal()?
22. Shared Memory
- What is shared memory?
- Why is shared memory fast?
- What is
mmap()? - What is POSIX shared memory?
- What is System V shared memory?
- Shared memory synchronization.
- Can multiple processes write simultaneously?
- What happens without synchronization?
- Shared memory vs message queue.
23. Synchronization
- What is synchronization?
- What is race condition?
- What is critical section?
- What is mutex?
- What is semaphore?
- What is spinlock?
- Mutex vs semaphore.
- Mutex vs spinlock.
- What is read-write lock?
- What is RCU?
- What is atomic operation?
- What is
atomic_t? - What is memory barrier?
- What is deadlock?
- What is livelock?
- What is starvation?
- What is priority inversion?
- How do you avoid deadlocks?
- What is lock ordering?
- Can a mutex be used in interrupt context?
- Can a spinlock be used in process context?
- Can you sleep while holding a spinlock?
24. RCU
For advanced interviews:
- What is RCU?
- Why was RCU introduced?
- Read-copy-update concept.
- Why is RCU useful for read-heavy workloads?
- What is an RCU read-side critical section?
- What is
rcu_read_lock()? - What is
rcu_read_unlock()? - What is
synchronize_rcu()? - RCU vs mutex.
- RCU vs spinlock.
25. Deadlock
- What is deadlock?
- Four conditions for deadlock.
- Mutual exclusion.
- Hold and wait.
- No preemption.
- Circular wait.
- How do you prevent deadlock?
- How do you debug deadlock?
- What is lockdep?
- Give an example of kernel deadlock.
26. Interrupts
- What is an interrupt?
- Hardware vs software interrupt.
- What is IRQ?
- What is ISR?
- Interrupt context.
- What happens when an interrupt occurs?
- What is interrupt controller?
- What is IRQ number?
- Shared IRQ.
- Edge-triggered vs level-triggered.
- What is interrupt affinity?
- What is interrupt storm?
- What is interrupt latency?
- What is top half?
- What is bottom half?
- What is threaded IRQ?
- What is tasklet?
- What is workqueue?
- Why can’t ISR sleep?
- What is
request_irq()? - What is
free_irq()?
27. Kernel Timers
- What is kernel timer?
- Why use kernel timers?
- What is timer callback?
- Can timer callback sleep?
- Timer vs workqueue.
- Timer vs delayed work.
- What happens if timer callback takes too long?
- How do you create a kernel timer?
28. Workqueues
- What is workqueue?
- Why defer work?
- What is
work_struct? - What is
schedule_work()? - Can workqueue sleep?
- Workqueue vs tasklet.
- Workqueue vs kernel thread.
- What is ordered workqueue?
- What is dedicated workqueue?
29. Kernel Threads
- What is a kernel thread?
- How is it different from a user thread?
- What is
kthread_run()? - What is
kthread_stop()? - Can kernel threads sleep?
- How does a kernel thread terminate?
- Why would a driver use a kernel thread?
30. Networking Internals
For Embedded Linux, prepare the basics.
- Explain Linux networking architecture.
- What happens when you run:
ping 8.8.8.8
- What happens when an Ethernet frame arrives?
- What is NIC?
- What is network driver?
- What is
net_device? - What is socket?
- What is socket buffer (
sk_buff)? - What is TCP/IP stack?
- What is ARP?
- What is routing?
- What is IP address?
- MAC address vs IP address.
- TCP vs UDP.
- What is port?
- What is network namespace?
- What is NAPI?
- Why is NAPI required?
- Interrupt-driven RX vs polling.
- What is checksum offload?
- What is TSO?
- What is GRO?
- What is RSS?
- What is DMA in network drivers?
31. Socket Internals
- What is a socket?
- What happens during
socket()? - What happens during
bind()? - What happens during
listen()? - What happens during
accept()? - What happens during
connect()? - What happens during
send()? - What happens during
recv()? - What is socket buffer?
- Blocking vs non-blocking socket.
- What is
select()? - What is
poll()? - What is
epoll()? - Why is
epoll()efficient? - Level-triggered vs edge-triggered.
32. DMA
- What is DMA?
- Why use DMA?
- CPU copy vs DMA.
- What is DMA buffer?
- What is DMA mapping?
- What is DMA coherent memory?
- What is cache coherency?
dma_map_single().dma_unmap_single().dma_alloc_coherent().- Streaming DMA vs coherent DMA.
- What is DMA mask?
- What is IOMMU?
- CPU cache vs DMA.
- What happens if cache isn’t synchronized?
33. Device Model
- What is Linux device model?
- What is a device?
- What is a driver?
- What is a bus?
- What is a class?
- What is kobject?
- What is sysfs?
- What is device binding?
- What is driver binding?
- Explain:
Bus
├── Device
└── Driver
- What is
struct device? - What is reference counting?
- What is
kref? - What is hotplug?
- What is uevent?
- What is udev?
34. Device Tree
- What is Device Tree?
- Why do we need Device Tree?
- DTS vs DTSI.
- DTS vs DTB.
- What is DTBO?
- What is a node?
- What is a property?
- What is
compatible? - What is
reg? - What is
interrupts? - What is
clocks? - What is
gpios? - What is
status? - What is phandle?
- What is Device Tree overlay?
- How does Device Tree bind to a driver?
- What is
of_match_table? - What is
of_device_id? - What is
probe()? - How does the kernel discover hardware from Device Tree?
35. Kernel Modules
- What is kernel module?
- Why use modules?
- Built-in vs module.
- What is
.ko? - What is
insmod? - What is
modprobe? - What is
rmmod? - What is
lsmod? - What is
modinfo? - What is module dependency?
- What is symbol export?
- What is
EXPORT_SYMBOL()? - What is
EXPORT_SYMBOL_GPL()? - What happens during module loading?
- What happens during unloading?
- Why can a module fail to unload?
- What is module reference count?
36. Sysfs / Procfs / Debugfs
- What is sysfs?
- What is procfs?
- What is debugfs?
- Difference between them.
- What information is exposed through
/proc? - What information is exposed through
/sys? - Why shouldn’t debugfs be used as a stable application interface?
- How does a driver create a sysfs attribute?
- What are
show()andstore()? - What is
DEVICE_ATTR()?
37. Kernel Synchronization Context
Interviewers love scenario questions:
Q: Can you sleep here?
Prepare answers for:
| Context | Can Sleep? |
|---|---|
| User process | Yes |
| Kernel process context | Yes |
| Kernel thread | Yes |
| Interrupt handler | No |
| Timer callback | No |
| Spinlock-held context | No |
| Atomic context | No |
Then expect:
Why?
What API can you use instead?
Which GFP flag should you use?
38. ELF & Program Loading
- What is ELF?
- What is an ELF executable?
- What is an ELF header?
- What is a program header?
- What is a section header?
- What is
.text? - What is
.data? - What is
.bss? - What is symbol table?
- What is relocation?
- What is dynamic linking?
- What is static linking?
- Static vs dynamic linking.
- What is a shared library?
- What is
.so? - What is the dynamic linker?
- What is
ld.so? - What happens when you execute an ELF binary?
- What is ASLR?
- What is PIE?
39. Dynamic Linking
- Static vs dynamic library.
- What is
.so? - What is
LD_LIBRARY_PATH? - What is
ldconfig? - What is dynamic linker?
- What is symbol resolution?
- What is PLT?
- What is GOT?
- What is lazy binding?
- What is
LD_PRELOAD?
40. IPC + Synchronization Scenarios
Prepare scenarios like:
Two processes access the same shared buffer. How will you synchronize?
Producer produces data faster than consumer. What happens?
Consumer waits until data arrives. What IPC/synchronization mechanism would you use?
Multiple threads update the same variable. What can go wrong?
An interrupt updates a buffer while a process reads it. How will you protect it?
41. Blocking & Non-Blocking I/O
- What is blocking I/O?
- What is non-blocking I/O?
- What is
O_NONBLOCK? - What happens when
read()has no data? - What is
EAGAIN? - What is
EWOULDBLOCK? - How does
poll()work? - How does
select()work? - How does
epoll()work? - Blocking vs polling.
- Blocking read vs interrupt-driven design.
42. select() / poll() / epoll()
- Why do we need I/O multiplexing?
- What is
select()? - What is
poll()? - What is
epoll()? select()vspoll().poll()vsepoll().- Why is
epoll()more scalable? - Level-triggered vs edge-triggered.
- What is
EPOLLIN? - What is
EPOLLOUT? - What is
EPOLLERR? - How does a device driver implement
poll()?
43. Signals vs Interrupts
Very common conceptual question.
| Interrupt | Signal |
|---|---|
| Hardware/kernel event | Process notification |
| Usually handled by kernel/ISR | Delivered to process |
| CPU/hardware related | Process related |
| Example GPIO interrupt | SIGTERM |
Questions:
- Difference between interrupt and signal.
- Can a process generate a signal?
- Can kernel generate a signal?
- What is hardware interrupt?
- What is software interrupt?
44. Time Management
- What is system clock?
- What is clock tick?
- What is jiffies?
- What is
HZ? - What is monotonic clock?
- What is realtime clock?
- Difference between
CLOCK_REALTIMEandCLOCK_MONOTONIC. - What is high-resolution timer?
- What is timer interrupt?
- What is
nanosleep()? - What is
clock_nanosleep()? - Why is
CLOCK_MONOTONICpreferred for measuring elapsed time?
45. SMP / Multicore Linux
- What is SMP?
- What is multicore?
- How does Linux handle multiple CPUs?
- What is CPU affinity?
- What is per-CPU data?
- Why use per-CPU variables?
- What is cache coherence?
- What is cache line?
- What is false sharing?
- What is CPU migration?
- What is load balancing?
- What is NUMA?
- What is memory barrier?
- Why are locks more important on SMP?
46. Cache & Memory Ordering
For senior Embedded Linux roles:
- What is CPU cache?
- L1/L2/L3 cache.
- What is cache line?
- What is cache coherence?
- What is memory ordering?
- What is memory barrier?
- Why is compiler reordering different from CPU reordering?
- What is
READ_ONCE()? - What is
WRITE_ONCE()? - What is
smp_mb()? - What is
smp_rmb()? - What is
smp_wmb()? - How can missing barriers cause race conditions?
- What is false sharing?
47. OOM – Out Of Memory
- What happens when Linux runs out of memory?
- What is OOM?
- What is OOM Killer?
- Why does Linux kill a process?
- How does Linux select a process?
- What is
oom_score? - What is
oom_score_adj? - How do you debug OOM?
- What is swap?
- Why might an embedded system disable swap?
48. Swap
- What is swap?
- Why is swap used?
- What is swap partition?
- What is swap file?
- What happens during swapping?
- What is swap-in?
- What is swap-out?
- What is thrashing?
- Why is swap usually avoided in some embedded systems?
49. Kernel Panic / Oops
- What is kernel panic?
- What is kernel Oops?
- Oops vs panic.
- What is NULL pointer dereference?
- What is use-after-free?
- What is stack overflow?
- What is kernel BUG?
- How do you debug a kernel crash?
- What is call trace?
- What is
dmesg? - What is
addr2line? - What is
vmlinux? - Why is debug information important?
- What is
CONFIG_DEBUG_INFO?
50. Linux Debugging
- How do you debug a Linux application?
- How do you debug a kernel?
- What is
gdb? - What is
strace? - What is
ltrace? - What is
dmesg? - What is
ftrace? - What is
perf? - What is
top? - What is
htop? - What is
vmstat? - What is
iostat? - What is
sar? - What is
free? - What is
/proc/meminfo? - What is
/proc/cpuinfo? - What is
/proc/interrupts? - What is
/proc/<pid>/maps? - What is
/proc/<pid>/status? - What is
/proc/<pid>/fd/?
51. Performance Debugging
- CPU usage is 100%. How do you debug?
- System is slow. What do you check?
- Memory usage is increasing continuously. What do you check?
- Process is blocked. How do you debug?
- High interrupt usage — what could cause it?
- High context switches — what could cause it?
- High CPU but low application workload — why?
- High I/O wait — what does it mean?
- What is
perf? - What is profiling?
- What is flame graph?
- What is tracing?
- Profiling vs tracing.
52. Kernel Tracing
- What is ftrace?
- What is tracepoint?
- What is kprobe?
- What is kretprobe?
- What is eBPF?
- What is perf?
- What is function tracing?
- What is event tracing?
- How can you trace system calls?
- How can you trace scheduler events?
53. eBPF
For modern Linux interviews:
- What is eBPF?
- Why is eBPF useful?
- What can eBPF observe?
- eBPF vs kernel module.
- What is a BPF program?
- What is BPF map?
- What is verifier?
- How can eBPF help debugging?
- What is
bpftrace? - What is
bpftool?
54. Namespaces
- What are Linux namespaces?
- Why are namespaces used?
- What is PID namespace?
- Network namespace?
- Mount namespace?
- IPC namespace?
- UTS namespace?
- User namespace?
- Cgroup namespace?
- How do namespaces help containers?
55. Cgroups
- What are cgroups?
- Why are cgroups used?
- CPU cgroup.
- Memory cgroup.
- I/O cgroup.
- What is resource limiting?
- What is resource accounting?
- Namespace vs cgroup.
- How do containers use namespaces and cgroups?
56. Containers / Docker Internals
- What is a container?
- Container vs virtual machine.
- How does Linux support containers?
- Namespaces.
- Cgroups.
- Overlay filesystem.
- Capabilities.
- What is container isolation?
- What is PID namespace?
- What happens when a container starts?
57. Linux Security Internals
- What is permission?
- What is UID?
- What is GID?
- Real UID vs effective UID.
- What is
setuid? - What are Linux capabilities?
- What is
CAP_NET_ADMIN? - What is
CAP_SYS_ADMIN? - What is DAC?
- What is MAC?
- What is SELinux?
- What is AppArmor?
- What is seccomp?
- What is ASLR?
- What is NX/DEP?
58. Kernel Synchronization + Interrupt Scenario Questions
Be ready for questions like:
Q1
ISR updates a variable and user thread reads it. What problem can occur?
Q2
Can you use mutex inside ISR?
Q3
Why use spinlock in interrupt context?
Q4
What happens if you call
schedule()while holding a spinlock?
Q5
Why use a workqueue after an interrupt?
Q6
What happens if two CPUs access the same variable simultaneously?
Q7
How do memory barriers solve ordering problems?
59. Linux Power Management
Important for embedded systems.
- What is suspend?
- What is resume?
- What is system sleep?
- What is runtime PM?
- What is runtime suspend?
- What is runtime resume?
- What is wakeup source?
- What is autosuspend?
- What is CPU idle?
- What is CPU frequency scaling?
- What is
cpufreq? - What is
cpuidle? - How does a driver participate in suspend/resume?
60. Embedded Linux Internals
For your target profile, definitely prepare:
- Bootloader → kernel flow.
- Kernel → Device Tree.
- Device Tree → driver.
- Driver → hardware.
- Interrupt → driver.
- DMA → memory.
- User application → driver.
- Driver → sysfs.
- Driver →
/dev. - ALSA architecture.
- Linux audio pipeline.
- I2C/SPI/GPIO.
- Kernel configuration.
- Cross compilation.
- Root filesystem.
- Init/systemd.
- Yocto integration.
- Kernel module integration.
- Debugging boot failures.
- Debugging driver probe failures.
61. ALSA / Audio Internals
Since Automotive Linux/audio roles can ask this:
- What is ALSA?
- ALSA architecture.
- What is ALSA kernel layer?
- What is ALSA userspace library?
- What is PCM?
- What is PCM device?
- What is PCM playback?
- What is PCM capture?
- What is PCM buffer?
- What is period?
- What is period size?
- What is buffer size?
- What is sample rate?
- What is bit depth?
- What is channel count?
- What is ALSA driver?
- What is ASoC?
- What is codec driver?
- What is CPU DAI?
- What is codec DAI?
- What is DAPM?
- What is machine driver?
- What is audio routing?
- How does an ALSA application reach hardware?
62. Linux Audio Stack
Know this flow:
Application
↓
ALSA / PulseAudio / PipeWire
↓
ALSA Kernel
↓
ASoC
↓
Machine Driver
↓
CPU DAI
↓
Codec / DSP
↓
I2S / TDM
↓
Audio Hardware
Possible questions:
Explain Linux audio architecture.
What happens when an application plays audio?
ALSA vs PulseAudio?
What is ASoC?
What is DAI?
What is PCM?
63. Driver + Linux Internals Scenario Questions
These are extremely important for experienced interviews.
Scenario 1
Application calls
read(). Explain everything that happens internally.
Expected chain:
Application
↓
libc
↓
system call
↓
Kernel
↓
VFS
↓
file_operations
↓
Driver read()
↓
Hardware/buffer
↓
copy_to_user()
↓
Application
Scenario 2
Hardware generates an interrupt. Explain what happens.
Hardware
↓
Interrupt Controller
↓
CPU
↓
IRQ Entry
↓
ISR
↓
Schedule Deferred Work
↓
Driver
↓
Wake Waiting Process
↓
Application
Scenario 3
Application writes to
/dev/mydevice.
Explain:
open()
↓
VFS
↓
driver open()
write()
↓
VFS
↓
driver write()
↓
copy_from_user()
↓
hardware
Scenario 4
Driver’s
probe()isn’t getting called.
Check:
Device exists?
↓
Correct bus?
↓
Device Tree?
↓
compatible?
↓
Driver registered?
↓
match table?
↓
Kernel configuration?
↓
probe()
Scenario 5
System randomly crashes after several hours.
Think:
Memory leak
↓
Use-after-free
↓
Race condition
↓
Buffer overflow
↓
DMA corruption
↓
Stack overflow
↓
Deadlock
64. Top 50 Linux Internals Questions
If you have limited interview preparation time, master these first:
- Linux architecture.
- Kernel space vs user space.
- Linux boot process.
start_kernel().- Process vs program.
task_struct.fork().exec().clone().wait().- Zombie vs orphan.
- Threads vs processes.
- Context switching.
- Scheduler.
- CFS.
- Real-time scheduling.
- System calls.
- User → kernel transition.
- Virtual memory.
- Page tables.
- MMU.
- TLB.
- Page fault.
- Copy-on-write.
mmap().malloc()internals.- Kernel memory allocation.
- Buddy allocator.
- SLAB/SLUB.
- Page cache.
- File descriptors.
- VFS.
- inode.
- dentry.
- superblock.
open()internals.- IPC.
- Signals.
- Shared memory.
- Mutex vs spinlock.
- Deadlock.
- Interrupt handling.
- Top half/bottom half.
- Workqueue.
- Device Tree.
- Device model.
- DMA.
- Kernel debugging.
- Kernel panic/Oops.
- Linux networking internals.
65.What Interviewers Usually Do
For an experienced Embedded Linux candidate, don’t expect only:
“What is a mutex?”
They may ask:
“Suppose an ISR receives data into a ring buffer and a userspace application reads that data. Explain the complete design.”
You should be able to discuss:
Hardware
↓
DMA
↓
Ring Buffer
↓
Interrupt
↓
ISR / Threaded IRQ
↓
Synchronization
↓
Wait Queue
↓
Driver read()
↓
copy_to_user()
↓
Application
Then they may go deeper:
Why DMA?
Why ring buffer?
Why spinlock?
Can ISR sleep?
Why wait queue?
What happens if buffer is full?
What happens if application is slow?
How do you prevent race conditions?
How do you handle cache coherency?
How would you debug data corruption?
That’s the level you should prepare for.
Best preparation sequence
For your Embedded Linux / Automotive Audio background, I’d study Linux internals in this order:
1. Linux Architecture
↓
2. Boot Process
↓
3. Processes & Threads
↓
4. Scheduling
↓
5. System Calls
↓
6. Virtual Memory
↓
7. Memory Management
↓
8. VFS & File Systems
↓
9. File Descriptors
↓
10. IPC
↓
11. Signals
↓
12. Synchronization
↓
13. Interrupts
↓
14. Workqueues / Kernel Threads
↓
15. Device Model
↓
16. Device Tree
↓
17. Drivers
↓
18. DMA
↓
19. Networking
↓
20. Power Management
↓
21. Kernel Debugging
↓
22. Performance / Tracing
↓
23. ALSA / ASoC
↓
24. Yocto + Kernel
↓
25. Real-world Scenarios
Linux Internals Interview Questions – Complete A–Z
1. Linux Architecture
- What is Linux?
- What is the Linux kernel?
- Explain Linux architecture.
- What are the major components of Linux?
- What is kernel space?
- What is user space?
- Why are user space and kernel space separated?
- What happens when a user application starts?
- What happens when a Linux command is executed?
- What happens when you execute
./a.out? - What is the role of the shell?
- What is the role of the kernel?
- What is GNU/Linux?
- What is monolithic kernel?
- Is Linux a monolithic kernel?
- What is a modular monolithic kernel?
- Monolithic vs microkernel.
- What are the advantages of Linux’s architecture?
- What are kernel subsystems?
- Explain the Linux kernel at a high level.
Know this architecture
User Applications
↓
Libraries
↓
System Calls
↓
Linux Kernel
┌───────────────┐
│ Process Mgmt │
│ Memory Mgmt │
│ VFS │
│ Networking │
│ IPC │
│ Drivers │
│ Scheduler │
└───────────────┘
↓
Hardware
2. Boot Process
- What happens when a Linux system powers ON?
- What is Boot ROM?
- What is firmware?
- What is a bootloader?
- What is U-Boot?
- What does U-Boot do?
- How does bootloader load the kernel?
- How does bootloader load Device Tree?
- What is
Image? - What is
zImage? - What is
uImage? - What is FIT image?
- What is initramfs?
- What is root filesystem?
- What is
/sbin/init? - What is systemd?
- What happens after kernel decompression?
- What is
start_kernel()? - What happens inside
start_kernel()? - How does Linux initialize devices?
- What are initcalls?
- What is
early_initcall()? - What is
subsys_initcall()? - What is
module_init()? - How does Linux finally start user space?
Embedded Linux boot flow
Power ON
↓
Boot ROM
↓
Bootloader
↓
DRAM Initialization
↓
Load Kernel
↓
Load Device Tree
↓
Kernel
↓
start_kernel()
↓
Kernel Initialization
↓
Root Filesystem
↓
init/systemd
↓
User Applications
3. Process Internals
This is one of the most important Linux Internal topics.
- What is a process?
- What is a program?
- Program vs process.
- What happens when a process is created?
- What is PCB?
- What is
task_struct? - What information is stored in
task_struct? - What is PID?
- What is PPID?
- What is TGID?
- What is TID?
- What is a process ID namespace?
- What is process state?
- Explain:
- Running
- Runnable
- Sleeping
- Stopped
- Zombie
- What is a zombie process?
- What is an orphan process?
- What happens to an orphan process?
- What is
init/PID 1? - What is
fork()? - What is
vfork()? - Difference between
fork()andvfork(). - What is
clone()? - How does Linux create a process?
- What happens internally during
fork()? - What is
exec()? - Difference between
fork()andexec(). - What is
wait()? - What is
waitpid()? - Why does a parent call
wait()? - What is process termination?
- What happens when
exit()is called? - What is
_exit()? exit()vs_exit().- What is process hierarchy?
- What is a process tree?
- What is
pstree? - What is process context?
4. Threads
- What is a thread?
- Process vs thread.
- Why use threads?
- What resources are shared between threads?
- What resources are private to each thread?
- Do threads have separate address spaces?
- What is a kernel thread?
- User thread vs kernel thread.
- What is
pthread_create()? - What is
pthread_join()? - What is thread cancellation?
- What is thread-local storage?
- What is TLS?
- How does Linux implement threads?
- What is
clone()? - Why are Linux threads often described as tasks?
- What is a thread group?
- What is TGID?
- What is TID?
5. CPU Scheduling
Very frequently asked.
- What is process scheduling?
- Why do we need a scheduler?
- What is the Linux scheduler?
- What is context switching?
- What happens during a context switch?
- Process context vs interrupt context.
- What is preemptive scheduling?
- What is cooperative scheduling?
- What is scheduling latency?
- What is time slice?
- What is priority?
- What is nice value?
- What is
nice? - What is
renice? - What is CFS?
- What is the Completely Fair Scheduler?
- What is
SCHED_NORMAL? - What is
SCHED_FIFO? - What is
SCHED_RR? - What is
SCHED_DEADLINE? - FIFO vs Round Robin.
- Real-time scheduling vs normal scheduling.
- What is starvation?
- What is priority inversion?
- How is priority inversion handled?
- What is CPU affinity?
- What is
taskset? - What is CPU isolation?
- What is load balancing?
- How does Linux select the next task?
- What is a runqueue?
- What is scheduler tick?
- What is tickless Linux?
- What is
CONFIG_NO_HZ?
6. Context Switching
- What is context switching?
- Why does context switching happen?
- What is saved during context switch?
- What is restored?
- Process context switch vs thread context switch.
- What is register context?
- What is stack context?
- What is address-space switching?
- Why is context switching expensive?
- What happens to CPU cache during context switching?
- What is TLB?
- Does every context switch flush the TLB?
- How does ASID/PCID help?
- What is voluntary context switching?
- What is involuntary context switching?
- How can you measure context switches?
7. System Calls
One of the most important Linux internals topics.
- What is a system call?
- Why are system calls needed?
- User function vs system call.
- Library call vs system call.
- What happens internally when
read()is called? - What happens when
write()is called? - What happens when
open()is called? - What happens when
fork()is called? - What happens when
execve()is called? - What is system call number?
- How does kernel identify a system call?
- What is syscall entry?
- What is syscall return?
- What is trap instruction?
- What is privilege-level transition?
- What happens to CPU registers during syscall?
- How does user space return from kernel space?
- What is
strace? - How can
stracehelp debug applications? - Can user space directly call kernel functions?
- Why can’t user space access kernel memory directly?
8. CPU Privilege Levels
- What is privilege?
- User mode vs kernel mode.
- What is ring 0?
- What is ring 3?
- Why does Linux use different privilege levels?
- What happens during user → kernel transition?
- What happens during kernel → user transition?
- What is a trap?
- What is an exception?
- What is an interrupt?
- Interrupt vs exception vs trap.
9. Virtual Memory
Extremely important.
- What is virtual memory?
- Why does Linux use virtual memory?
- Virtual address vs physical address.
- What is address space?
- What is process address space?
- What is virtual address space?
- What is page?
- What is page frame?
- What is page table?
- What is multi-level page table?
- Why are multi-level page tables used?
- What is MMU?
- What is TLB?
- Why do we need TLB?
- What is page fault?
- Minor vs major page fault.
- What happens during a page fault?
- What is demand paging?
- What is lazy allocation?
- What is copy-on-write?
- How does
fork()use copy-on-write? - What is memory mapping?
- What is
mmap()? - What is anonymous memory?
- What is file-backed memory?
- What is shared memory?
- What is private memory?
- What is memory overcommit?
- What is ASLR?
- What is memory protection?
10. Process Address Space
Know this diagram:
High Address
+------------------+
| Kernel Space |
+------------------+
| Stack |
| ↓ |
| |
| ↑ |
| Heap |
+------------------+
| BSS |
| Data |
| Text |
+------------------+
Low Address
Questions:
- What is text segment?
- What is data segment?
- What is BSS?
- What is heap?
- What is stack?
- Heap vs stack.
- Where are global variables stored?
- Where are static variables stored?
- Where are local variables stored?
- Where are string literals stored?
- What causes stack overflow?
- What is stack frame?
- What is function call stack?
- What is ASLR?
- How does shared library memory appear in process address space?
11. Memory Allocation
- What is
malloc()? - What happens internally during
malloc()? malloc()vscalloc().malloc()vsrealloc().- What is
brk()? - What is
sbrk()? - What is
mmap()used for in memory allocation? - How does glibc allocate memory?
- What is memory fragmentation?
- Internal vs external fragmentation.
- What is memory leak?
- How do you find memory leaks?
- What is
valgrind? - What is AddressSanitizer?
- What is double free?
- What is use-after-free?
- What is dangling pointer?
12. Kernel Memory Management
- What is
kmalloc()? - What is
kzalloc()? - What is
vmalloc()? kmalloc()vsvmalloc().- What is
GFP_KERNEL? - What is
GFP_ATOMIC? - Why can’t
GFP_KERNELbe used in interrupt context? - What is the buddy allocator?
- What is SLAB?
- What is SLUB?
- What is SLOB?
- Why does Linux use slab allocation?
- What is an object cache?
- What is page allocator?
- What is high memory?
- What is low memory?
- What is physically contiguous memory?
- What is virtually contiguous memory?
13. Buddy Allocator
- What is buddy system?
- Why is buddy allocator used?
- What is an order?
- What is an order-0 page?
- How does buddy splitting work?
- How does buddy merging work?
- What is external fragmentation?
- Why can’t large physically contiguous allocations always succeed?
- What is compaction?
14. Slab / SLUB Allocator
- Why do we need slab allocator?
- What is a slab?
- What is a cache?
- What is an object?
- Slab vs page allocator.
- SLAB vs SLUB.
- Why is SLUB commonly used?
- What is
kmem_cache_create()? - What is
kmem_cache_alloc()? - What is
kmem_cache_free()?
15. Page Cache
- What is page cache?
- Why does Linux use page cache?
- How does
read()interact with page cache? - How does
write()interact with page cache? - What is buffered I/O?
- What is direct I/O?
- What is
O_DIRECT? - What is dirty page?
- What is writeback?
- What is
fsync()? - What is
sync()? - What is
fdatasync()? - What is writeback cache?
- What happens if RAM becomes full of cached data?
16. File Descriptors
- What is a file descriptor?
- Why does Linux represent devices/files using file descriptors?
- What is FD 0?
- What is FD 1?
- What is FD 2?
- What happens when
open()is called? - What is a file descriptor table?
- What is an open file description?
- What is
struct file? - What is an inode?
- FD vs inode vs file.
- What happens when
close()is called? - What happens if two processes share an FD?
- What happens after
fork()? - What is
dup()? - What is
dup2()? - What is
dup3()? - What is FD inheritance?
17. VFS – Virtual File System
Very important for Linux internals.
- What is VFS?
- Why does Linux need VFS?
- What is a filesystem?
- What is an inode?
- What is a dentry?
- What is
struct file? - What is
super_block? - Explain:
Process
↓
System Call
↓
VFS
↓
Filesystem
↓
Block Layer
↓
Device Driver
↓
Hardware
- What is inode cache?
- What is dentry cache?
- What is pathname lookup?
- What happens during
open("/home/test.txt")? - What is
namei? - What is mount?
- What is superblock?
- Hard link vs symbolic link.
- What happens when a file is deleted?
- Can a deleted file still be open?
18. Filesystem Internals
- What is ext4?
- What is inode?
- What is directory entry?
- What is block?
- What is filesystem block size?
- What is journaling?
- Why is journaling needed?
- What happens after sudden power failure?
- What is
fsck? - What is mount?
- What is unmount?
- What is
/etc/fstab? - What is root filesystem?
- What is tmpfs?
- What is procfs?
- What is sysfs?
- What is devtmpfs?
- What is debugfs?
- What is overlayfs?
- What is NFS?
19. IPC – Inter-Process Communication
- What is IPC?
- Why is IPC needed?
- What are the IPC mechanisms?
- Pipe
- FIFO
- Message queue
- Shared memory
- Semaphore
- Signal
- Socket
- Pipe vs FIFO.
- Message queue vs shared memory.
- Shared memory vs pipe.
- Which IPC mechanism is fastest?
- Why is shared memory fast?
- How do you synchronize shared memory?
20. Pipes
- What is a pipe?
- How does
pipe()work? - Anonymous pipe vs named pipe.
- What is FIFO?
- What happens if pipe buffer is full?
- What happens if no reader exists?
- Is pipe unidirectional?
- How is pipe implemented inside kernel?
21. Signals
- What is a signal?
- Why are signals used?
- What is
SIGINT? SIGTERMvsSIGKILL.SIGSTOPvsSIGCONT.- What is
SIGSEGV? - What is
SIGCHLD? - What happens when a signal is generated?
- What is signal handler?
- Can you catch
SIGKILL? - Can you catch
SIGSTOP? - Signal vs interrupt.
- What is signal masking?
- What is pending signal?
- What is blocked signal?
- What is
sigaction()? - Why is
sigaction()preferred over oldsignal()?
22. Shared Memory
- What is shared memory?
- Why is shared memory fast?
- What is
mmap()? - What is POSIX shared memory?
- What is System V shared memory?
- Shared memory synchronization.
- Can multiple processes write simultaneously?
- What happens without synchronization?
- Shared memory vs message queue.
23. Synchronization
- What is synchronization?
- What is race condition?
- What is critical section?
- What is mutex?
- What is semaphore?
- What is spinlock?
- Mutex vs semaphore.
- Mutex vs spinlock.
- What is read-write lock?
- What is RCU?
- What is atomic operation?
- What is
atomic_t? - What is memory barrier?
- What is deadlock?
- What is livelock?
- What is starvation?
- What is priority inversion?
- How do you avoid deadlocks?
- What is lock ordering?
- Can a mutex be used in interrupt context?
- Can a spinlock be used in process context?
- Can you sleep while holding a spinlock?
24. RCU
For advanced interviews:
- What is RCU?
- Why was RCU introduced?
- Read-copy-update concept.
- Why is RCU useful for read-heavy workloads?
- What is an RCU read-side critical section?
- What is
rcu_read_lock()? - What is
rcu_read_unlock()? - What is
synchronize_rcu()? - RCU vs mutex.
- RCU vs spinlock.
25. Deadlock
- What is deadlock?
- Four conditions for deadlock.
- Mutual exclusion.
- Hold and wait.
- No preemption.
- Circular wait.
- How do you prevent deadlock?
- How do you debug deadlock?
- What is lockdep?
- Give an example of kernel deadlock.
26. Interrupts
- What is an interrupt?
- Hardware vs software interrupt.
- What is IRQ?
- What is ISR?
- Interrupt context.
- What happens when an interrupt occurs?
- What is interrupt controller?
- What is IRQ number?
- Shared IRQ.
- Edge-triggered vs level-triggered.
- What is interrupt affinity?
- What is interrupt storm?
- What is interrupt latency?
- What is top half?
- What is bottom half?
- What is threaded IRQ?
- What is tasklet?
- What is workqueue?
- Why can’t ISR sleep?
- What is
request_irq()? - What is
free_irq()?
27. Kernel Timers
- What is kernel timer?
- Why use kernel timers?
- What is timer callback?
- Can timer callback sleep?
- Timer vs workqueue.
- Timer vs delayed work.
- What happens if timer callback takes too long?
- How do you create a kernel timer?
28. Workqueues
- What is workqueue?
- Why defer work?
- What is
work_struct? - What is
schedule_work()? - Can workqueue sleep?
- Workqueue vs tasklet.
- Workqueue vs kernel thread.
- What is ordered workqueue?
- What is dedicated workqueue?
29. Kernel Threads
- What is a kernel thread?
- How is it different from a user thread?
- What is
kthread_run()? - What is
kthread_stop()? - Can kernel threads sleep?
- How does a kernel thread terminate?
- Why would a driver use a kernel thread?
30. Networking Internals
For Embedded Linux, prepare the basics.
- Explain Linux networking architecture.
- What happens when you run:
ping 8.8.8.8
- What happens when an Ethernet frame arrives?
- What is NIC?
- What is network driver?
- What is
net_device? - What is socket?
- What is socket buffer (
sk_buff)? - What is TCP/IP stack?
- What is ARP?
- What is routing?
- What is IP address?
- MAC address vs IP address.
- TCP vs UDP.
- What is port?
- What is network namespace?
- What is NAPI?
- Why is NAPI required?
- Interrupt-driven RX vs polling.
- What is checksum offload?
- What is TSO?
- What is GRO?
- What is RSS?
- What is DMA in network drivers?
31. Socket Internals
- What is a socket?
- What happens during
socket()? - What happens during
bind()? - What happens during
listen()? - What happens during
accept()? - What happens during
connect()? - What happens during
send()? - What happens during
recv()? - What is socket buffer?
- Blocking vs non-blocking socket.
- What is
select()? - What is
poll()? - What is
epoll()? - Why is
epoll()efficient? - Level-triggered vs edge-triggered.
32. DMA
- What is DMA?
- Why use DMA?
- CPU copy vs DMA.
- What is DMA buffer?
- What is DMA mapping?
- What is DMA coherent memory?
- What is cache coherency?
dma_map_single().dma_unmap_single().dma_alloc_coherent().- Streaming DMA vs coherent DMA.
- What is DMA mask?
- What is IOMMU?
- CPU cache vs DMA.
- What happens if cache isn’t synchronized?
33. Device Model
- What is Linux device model?
- What is a device?
- What is a driver?
- What is a bus?
- What is a class?
- What is kobject?
- What is sysfs?
- What is device binding?
- What is driver binding?
- Explain:
Bus
├── Device
└── Driver
- What is
struct device? - What is reference counting?
- What is
kref? - What is hotplug?
- What is uevent?
- What is udev?
34. Device Tree
- What is Device Tree?
- Why do we need Device Tree?
- DTS vs DTSI.
- DTS vs DTB.
- What is DTBO?
- What is a node?
- What is a property?
- What is
compatible? - What is
reg? - What is
interrupts? - What is
clocks? - What is
gpios? - What is
status? - What is phandle?
- What is Device Tree overlay?
- How does Device Tree bind to a driver?
- What is
of_match_table? - What is
of_device_id? - What is
probe()? - How does the kernel discover hardware from Device Tree?
35. Kernel Modules
- What is kernel module?
- Why use modules?
- Built-in vs module.
- What is
.ko? - What is
insmod? - What is
modprobe? - What is
rmmod? - What is
lsmod? - What is
modinfo? - What is module dependency?
- What is symbol export?
- What is
EXPORT_SYMBOL()? - What is
EXPORT_SYMBOL_GPL()? - What happens during module loading?
- What happens during unloading?
- Why can a module fail to unload?
- What is module reference count?
36. Sysfs / Procfs / Debugfs
- What is sysfs?
- What is procfs?
- What is debugfs?
- Difference between them.
- What information is exposed through
/proc? - What information is exposed through
/sys? - Why shouldn’t debugfs be used as a stable application interface?
- How does a driver create a sysfs attribute?
- What are
show()andstore()? - What is
DEVICE_ATTR()?
37. Kernel Synchronization Context
Interviewers love scenario questions:
Q: Can you sleep here?
Prepare answers for:
| Context | Can Sleep? |
|---|---|
| User process | Yes |
| Kernel process context | Yes |
| Kernel thread | Yes |
| Interrupt handler | No |
| Timer callback | No |
| Spinlock-held context | No |
| Atomic context | No |
Then expect:
Why?
What API can you use instead?
Which GFP flag should you use?
38. ELF & Program Loading
- What is ELF?
- What is an ELF executable?
- What is an ELF header?
- What is a program header?
- What is a section header?
- What is
.text? - What is
.data? - What is
.bss? - What is symbol table?
- What is relocation?
- What is dynamic linking?
- What is static linking?
- Static vs dynamic linking.
- What is a shared library?
- What is
.so? - What is the dynamic linker?
- What is
ld.so? - What happens when you execute an ELF binary?
- What is ASLR?
- What is PIE?
39. Dynamic Linking
- Static vs dynamic library.
- What is
.so? - What is
LD_LIBRARY_PATH? - What is
ldconfig? - What is dynamic linker?
- What is symbol resolution?
- What is PLT?
- What is GOT?
- What is lazy binding?
- What is
LD_PRELOAD?
40. IPC + Synchronization Scenarios
Prepare scenarios like:
Two processes access the same shared buffer. How will you synchronize?
Producer produces data faster than consumer. What happens?
Consumer waits until data arrives. What IPC/synchronization mechanism would you use?
Multiple threads update the same variable. What can go wrong?
An interrupt updates a buffer while a process reads it. How will you protect it?
41. Blocking & Non-Blocking I/O
- What is blocking I/O?
- What is non-blocking I/O?
- What is
O_NONBLOCK? - What happens when
read()has no data? - What is
EAGAIN? - What is
EWOULDBLOCK? - How does
poll()work? - How does
select()work? - How does
epoll()work? - Blocking vs polling.
- Blocking read vs interrupt-driven design.
42. select() / poll() / epoll()
- Why do we need I/O multiplexing?
- What is
select()? - What is
poll()? - What is
epoll()? select()vspoll().poll()vsepoll().- Why is
epoll()more scalable? - Level-triggered vs edge-triggered.
- What is
EPOLLIN? - What is
EPOLLOUT? - What is
EPOLLERR? - How does a device driver implement
poll()?
43. Signals vs Interrupts
Very common conceptual question.
| Interrupt | Signal |
|---|---|
| Hardware/kernel event | Process notification |
| Usually handled by kernel/ISR | Delivered to process |
| CPU/hardware related | Process related |
| Example GPIO interrupt | SIGTERM |
Questions:
- Difference between interrupt and signal.
- Can a process generate a signal?
- Can kernel generate a signal?
- What is hardware interrupt?
- What is software interrupt?
44. Time Management
- What is system clock?
- What is clock tick?
- What is jiffies?
- What is
HZ? - What is monotonic clock?
- What is realtime clock?
- Difference between
CLOCK_REALTIMEandCLOCK_MONOTONIC. - What is high-resolution timer?
- What is timer interrupt?
- What is
nanosleep()? - What is
clock_nanosleep()? - Why is
CLOCK_MONOTONICpreferred for measuring elapsed time?
45. SMP / Multicore Linux
- What is SMP?
- What is multicore?
- How does Linux handle multiple CPUs?
- What is CPU affinity?
- What is per-CPU data?
- Why use per-CPU variables?
- What is cache coherence?
- What is cache line?
- What is false sharing?
- What is CPU migration?
- What is load balancing?
- What is NUMA?
- What is memory barrier?
- Why are locks more important on SMP?
46. Cache & Memory Ordering
For senior Embedded Linux roles:
- What is CPU cache?
- L1/L2/L3 cache.
- What is cache line?
- What is cache coherence?
- What is memory ordering?
- What is memory barrier?
- Why is compiler reordering different from CPU reordering?
- What is
READ_ONCE()? - What is
WRITE_ONCE()? - What is
smp_mb()? - What is
smp_rmb()? - What is
smp_wmb()? - How can missing barriers cause race conditions?
- What is false sharing?
47. OOM – Out Of Memory
- What happens when Linux runs out of memory?
- What is OOM?
- What is OOM Killer?
- Why does Linux kill a process?
- How does Linux select a process?
- What is
oom_score? - What is
oom_score_adj? - How do you debug OOM?
- What is swap?
- Why might an embedded system disable swap?
48. Swap
- What is swap?
- Why is swap used?
- What is swap partition?
- What is swap file?
- What happens during swapping?
- What is swap-in?
- What is swap-out?
- What is thrashing?
- Why is swap usually avoided in some embedded systems?
49. Kernel Panic / Oops
- What is kernel panic?
- What is kernel Oops?
- Oops vs panic.
- What is NULL pointer dereference?
- What is use-after-free?
- What is stack overflow?
- What is kernel BUG?
- How do you debug a kernel crash?
- What is call trace?
- What is
dmesg? - What is
addr2line? - What is
vmlinux? - Why is debug information important?
- What is
CONFIG_DEBUG_INFO?
50. Linux Debugging
- How do you debug a Linux application?
- How do you debug a kernel?
- What is
gdb? - What is
strace? - What is
ltrace? - What is
dmesg? - What is
ftrace? - What is
perf? - What is
top? - What is
htop? - What is
vmstat? - What is
iostat? - What is
sar? - What is
free? - What is
/proc/meminfo? - What is
/proc/cpuinfo? - What is
/proc/interrupts? - What is
/proc/<pid>/maps? - What is
/proc/<pid>/status? - What is
/proc/<pid>/fd/?
51. Performance Debugging
- CPU usage is 100%. How do you debug?
- System is slow. What do you check?
- Memory usage is increasing continuously. What do you check?
- Process is blocked. How do you debug?
- High interrupt usage — what could cause it?
- High context switches — what could cause it?
- High CPU but low application workload — why?
- High I/O wait — what does it mean?
- What is
perf? - What is profiling?
- What is flame graph?
- What is tracing?
- Profiling vs tracing.
52. Kernel Tracing
- What is ftrace?
- What is tracepoint?
- What is kprobe?
- What is kretprobe?
- What is eBPF?
- What is perf?
- What is function tracing?
- What is event tracing?
- How can you trace system calls?
- How can you trace scheduler events?
53. eBPF
For modern Linux interviews:
- What is eBPF?
- Why is eBPF useful?
- What can eBPF observe?
- eBPF vs kernel module.
- What is a BPF program?
- What is BPF map?
- What is verifier?
- How can eBPF help debugging?
- What is
bpftrace? - What is
bpftool?
54. Namespaces
- What are Linux namespaces?
- Why are namespaces used?
- What is PID namespace?
- Network namespace?
- Mount namespace?
- IPC namespace?
- UTS namespace?
- User namespace?
- Cgroup namespace?
- How do namespaces help containers?
55. Cgroups
- What are cgroups?
- Why are cgroups used?
- CPU cgroup.
- Memory cgroup.
- I/O cgroup.
- What is resource limiting?
- What is resource accounting?
- Namespace vs cgroup.
- How do containers use namespaces and cgroups?
56. Containers / Docker Internals
- What is a container?
- Container vs virtual machine.
- How does Linux support containers?
- Namespaces.
- Cgroups.
- Overlay filesystem.
- Capabilities.
- What is container isolation?
- What is PID namespace?
- What happens when a container starts?
57. Linux Security Internals
- What is permission?
- What is UID?
- What is GID?
- Real UID vs effective UID.
- What is
setuid? - What are Linux capabilities?
- What is
CAP_NET_ADMIN? - What is
CAP_SYS_ADMIN? - What is DAC?
- What is MAC?
- What is SELinux?
- What is AppArmor?
- What is seccomp?
- What is ASLR?
- What is NX/DEP?
58. Kernel Synchronization + Interrupt Scenario Questions
Be ready for questions like:
Q1
ISR updates a variable and user thread reads it. What problem can occur?
Q2
Can you use mutex inside ISR?
Q3
Why use spinlock in interrupt context?
Q4
What happens if you call
schedule()while holding a spinlock?
Q5
Why use a workqueue after an interrupt?
Q6
What happens if two CPUs access the same variable simultaneously?
Q7
How do memory barriers solve ordering problems?
59. Linux Power Management
Important for embedded systems.
- What is suspend?
- What is resume?
- What is system sleep?
- What is runtime PM?
- What is runtime suspend?
- What is runtime resume?
- What is wakeup source?
- What is autosuspend?
- What is CPU idle?
- What is CPU frequency scaling?
- What is
cpufreq? - What is
cpuidle? - How does a driver participate in suspend/resume?
60. Embedded Linux Internals
For your target profile, definitely prepare:
- Bootloader → kernel flow.
- Kernel → Device Tree.
- Device Tree → driver.
- Driver → hardware.
- Interrupt → driver.
- DMA → memory.
- User application → driver.
- Driver → sysfs.
- Driver →
/dev. - ALSA architecture.
- Linux audio pipeline.
- I2C/SPI/GPIO.
- Kernel configuration.
- Cross compilation.
- Root filesystem.
- Init/systemd.
- Yocto integration.
- Kernel module integration.
- Debugging boot failures.
- Debugging driver probe failures.
61. ALSA / Audio Internals
Since Automotive Linux/audio roles can ask this:
- What is ALSA?
- ALSA architecture.
- What is ALSA kernel layer?
- What is ALSA userspace library?
- What is PCM?
- What is PCM device?
- What is PCM playback?
- What is PCM capture?
- What is PCM buffer?
- What is period?
- What is period size?
- What is buffer size?
- What is sample rate?
- What is bit depth?
- What is channel count?
- What is ALSA driver?
- What is ASoC?
- What is codec driver?
- What is CPU DAI?
- What is codec DAI?
- What is DAPM?
- What is machine driver?
- What is audio routing?
- How does an ALSA application reach hardware?
62. Linux Audio Stack
Know this flow:
Application
↓
ALSA / PulseAudio / PipeWire
↓
ALSA Kernel
↓
ASoC
↓
Machine Driver
↓
CPU DAI
↓
Codec / DSP
↓
I2S / TDM
↓
Audio Hardware
Possible questions:
Explain Linux audio architecture.
What happens when an application plays audio?
ALSA vs PulseAudio?
What is ASoC?
What is DAI?
What is PCM?
63. Driver + Linux Internals Scenario Questions
These are extremely important for experienced interviews.
Scenario 1
Application calls
read(). Explain everything that happens internally.
Expected chain:
Application
↓
libc
↓
system call
↓
Kernel
↓
VFS
↓
file_operations
↓
Driver read()
↓
Hardware/buffer
↓
copy_to_user()
↓
Application
Scenario 2
Hardware generates an interrupt. Explain what happens.
Hardware
↓
Interrupt Controller
↓
CPU
↓
IRQ Entry
↓
ISR
↓
Schedule Deferred Work
↓
Driver
↓
Wake Waiting Process
↓
Application
Scenario 3
Application writes to
/dev/mydevice.
Explain:
open()
↓
VFS
↓
driver open()
write()
↓
VFS
↓
driver write()
↓
copy_from_user()
↓
hardware
Scenario 4
Driver’s
probe()isn’t getting called.
Check:
Device exists?
↓
Correct bus?
↓
Device Tree?
↓
compatible?
↓
Driver registered?
↓
match table?
↓
Kernel configuration?
↓
probe()
Scenario 5
System randomly crashes after several hours.
Think:
Memory leak
↓
Use-after-free
↓
Race condition
↓
Buffer overflow
↓
DMA corruption
↓
Stack overflow
↓
Deadlock
64. Top 50 Linux Internals Questions
If you have limited interview preparation time, master these first:
- Linux architecture.
- Kernel space vs user space.
- Linux boot process.
start_kernel().- Process vs program.
task_struct.fork().exec().clone().wait().- Zombie vs orphan.
- Threads vs processes.
- Context switching.
- Scheduler.
- CFS.
- Real-time scheduling.
- System calls.
- User → kernel transition.
- Virtual memory.
- Page tables.
- MMU.
- TLB.
- Page fault.
- Copy-on-write.
mmap().malloc()internals.- Kernel memory allocation.
- Buddy allocator.
- SLAB/SLUB.
- Page cache.
- File descriptors.
- VFS.
- inode.
- dentry.
- superblock.
open()internals.- IPC.
- Signals.
- Shared memory.
- Mutex vs spinlock.
- Deadlock.
- Interrupt handling.
- Top half/bottom half.
- Workqueue.
- Device Tree.
- Device model.
- DMA.
- Kernel debugging.
- Kernel panic/Oops.
- Linux networking internals.
65.What Interviewers Usually Do
For an experienced Embedded Linux candidate, don’t expect only:
“What is a mutex?”
They may ask:
“Suppose an ISR receives data into a ring buffer and a userspace application reads that data. Explain the complete design.”
You should be able to discuss:
Hardware
↓
DMA
↓
Ring Buffer
↓
Interrupt
↓
ISR / Threaded IRQ
↓
Synchronization
↓
Wait Queue
↓
Driver read()
↓
copy_to_user()
↓
Application
Then they may go deeper:
Why DMA?
Why ring buffer?
Why spinlock?
Can ISR sleep?
Why wait queue?
What happens if buffer is full?
What happens if application is slow?
How do you prevent race conditions?
How do you handle cache coherency?
How would you debug data corruption?
That’s the level you should prepare for.
Best preparation sequence
For your Embedded Linux / Automotive Audio background, I’d study Linux internals in this order:
1. Linux Architecture
↓
2. Boot Process
↓
3. Processes & Threads
↓
4. Scheduling
↓
5. System Calls
↓
6. Virtual Memory
↓
7. Memory Management
↓
8. VFS & File Systems
↓
9. File Descriptors
↓
10. IPC
↓
11. Signals
↓
12. Synchronization
↓
13. Interrupts
↓
14. Workqueues / Kernel Threads
↓
15. Device Model
↓
16. Device Tree
↓
17. Drivers
↓
18. DMA
↓
19. Networking
↓
20. Power Management
↓
21. Kernel Debugging
↓
22. Performance / Tracing
↓
23. ALSA / ASoC
↓
24. Yocto + Kernel
↓
25. Real-world Scenarios
Linux Kernel Programming – Complete Interview Question Bank
1. Linux Kernel Programming Basics
- What is Linux kernel programming?
- How is kernel programming different from normal C programming?
- What is kernel space?
- What is user space?
- Why can’t kernel code use normal user-space APIs?
- Can kernel code use
printf()? - What is
printk()? - What are
pr_info(),pr_err(),pr_warn(), andpr_debug()? - What is a kernel module?
- What is an LKM?
- Why are kernel modules used?
- Built-in code vs loadable module.
- What is a
.kofile? - What happens when a
.kofile is loaded? - What happens when a module is unloaded?
- What is
insmod? - What is
rmmod? - What is
modprobe? - Difference between
insmodandmodprobe. - What is
lsmod? - What is
modinfo? - What is module dependency?
- What is module reference counting?
- Why can a module fail to unload?
2. Kernel Module Programming
Questions
- What is
module_init()? - What is
module_exit()? - What happens inside module initialization?
- What happens inside module cleanup?
- Can a kernel module have multiple
module_init()functions? - What is
MODULE_LICENSE()? - Why is module licensing important?
- What is
MODULE_AUTHOR()? - What is
MODULE_DESCRIPTION()? - What is
MODULE_VERSION()? - What is
MODULE_DEVICE_TABLE()? - What is
EXPORT_SYMBOL()? - What is
EXPORT_SYMBOL_GPL()? - Difference between them.
- What is a kernel symbol?
- What is symbol resolution?
- What causes an “Unknown symbol” error?
- What happens if a module depends on another module?
- How does the kernel resolve module dependencies?
- What is
modprobedoing internally?
Basic structure
#include <linux/module.h>
#include <linux/kernel.h>
static int __init my_init(void)
{
pr_info("Driver loaded\n");
return 0;
}
static void __exit my_exit(void)
{
pr_info("Driver unloaded\n");
}
module_init(my_init);
module_exit(my_exit);
MODULE_LICENSE("GPL");
Interviewers may ask you to write this from memory.
3. Kernel Build System
- How do you compile a kernel module?
- What is a kernel Makefile?
- What is Kbuild?
- What is Kconfig?
- What is
.config? - What is
CONFIG_xxx? - Difference between:
CONFIG_xxx=y
CONFIG_xxx=m
CONFIG_xxx=n
- What does
obj-mmean? - What does
obj-ymean? - How do you build an external module?
- What is
KDIR? - What is
ARCH? - What is
CROSS_COMPILE? - Why must a module be built against the correct kernel?
- What is
vermagic? - What happens if kernel and module versions don’t match?
- What are kernel headers?
- Difference between userspace headers and kernel headers.
- How do you cross-compile a kernel module?
- How do you add a driver to the Linux kernel source tree?
4. Kernel Data Types
- What is
u8? - What is
u16? - What is
u32? - What is
u64? - What is
s32? - What is
size_t? - What is
ssize_t? - What is
phys_addr_t? - What is
dma_addr_t? - What is
dev_t? - What is
pid_t? - What is
atomic_t? - Why does kernel code use its own data types?
- Why should you avoid assuming
intis always a particular size?
5. Kernel Memory Programming
This is one of the highest-priority areas.
Allocation
- What is
kmalloc()? - What is
kzalloc()? - What is
kcalloc()? - What is
krealloc()? - What is
kfree()? - What is
vmalloc()? - What is
vzalloc()? - What is
vfree()? kmalloc()vsvmalloc().- What does “physically contiguous” mean?
- What does “virtually contiguous” mean?
- Why is
kmalloc()physically contiguous? - Why is
vmalloc()only virtually contiguous? - Which is faster:
kmalloc()orvmalloc()? - When would you use each?
GFP flags
- What is GFP?
- What is
GFP_KERNEL? - What is
GFP_ATOMIC? - What is
GFP_NOWAIT? - Why can’t
GFP_KERNELbe used in interrupt context? - Why is
GFP_ATOMICneeded? - What does it mean for an allocation to sleep?
Advanced
- What is the buddy allocator?
- What is SLAB?
- What is SLUB?
- Why does the kernel use slab allocation?
- What is a slab cache?
- What is
kmem_cache_create()? - What is
kmem_cache_alloc()? - What is
kmem_cache_free()? - What is memory fragmentation?
- What is a memory leak?
- What is use-after-free?
- What is double-free?
- How do you detect kernel memory leaks?
6. copy_to_user() / copy_from_user()
- Why can’t you directly access user memory from kernel code?
- What is
copy_to_user()? - What is
copy_from_user()? - Difference between
memcpy()andcopy_to_user(). - What does
copy_to_user()return? - What does
copy_from_user()return? - What happens if the user passes an invalid pointer?
- What is
access_ok()? - Why is validating user input important?
- Can
copy_to_user()sleep? - Can you call it from interrupt context?
7. Kernel Pointers
- What is a kernel virtual address?
- What is a physical address?
- What is a user virtual address?
- What is
virt_to_phys()? - What is
phys_to_virt()? - What is
ioremap()? - Why is
ioremap()required? - What is
__iomem? - What is
IS_ERR()? - What is
PTR_ERR()? - What is
ERR_PTR()? - NULL pointer vs ERR_PTR.
- Why are kernel error pointers used?
8. Character Driver Programming
- What is a character driver?
- How do you create a character driver?
- What is
struct cdev? - What is
struct file_operations? - What is
struct inode? - What is
struct file? - Difference between
inodeandfile. - What is
dev_t? - What is major number?
- What is minor number?
- What is
alloc_chrdev_region()? - What is
register_chrdev_region()? - Difference between them.
- What is
cdev_init()? - What is
cdev_add()? - What is
cdev_del()? - What is
class_create()? - What is
device_create()? - Who creates
/dev/mydevice? - What is udev?
- What is devtmpfs?
- How does
/dev/mydeviceconnect to your driver? - How does
open()reach the driver? - How does
read()reach the driver? - How does
write()reach the driver? - How does
close()reach the driver?
Flow
Application
↓
open("/dev/mydevice")
↓
VFS
↓
file_operations
↓
driver->open()
9. file_operations
Prepare every callback:
- What is
.open? - What is
.release? - What is
.read? - What is
.write? - What is
.unlocked_ioctl? - What is
.compat_ioctl? - What is
.mmap? - What is
.poll? - What is
.llseek? - What is
.fasync? - What is
.fsync? - What is
.read_iter? - What is
.write_iter? - What is
private_data? - How do you store per-device data in
private_data?
10. ioctl
- What is ioctl?
- Why use ioctl?
- When should you use ioctl instead of read/write?
- What is
_IO()? - What is
_IOR()? - What is
_IOW()? - What is
_IOWR()? - What is an ioctl command number?
- How is data passed between userspace and kernel?
- Why should ioctl arguments be validated?
- How do you pass a structure through ioctl?
- What security problems can ioctl create?
- What is 32-bit/64-bit compatibility in ioctl?
- What is
.compat_ioctl?
11. Blocking & Non-Blocking I/O
- What is blocking I/O?
- What is non-blocking I/O?
- What is
O_NONBLOCK? - What happens when
read()has no data? - What is
EAGAIN? - What is
EWOULDBLOCK? - How do you implement blocking read in a driver?
- How do you implement non-blocking read?
- What is a wait queue?
- Why do drivers put processes to sleep?
- How does the driver wake the process?
12. Wait Queues
- What is a wait queue?
- Why are wait queues required?
- What is
wait_event()? - What is
wait_event_interruptible()? - What is
wait_event_timeout()? - What is
wake_up()? - What is
wake_up_interruptible()? - What is the wait condition?
- Why must the condition be checked again after waking?
- What is a spurious wakeup?
- How would you implement a blocking
read()using a wait queue?
Typical design
Application
↓
read()
↓
Data unavailable
↓
wait_event()
↓
Process sleeps
↓
Hardware interrupt
↓
Data arrives
↓
wake_up()
↓
read() continues
13. Poll / Select / Epoll
- Why does a driver implement
poll()? - What is
poll_wait()? - How does
select()work? - How does
poll()work? - How does
epoll()work? select()vspoll().poll()vsepoll().- Level-triggered vs edge-triggered.
- What is
POLLIN? - What is
POLLOUT? - What is
POLLERR? - How does a driver notify userspace that data is available?
14. Interrupt Programming
- What is an interrupt?
- What is IRQ?
- What is ISR?
- What is interrupt context?
- What is
request_irq()? - What is
free_irq()? - What is
irqreturn_t? - What is
IRQ_HANDLED? - What is
IRQ_NONE? - What is shared IRQ?
- What is
IRQF_SHARED? - Edge vs level triggered interrupt.
- What is interrupt affinity?
- What is interrupt latency?
- Why can’t an ISR sleep?
- Can you call
kmalloc(GFP_KERNEL)from ISR? - Can you acquire a mutex inside ISR?
- Can you use a spinlock inside ISR?
- What is threaded IRQ?
- What is
request_threaded_irq()?
15. Top Half / Bottom Half
- What is top half?
- What is bottom half?
- Why do we defer interrupt work?
- What is tasklet?
- What is workqueue?
- What is threaded interrupt?
- Tasklet vs workqueue.
- Workqueue vs threaded IRQ.
- Which can sleep?
- Which runs in interrupt context?
- When would you choose each mechanism?
Simple idea
Hardware Interrupt
↓
Top Half
↓
Quick processing
↓
Bottom Half
↓
Longer processing
16. Spinlocks
- What is spinlock?
- Why do we need spinlocks?
- What is
spin_lock()? - What is
spin_unlock()? - What is
spin_lock_irqsave()? - What is
spin_unlock_irqrestore()? - Why disable interrupts while taking some spinlocks?
- Can a spinlock holder sleep?
- What happens if it does?
- Spinlock vs mutex.
- Spinlock vs semaphore.
- What is spinlock contention?
- What is recursive spinlock acquisition?
- What is deadlock with spinlocks?
17. Mutex
- What is a mutex?
- Why use mutex?
mutex_lock().mutex_unlock().- Can mutex sleep?
- Can mutex be used in interrupt context?
- Mutex vs spinlock.
- Mutex vs semaphore.
- Recursive mutex?
- What happens if a process dies while holding a mutex?
- What is priority inversion?
18. Semaphores
- What is semaphore?
- Binary semaphore vs counting semaphore.
- Semaphore vs mutex.
- What is
down()? - What is
up()? - Can semaphore sleep?
- Can semaphore be used in interrupt context?
- When would you choose semaphore?
19. Atomic Operations
- What is an atomic operation?
- Why do we need atomic operations?
- What is
atomic_t? - What is
atomic_read()? - What is
atomic_set()? - What is
atomic_inc()? - What is
atomic_dec()? - What is
atomic_add()? - Atomic variable vs mutex.
- When should you use atomic operations?
20. Memory Barriers
- What is memory ordering?
- What is a memory barrier?
- Why are memory barriers required on SMP?
- What is compiler reordering?
- What is CPU reordering?
- What is
mb()? - What is
rmb()? - What is
wmb()? - What is
smp_mb()? - What is
READ_ONCE()? - What is
WRITE_ONCE()? - Give a real race condition where a memory barrier is needed.
21. Kernel Linked Lists
- Why does Linux use linked lists?
- What is
struct list_head? - What is an intrusive linked list?
INIT_LIST_HEAD().list_add().list_add_tail().list_del().list_for_each().list_for_each_entry().- What is
container_of()? - Why is
container_of()important? - How does
container_of()work? - What is
offsetof()?
22. container_of()
A classic interview question.
Suppose:
struct my_device {
int id;
struct list_head list;
};
If you have:
struct list_head *ptr;
how do you obtain:
struct my_device *
Answer:
container_of()
Know exactly how and why it works.
23. Kernel Process Programming
- What is
task_struct? - What information does it contain?
- How do you get the current task?
- What is
current? - What is
current->pid? - What is
current->comm? - What is process context?
- What is kernel context?
- Can kernel code create processes?
- Can kernel code create threads?
- What is
kthread_run()? - What is
kthread_stop()? - How do you stop a kernel thread?
- Can a kernel thread sleep?
- What is
schedule()? - What is
schedule_timeout()?
24. Kernel Threads
- What is a kernel thread?
- User thread vs kernel thread.
- What is
kthread_run()? - What is
kthread_create()? - What is
wake_up_process()? - What is
kthread_should_stop()? - What is
kthread_stop()? - Can a kernel thread call
schedule()? - How do you safely terminate a kernel thread?
- Kernel thread vs workqueue.
25. Timers
- What is a kernel timer?
- Why are kernel timers used?
- What is
struct timer_list? - What is
timer_setup()? - What is
mod_timer()? - What is
del_timer()? - What is timer callback?
- Can a timer callback sleep?
- Timer vs delayed work.
- How do you create a periodic timer?
26. Workqueues
- What is workqueue?
- Why use workqueue?
- What is deferred work?
- What is
struct work_struct? - What is
INIT_WORK()? - What is
schedule_work()? - What is
cancel_work_sync()? - Can workqueue code sleep?
- Workqueue vs tasklet.
- Workqueue vs kernel thread.
- What is delayed work?
- What is
schedule_delayed_work()?
27. Device Tree Programming
- What is Device Tree?
- What is DTS?
- What is DTSI?
- What is DTB?
- What is DTBO?
- What is
compatible? - What is
reg? - What is
interrupts? - What is
clocks? - What is
gpios? - What is
status? - What is a phandle?
- What is
of_match_table? - What is
of_device_id? - How does a driver read a Device Tree property?
- What is
of_property_read_u32()? - What is
of_property_read_string()? - How do you obtain a GPIO?
- How do you obtain an IRQ?
- How does Device Tree trigger
probe()?
Critical flow
DTS
↓
DTB
↓
Kernel parses Device Tree
↓
Device created
↓
Driver registered
↓
compatible matching
↓
probe()
28. Platform Driver Programming
- What is a platform driver?
- Why use platform drivers?
- What is
struct platform_driver? - What is
probe()? - What is
remove()? - When is
probe()called? - How does platform driver matching work?
- What is
platform_get_resource()? - What is
platform_get_irq()? - What is
platform_get_drvdata()? - What is
platform_set_drvdata()? - What is
devm_ioremap_resource()? - What is
devm_kzalloc()? - What is
devm_request_irq()? - What happens if probe fails?
- How do you clean up resources?
29. I2C Kernel Programming
- What is I2C?
- What is an I2C adapter?
- What is an I2C client?
- What is
struct i2c_driver? - What is
struct i2c_client? - What is
struct i2c_adapter? - What is
probe()? - What is
remove()? - What is
i2c_transfer()? - What is
i2c_master_send()? - What is
i2c_master_recv()? - What is SMBus?
- I2C vs SMBus.
- How does an I2C driver match a Device Tree node?
- How do you debug an I2C device that isn’t responding?
30. SPI Kernel Programming
- What is SPI?
- What is SPI master?
- What is SPI device?
- What is
struct spi_driver? - What is
struct spi_device? - What is
struct spi_transfer? - What is
struct spi_message? - What is
spi_sync()? - What is
spi_async()? - What is CPOL?
- What is CPHA?
- What are SPI modes?
- How does SPI driver matching work?
- How is SPI represented in Device Tree?
- I2C vs SPI.
31. GPIO Kernel Programming
- What is GPIO?
- What is GPIO descriptor?
- What is
gpiod_get()? - What is
gpiod_set_value()? - What is
gpiod_get_value()? - GPIO input vs output.
- GPIO vs pinctrl.
- How do you describe GPIO in Device Tree?
- How can a GPIO generate an interrupt?
- Legacy GPIO API vs descriptor-based API.
32. MMIO
- What is memory-mapped I/O?
- What is a hardware register?
- How does CPU access hardware registers?
- What is
ioremap()? - What is
iounmap()? - What is
readb()? - What is
readw()? - What is
readl()? - What is
writeb()? - What is
writew()? - What is
writel()? - Why shouldn’t you use normal pointer access for MMIO?
- What is
__iomem? - What is register masking?
- How do you set/clear a register bit?
33. DMA
- What is DMA?
- Why use DMA?
- CPU transfer vs DMA transfer.
- What is a DMA buffer?
- What is DMA mapping?
- What is
dma_map_single()? - What is
dma_unmap_single()? - What is
dma_alloc_coherent()? - What is coherent DMA?
- What is streaming DMA?
- What is cache coherency?
- What is DMA mask?
- What is
dma_set_mask_and_coherent()? - What is IOMMU?
- What happens if CPU cache isn’t synchronized with DMA?
34. Device Model
- What is Linux device model?
- What is
struct device? - What is a bus?
- What is a driver?
- What is a device?
- What is a class?
- What is kobject?
- What is reference counting?
- What is sysfs?
- What is uevent?
- What is device binding?
- What is driver binding?
- What is hotplug?
- What is udev?
35. Sysfs Programming
- What is sysfs?
- Why is sysfs used?
- How does a driver create a sysfs attribute?
- What is
struct device_attribute? - What is
show()? - What is
store()? - What is
DEVICE_ATTR()? - What is
sysfs_create_group()? - Sysfs vs procfs.
- Sysfs vs debugfs.
36. Debugfs
- What is debugfs?
- Why use debugfs?
- How do you create a debugfs file?
- How do you expose driver debug information?
- Debugfs vs sysfs.
- Should production applications depend on debugfs?
37. Kernel Debugging
- How do you debug a kernel module?
- What is
dmesg? - What is dynamic debug?
- What is ftrace?
- What is tracepoint?
- What is kprobe?
- What is kretprobe?
- What is perf?
- What is KGDB?
- What is KASAN?
- What is KCSAN?
- What is lockdep?
- What is kmemleak?
- What is kernel panic?
- What is Oops?
- Oops vs panic.
- What is a kernel call trace?
- How do you find the source line causing a crash?
- What is
addr2line? - Why do you need
vmlinuxwith debug symbols?
38. Kernel Crash Questions
Prepare these scenarios:
Q1
Kernel crashes with NULL pointer dereference. How do you debug?
Q2
Driver works for 10 minutes and then crashes.
What do you investigate?
Memory corruption
Race condition
Use-after-free
DMA corruption
Stack overflow
Q3
Driver unload causes kernel panic.
Think:
Outstanding references
Running workqueue
Active timer
Interrupt still enabled
Use-after-free
Q4
System hangs when driver is unloaded.
Think:
Deadlock
Blocked process
Workqueue not cancelled
Kernel thread not stopped
39. Error Handling
- Why does kernel code return negative error codes?
- What is
-EINVAL? - What is
-ENOMEM? - What is
-EFAULT? - What is
-EBUSY? - What is
-ENODEV? - What is
-EIO? - What is
IS_ERR()? - What is
PTR_ERR()? - What is
ERR_PTR()? - NULL pointer vs error pointer.
- How do you clean resources when
probe()fails halfway?
40. Reference Counting
- What is reference counting?
- Why is reference counting needed?
- What is
kref? - What is
refcount_t? - What happens if reference counting is wrong?
- How can reference counting prevent use-after-free?
- What is a module reference count?
- Why can’t a driver unload while it is still in use?
41. RCU
- What is RCU?
- Why use RCU?
- What is read-copy-update?
- What is
rcu_read_lock()? - What is
rcu_read_unlock()? - What is
synchronize_rcu()? - RCU vs mutex.
- RCU vs spinlock.
- When is RCU useful?
42. Kernel Scheduling APIs
- What is
schedule()? - What is
schedule_timeout()? - What is
cond_resched()? - What is
yield()? - What is task state?
- What is
TASK_RUNNING? - What is
TASK_INTERRUPTIBLE? - What is
TASK_UNINTERRUPTIBLE? - Why shouldn’t you normally use
TASK_UNINTERRUPTIBLEunnecessarily?
43. Kernel Preemption
- What is preemption?
- What is kernel preemption?
- What is voluntary preemption?
- What is preemptive kernel?
- What is
preempt_disable()? - What is
preempt_enable()? - What is preemption count?
- Why can’t certain kernel contexts be preempted?
- How does PREEMPT_RT change kernel behavior?
44. Per-CPU Variables
- What is per-CPU data?
- Why use per-CPU variables?
- What problem do they solve?
- What is
DEFINE_PER_CPU()? - What is
alloc_percpu()? - How does per-CPU data improve performance?
- How does it reduce locking?
45. Kernel Stack
- What is a kernel stack?
- User stack vs kernel stack.
- Does each thread have its own kernel stack?
- How large is a kernel stack?
- Why must kernel stack usage be limited?
- What causes kernel stack overflow?
- Why should large local arrays be avoided in kernel code?
- What happens during user → kernel transition to the stack?
46. Kernel Concurrency Scenarios
Be able to answer:
Scenario
One CPU is executing your driver while an interrupt occurs and accesses the same data.
What do you use?
Possible answer: appropriate locking such as a spinlock, depending on context.
Scenario
Two processes call your driver’s
write()simultaneously.
What do you do?
Answer: identify shared state and protect it with appropriate synchronization.
Scenario
ISR modifies a buffer while userspace reads it.
Think:
Interrupt context
↕
Synchronization
↕
Process context
47. User ↔ Kernel Communication
Know every major mechanism:
read()
write()
ioctl()
mmap()
poll()
sysfs
procfs
netlink
Questions:
- How does userspace communicate with kernel?
- When would you use
read/write? - When would you use ioctl?
- When would you use mmap?
- When would you use sysfs?
- What is netlink?
- What is procfs?
- Which mechanism is appropriate for configuration vs bulk data?
48. mmap Programming
- What is
mmap()? - Why map kernel memory into userspace?
- How does a driver’s
.mmapcallback work? - What is zero-copy?
- Why is mmap useful for high-bandwidth data?
- What are mmap security concerns?
- How can DMA buffers be exposed to userspace?
49. Kernel Networking Programming
- What is
struct net_device? - What is
sk_buff? - What is NAPI?
- Why is NAPI used?
- What happens when an Ethernet packet arrives?
- How does a network driver receive packets?
- What is RX ring?
- What is TX ring?
- How is DMA used by network drivers?
- What is interrupt coalescing?
50. Power Management
- What is runtime PM?
- What is system suspend?
- What is resume?
- What is
suspend()? - What is
resume()? - What is
pm_runtime_get_sync()? - What is
pm_runtime_put()? - What is autosuspend?
- What is wakeup source?
- How does a driver handle power state transitions?
51. Kernel Time / Timers
- What is
jiffies? - What is
HZ? - What is kernel tick?
- What is high-resolution timer?
- What is monotonic time?
- What is
ktime? - Timer vs sleep.
- Timer callback vs workqueue.
52. Kernel Lists / Queues
- Linked list.
- Hash list.
- Circular buffer.
- Ring buffer.
- FIFO.
- What is
kfifo? - Why use
kfifo? - How do you implement producer-consumer?
- How do you synchronize a ring buffer?
53. Kernel FIFO
- What is
kfifo? - Why use
kfifo? kfifo_in().kfifo_out().- How do you allocate a FIFO?
- Is
kfifoautomatically thread-safe? - How would you synchronize producer and consumer?
54. Kernel APIs — Must Know
You should recognize and explain these:
kmalloc()
kzalloc()
kfree()
vmalloc()
vfree()
copy_to_user()
copy_from_user()
mutex_lock()
mutex_unlock()
spin_lock()
spin_unlock()
spin_lock_irqsave()
spin_unlock_irqrestore()
wait_event()
wake_up()
schedule()
schedule_timeout()
request_irq()
free_irq()
request_threaded_irq()
alloc_chrdev_region()
unregister_chrdev_region()
cdev_init()
cdev_add()
cdev_del()
class_create()
device_create()
device_destroy()
ioremap()
iounmap()
readl()
writel()
devm_kzalloc()
devm_request_irq()
devm_ioremap_resource()
kthread_run()
kthread_stop()
schedule_work()
cancel_work_sync()
dma_alloc_coherent()
dma_map_single()
dma_unmap_single()
container_of()
list_add()
list_del()
list_for_each_entry()
55. Kernel Coding Questions
Interviewers may give you code and ask:
Example 1
char *buf;
buf = kmalloc(100, GFP_KERNEL);
Questions:
- What does this do?
- What if allocation fails?
- How do you free it?
- Can this be called from ISR?
Example 2
spin_lock(&lock);
foo++;
spin_unlock(&lock);
Questions:
- Why use spinlock?
- Can
foo++be interrupted? - Can this code sleep?
- What happens on SMP?
Example 3
if (copy_from_user(buf, user_buf, count))
return -EFAULT;
Questions:
- Why use
copy_from_user()? - What does its return value mean?
- Why return
-EFAULT?
56. Kernel Programming Scenario Questions
These are very important for actual interviews.
1. Your driver hangs the system.
How do you debug it?
2. Your probe() isn’t called.
What do you check?
3. /dev/mydevice isn’t created.
What do you check?
4. Interrupt isn’t coming.
What do you check?
5. I2C device isn’t detected.
What do you check?
6. Driver crashes during rmmod.
What do you check?
7. read() blocks forever.
What could be wrong?
8. CPU usage becomes 100%.
Could your driver be causing it?
9. DMA data is corrupted.
What could be wrong?
10. Driver works on one board but not another.
What would you investigate?
11. Race condition occurs only occasionally.
How would you debug it?
12. Kernel memory usage keeps increasing.
What do you investigate?
13. System crashes after suspend/resume.
What do you investigate?
14. Driver works initially but fails after repeated open/close.
What could be wrong?
15. Hardware generates interrupts continuously.
What could cause an interrupt storm?
57. Most Important Questions to Master
If you have an interview soon, do these first:
- Kernel vs user space.
- Kernel module lifecycle.
module_init()/module_exit().- Kernel Makefile.
kmalloc()/vmalloc().- GFP flags.
copy_to_user()/copy_from_user().- Character driver architecture.
- Major/minor numbers.
cdev.file_operations.open/read/write/ioctl.- Blocking/non-blocking I/O.
- Wait queues.
poll().- Interrupts.
- Top half/bottom half.
- Workqueue.
- Kernel thread.
- Mutex.
- Spinlock.
- Semaphore.
- Atomic operations.
- Memory barriers.
- Race conditions.
- Deadlocks.
container_of().- Linked lists.
- Device Tree.
- Platform driver.
probe()/remove().- MMIO.
ioremap().- I2C driver.
- SPI driver.
- GPIO.
- DMA.
- Sysfs.
- Debugfs.
- Kernel debugging.
- Kernel Oops.
- Kernel panic.
- KASAN.
- Lockdep.
- ftrace.
- Power management.
- mmap.
- VFS basics.
- Kernel scheduling.
- Real-world debugging scenarios.

Leave a Reply