- 论坛徽章:
- 0
|
- #include <linux/module.h>
- #include <linux/vmalloc.h>
- MODULE_AUTHOR("platinum");
- MODULE_DESCRIPTION("This is a module sample.");
- MODULE_LICENSE("GPL");
- __u8 *data;
- int
- init_module (void)
- {
- data = vmalloc(1024 * 1024 * 200);
- if (!data)
- return -ENOMEM;
- memset(data, 0xff, 1024 * 1024 * 200);
- printk("module loaded.\n");
- return 0;
- }
- void
- cleanup_module(void)
- {
- vfree(data);
- printk("module unloaded.\n");
- }
复制代码root@LinuxDev /platinum/project/module
# free
total used free shared buffers cached
Mem: 510644 275620 235024 0 48544 168876
-/+ buffers/cache: 58200 452444
Swap: 522104 0 522104
root@LinuxDev /platinum/project/module
# insmod module.ko
root@LinuxDev /platinum/project/module
# free
total used free shared buffers cached
Mem: 510644 480716 29928 0 48652 168888
-/+ buffers/cache: 263176 247468
Swap: 522104 0 522104
root@LinuxDev /platinum/project/module
# rmmod module
root@LinuxDev /platinum/project/module
# free
total used free shared buffers cached
Mem: 510644 276232 234412 0 48732 168888
-/+ buffers/cache: 58612 452032
Swap: 522104 0 522104
root@LinuxDev /platinum/project/module
# |
评分
-
查看全部评分
|