Essential System Calls Interview Questions & Answers:
1. What happens when we do insmod & rmmod in Linux Device Drivers?
insmod: insmod is a tool used to attach a module to the
running linux kernel. This will take the kernel object(.ko)
and takes all executable code and data sections of the .ko
and attach it to the running linux kernel.
rmmod: used to remove or deattach a module code from the
running kernel
2. What kind of information the Linux driver modules (.ko ) files has?
kernel 2.6 introduces a new file naming convention: kernel
modules now have a .ko extension (in place of the old .o
extension) which easily distinguishes them from conventional
object files. The reason for this is that they contain an
additional .modinfo section that where additional
information about the module is kept.
Linux program modpost can be used to convert .o files into
.ko files.
3. What are the different ways the Linux can switch from User Space to Kernel Space & vice-versa?
There are 2 situations when Linux can switch from user Space
to Kernel Space:-
1) by doing System calls
2) When interrupt comes (to handle interrupt)
3) by executing 128 (0x80 ) instruction or doing sysenter
Linux can switch from kernel Space to User space:-
1) process in kernel mode is preempted.
2) After completion of Interrupt handler / System call
3) performing sysexit sys call
Mainly hardware related information such as CPU
information, Memory (RAM) information stored under /proc
directory
example:
# cat /proc/cpuinfo (show the information of CPU of that
particular hardware)
# cat /proc/meminfo (show the information of Memory i.e.
RAM of that particular hardware)
5. What is stored at /lib/modules?
It contains all the kernel modules that needed to be loaded
into kernel (booting etc). there will some .map, .dep
(dependency files) files present.
When the kernel needs a feature that is not resident in the
kernel, the kernel module daemon kmod[1] execs modprobe to
load the module in.
You can see what modules are already loaded into the kernel
by running lsmod, which gets its information by reading the
file /proc/modules
6. What is atomic function and atomic variable?
atomic variables are the variables which can only be
manipulated atomically using atomic APIs. Linux declares
variable as atomic by using the type atomic_t. Basically
used a way to achieve synchronization.
an atomic operation is one which cannot be (or is not)
interrupted by concurrent operations and cannot be broken up
into smaller parts that could be performed by different
processors.
Atomic function is a function which is executed to
completion without interruption. Atomic function can also be
seen as a small critical section which is executed without
interruption, locking.
7. Linux file defaults permition is?
umask value = 022
Without a umask in effect,any file created will have 666
permissions.
666
022
---------
644
---------
A umask of 022 will result in files created with 666 permission.
8. How to create secured appeche web sever?
You need to install an SSL certificate in apahce to secure
the transactions.
9. What do fork() internally call?
Linux implements fork() via the clone() system call.
The clone() system call, in turn, calls do_fork().
The bulk of the work in forking is handled by do_fork(),
which is defined in kernel/fork.c.This function calls
copy_process() and then starts the process running.
If copy_process() returns successfully, the new child is
woken up and run. Deliberately, the kernel runs the child
process first.
10. What does exec family return?
When successful exec will not return, it will start
executing the new program
However if there is an- error exec returns -1 and sets the
errno to the appropriate value
https://InterviewQuestionsAnswers.ORG.