Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of __init & __exit attributes

What happens if __init & __exit attributes are used in intialization and exit modules & what happens if i don't use them. Example as shown below.

Using Attributes

static __init int myinit(void)
{}
static __exit void myexit(void)
{}

Witout attributes

static int myinit(void)
{}
static void myexit(void)
{}
like image 477
Sandy Avatar asked Oct 06 '13 12:10

Sandy


1 Answers

@Sandy, The __init macro causes the init function to be discarded and its memory(vmalloc) freed once the init function finishes for built-in drivers. The __exit macro causes the omission of the function when the module is built into the kernel. Both __init and __exit will not hold good for the LKM. Also go through these links What does __init mean in the Linux kernel code? http://amar-techbits.blogspot.in/2012/08/understanding-macro-init-and-exit-in.html

like image 117
Gautham Kantharaju Avatar answered Sep 21 '22 06:09

Gautham Kantharaju