jjww 发表于 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

lxg8906 发表于 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.

Dragonfly 发表于 2003-6-22 23:01:38

yes, this is an attribute as jjww said.
页: 1 [2]
查看完整版本: __init什么意思?