Template Information

Trang

Initialization and Shutdown

Thứ Bảy, 4 tháng 6, 2011 / 20:31

static int __init initialization_function(void)
{
/* Initialization code here */
}
module_init(initialization_function);
Initialization functions should be declared static, since they are not meant to be visible
outside the specific file; there is no hard rule about this, though, as no function is
exported to the rest of the kernel unless explicitly requested. The __init token in the
definition may look a little strange; it is a hint to the kernel that the given function is
used only at initialization time. The module loader drops the initialization function
after the module is loaded, making its memory available for other uses. There is
a similar tag (__initdata)for data used only during initialization. Use of __init and
__initdata is optional, but it is worth the trouble. Just be sure not to use them for
any function (or data structure)you will be using after initialization completes. You
may also encounter __devinit and __devinitdata in the kernel source; these translate
to __init and __initdata only if the kernel has not been configured for hotpluggable
devices

0 nhận xét:

Đăng nhận xét