linux内核很庞大,怎样把需要的部分都包含在内核中:
1,把需要的功能都编译到内核。这会导致内核很大,如果要在内核中下新增或删除功能需要重新编译。
2,使用linux 模块机制。模块机制:模块本身不被编译入内核,模块一旦被加载它就和内核中的其他部分完全一样。
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void)
{
printk(KERN_INFO " hello world enter \n");
return 0;
}
static int hello_init(void)
{
printk(KERN_INFO " hello world enter \n");
return 0;
}
static int hello_init(void)
{
printk(KERN_INFO " hello world enter \n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_INFO " hello world enter \n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_AUTHOR("xsw 530728983@qq.com");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("a simple hello world module");
MODUL