Linux Interview Questions: March 2020
Linux Interview Questions: March 2020
Linux Interview Questions: March 2020
March 2020
Page |1
Memory Management
10. What are the use of L1, L2, and L3 Caches?
11. Difference between GFP_KERNEL and GFP_ATOMIC.
12. Where are page tables stored?
13. How do you test whether there are memory leaks in a Linux application?
14. Which file in Linux gives you information about memory zones?
15. Difference between kmalloc and vmalloc.
16. What does malloc(0) return?
17. What is the maximum memory that can be allocated using vmalloc?
18. What is the maximum memory that can be allocated using kmalloc?
19. What is the difference between VIRT, RES and SHR fields in top command?
20. What is the system call used by malloc and free?
21. What is the maximum memory that I can allocate using malloc?
22. What is cache coherence?
23. Linux intentionally leaves the first few kilobytes (or even megabytes) of each process's
virtual address space unmapped, so that attempts to dereference null pointers generate
an unhandled page fault resulting in an immediate SIGSEGV, killing the process. a) Yes b)
No
24. Virtual memory is divided into ____ a) pages b) bytes c) bits
25. What are the advantages of using virtual memory?
26. ____ is a method of data transfer between main memory to input/output device without
the need of processor.
27. Differences between vmalloc and kmalloc.
28. What is the maximum amount of RAM you can access with 32 bit processor?
Page |2
29. When you call malloc from user space, from where it allocates memory: low mem/high
mem or any other location?
30. Why use volatile memory? Why not always use nonvolatile memory?
31. What does kmalloc(0) return?
Process Management
32. What is the difference between context switch and preemption?
33. On a multiprocessor system, how do you find out which process is running on which
processor?
34. How to change the priority of a process in Linux?
35. How can I find out the Count of number of times a process has been preempted in Linux?
36. What happens internally during context switch in Linux kernel?
37. What is buffer/cache?
38. Difference between orphan and zombie process.
39. What is the use of swapper process in Linux?
40. How to kill the process which is in TASK_UNINTERRUPTIBLE state?
41. What is load average in Linux?
42. What is resident memory in process?
43. What is the use of Procedure-linking table (PLT) while application is starting up?
44. Difference between fork and vfork.
45. What is kernel preemption?
46. What is process kernel stack and process user stack?
47. What is difference between background process and daemon?
48. Which state the process is in when executing the below line and waiting for input?
scanf("%d", &val);
a) TASK_INTERRUPTIBLE b) TASK_UNINTERRUPTIBLE
Interrupts
49. Which hardware is responsible for generating timer interrupts in Linux kernel?
50. How to direct interrupt to a particular cpu in Linux kernel
51. Interrupt handler in Linux kernel run with current interrupt line disabled on all processors.
a)True b) False
52. What is the difference between request_irq and request_threaded_irq?
53. What are the advantages of disabling interrupts?
Page |3
54. What happens when two interrupts arrive at the same time in Linux?
55. Does Linux kernel supports interrupt nesting?
56. APIC vs PIC in x86.
57. Can we use printk inside interrupt handler?
58. What happens when we are in interrupt handler and another interrupt arrives?
59. Can we disable interrupts on all processors in Linux kernel?
60. How Message Signalled Interrupt works?
61. What happens if we call schedule() in interrupt handler?
62. What all actions cannot be performed in interrupt handler?
PCI
63. How do you check how many lanes are being used by pcie card in Linux?
64. Maximum number of PCI devices that can be connected to a host?
65. What are lanes in PCI?
66. How auto detection of PCI devices happen in PCI?
67. What is a PCI bridge?
68. Is PCI serial protocol or parallel protocol. What is the maximum data rate achieved with
PCI?
69. What is the use of Base Address Register in PCI?
70. What is the use of PCI protocol?
Processor
71. Difference between processor and core?
72. What is NUMA?
73. Does microprocessor have internal memory? a) Yes b) No
74. System bus = address bus + data bus + control bus. Yes/No
75. Consider a square matrix of x size, which technique will be faster to perform sum of
elements of the matrix?
A) Traversing row by row and adding elements
B) Traversing column by column and adding elements
76. What is a cache line?
77. What is SMP?
78. Comment the registers you know about any processor and its purpose.
79. What are the factors you consider when selecting a processor for your project?
80. Why do we need PCI, USB and other kind of buses why can't we directly connect
peripherals to the processor?
81. Explain differences between SRAM and DRAM in terms of cost, access time and size.
82. What is difference between motherboard, chipset and processor?
Page |4
Character Drivers
116.What is the maximum major number in case of Character and block device driver?
117. Which one will you use to empty a file?
a) /dev/null b) /dev/zero
118. What are the examples of character devices in Linux?
119. What is the use of file->private_data in a device driver?
Commands
120. How to create 100 files in a single command?
121. Why running ps command without options on shell shows only two entries?
122. ____ command will you use to find list of C files present in a directory.
123. Which Linux commands you run when you get a new embedded hardware?
124. Difference between 'echo 0>file' and 'echo 0 > file'.
125. What is the first tool you use if your c/cpp application is not behaving properly in Linux?
Time Management
126. Will the call to date command read from rtc?
127. gettimeofday and clock_gettime both returns the wall time. Which one will you use in
your application and how do you decide?
Page |6
Files
128. What is the use of O_SYNC flag while opening the file?
129. What is the difference between file and inode?
130. I have closed stdout close(1) Can we reopen it?
Scheduling
131. How is scheduler invoked in Linux kernel?
Signals
132. What are the advantages of sigaction over signal?
Bottom Halves
133. Which context softirq/tasklets/workqueues runs?
134. What are the various bottom halves techniques available in Linux Kernel?
135. Why do we need to divide interrupt handler into top half and bottom half?
136. Differences between softirqs and tasklets.
Kernel Threads
138. irq/ - Threaded interrupt handlers
ksoftirqd/ - Softirq Threads
kworker/ - Workqueue Threads
What more kernel threads you see in ps?
139. How do you identify kernel thread from ps output?
144. What are the different ways to find out the kernel command line parameters?
145. What do you mean by vanilla kernel?
146. Is it possible to boot Linux kernel without initrd/initramfs?
147. Which one will you use for custom driver operations:sysfs or ioctl?
148. Difference between printk and trace_printk.
149. Which kernel parameters you added to kernel command line?
150. When an unallocated pointer is derefrenced, who will check that this is invalid
instruction?
151. What is the difference between initrd and initramfs?
152. What is the use of asmlinkage in Linux kernel?
153. /proc/kallsyms contains both global and exported symbols. How do you identify
exported symbols from output of /proc/kallsyms?
154. We say Linux kernel is monolithic. What does it mean?
155. What is the use of compatible property in nodes of device tree?
156. Will /proc/kallsyms contains the global variables defined in Linux kernel modules?
157. What exactly is kernel headers? Why should we install them for generating kernel
modules?
158. Which time is used in dmesg logs?
159. Explain the role of the variable preempt_count in the Linux kernel.
160. What is the initial value of jiffies on boot?
161. What is jiffies in Linux kernel?
162. Difference between mdelay and msleep in Linux kernel.
163. Can I disable drivers which are configured as builtin from loading?
164. How Linux kernel modules are automatically loaded in any Linux distribution?
System Calls
165. How do you allow only root to run your user application. If normal user is running your
user application, you need to print a message and exit?
166. What are the maximum number of arguments we can have for a system call?
167. Who updates the errno in Linux? a) glibc b) Linux Kernel c) None of these d) Both
168. Can I update the system call table from Linux Kernel module?
169. Does calling gettimeofday() from your user space code perform a mode switch from user
to kernel space?
Sysfs
170. Attributes in sysfs are mapped to a) directories b)files
171. kobjects in sysfs are mapped to a) directory b)files
172. What is the use of /etc/fstab file in Linux?
Page |8