QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

楼主: jjww

__init什么意思?

[复制链接]
 楼主| 发表于 2003-6-20 10:14:57 | 显示全部楼层
The attribute __init, when used in this way, will cause the initialization function to be discarded, and its memory reclaimed, after initialization is complete. It only works, however, for built-in drivers; it has no effect on modules. __exit, instead, causes the omission of the marked function when the driver is not built as a module; again, in modules, it has no effect.
The use of __init (and __initdata for data items) can reduce the amount of memory used by the kernel. There is no harm in marking module initialization functions with __init, even though currently there is no benefit either. Management of initialization sections has not been implemented yet for modules, but it’s a possible enhancement for the future.

LDD2第二章Explicit Initialization and Cleanup Functions
回复

使用道具 举报

发表于 2003-6-22 22:36:13 | 显示全部楼层
I just want to repeat __init is used to free the memory used.   Some memories are just used once and can be reclaimed later.  "但是我不知道kernel释放这些初始化内存的控制路径在什么位置", it is controlled by gcc.  Actually when you compile it, the compiler will process it the correct way.  After execution, reclaim the memory.   It is not linux related, but gcc related.   GCC is infamous for its bad doc, but I remember the feature is documented in detail.  so better read gcc manual or $info gcc.

Hope it helps.
回复

使用道具 举报

发表于 2003-6-22 23:01:38 | 显示全部楼层
yes, this is an attribute as jjww said.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-16 11:59 , Processed in 0.036088 second(s), 13 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表