I have listed few questions which gives basic idea of Linux kernel programming. Mostly kernel related interview is about the work you have done in past. For example, if you have done I2C & SPI drivers then most of the question is from those interfaces. If interviewer wants to know about your kernel knowledge, then he/she may ask general kernel related questions. I will update these questions on regular basis.
1. What is __init , __initdata ??
These macros are used to mark some functions or initialized data (doesn't apply to uninitialized data) as "initialization" functions.The kernel can take this as hint that the function is used only during the initialization phase and free up used memory resources after.
__init
will be defined as#define __init __section(.init.text) __cold notrace
and internally it will be expanded as
#define __section(S) __attribute__ ((__section__(#S)))
References:
http://lxr.free-electrons.com/source/include/linux/init.h?v=3.14
good explanation of __read_mostly, __init, __exit macros
http://lxr.free-electrons.com/source/include/linux/init.h?v=3.14
good explanation of __read_mostly, __init, __exit macros
2. what is module_init() and module_exit() ??
These are macros which provides appropriate flags(boilerplates) to compiler for ensuring the treatment of init and cleanup functions.
3. What is EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL() ??
If programmer wants some symbols(function/data) to be used in other kernel modules, then those symbols should be exported using these macro. As name implies, EXPORT_SYMBOL_GPL() exports symbols only to GPL licensed modules.
4. What is modprobe, insmod, rmmod & depmod ?
5. What is initcall mechanism??
6. Which function will be the first function to be called in linux kernel?
No comments:
Post a Comment