• [译]5.5. Initialization Options 初始化选项


    目录:http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html
     
    [不提供插图,读者最好从网上下载源书]

    5.5. Initialization Options 初始化选项
    Both components built into the kernel and components loaded as modules can be passed input parameters so that users can fine-tune the functionality implemented by the components, override defaults compiled into them, or change them from one system boot to the next. The kernel provides two kinds of macros to define options :
    不管是编译到内核中的组件,还是以模块的形式加载的组件,用户都可以通过输入参数来调整组件给我们提供的功能。重载编译到组件中的默认值,或者在后来的系统启动时修改它们。内核给我们提供了两个宏来定义选项:

    Module options (macros of the module_param family)
    模块选项 module_param家族宏

    These define options you can provide when you load a module. When a component is built into the kernel, you cannot provide values for these options at kernel boot time. However, with the introduction of the /sys filesystem, you can configure the options via those files at runtime. The /sys interface is relatively new, compared to the /proc interface. The later section "Module Options" goes into a little more detail on these options.
    当你加载一个模块时,可以提供这些定义选项。当一个组件编译到内核时,你不能在内核启动时为这些组件提供值。然而,通过介绍/sys文件系统,你可以在运行时通过这些文件来配置这些选项。与/proc接口相比,/sys接口相对是新的方法。在后面一节,“模块选项”会进一步详细的讨论这些选项。


    Boot-time kernel options (macros of the _ _setup family)
    启动时内核选项(__seup家族宏)

    These define options you can provide at boot time with a boot loader. They are used mainly by modules that the user can build into the kernel, and kernel components that cannot be compiled as modules. You will see those macros in the section "Boot-Time Kernel Options" in Chapter 7.
    你可以在内核启动时,通过bootloader提供这些定义选项。这些主要是给那些用户编译到内核中的模块使用,以及那些可以编译成模块的内核组件。你会在第7章的“启动时内核选项”这一节中看到这些宏。

    It is interesting to note that a module can define an initialization option in both ways: one is effective when the module is built-in and the other is effective when the module is loaded separately. This can be a little confusing, especially because different modules can define passing parameters of the same name at module load time without any risk of name collision (i.e., the parameters are passed just to the module being loaded), but if you pass those parameters at kernel boot time, you must make sure there is no name collision between the various modules' options.
    值得注意是,当一个模块可以通过两种方法定义一个初始化选项时:一个是在编译到时起作用,另一个是在模块独立加载时起作用。这可能会有些混淆,特别是因为不同的模块可以定义成在加载时传同样名字的参数而没有任何名字冲突的风险(例如,这些被传递的参数只是用于模块加载),但如果你在内核启动时传递这些参数,你必须确保这些参数名与模块的选项没有冲突。

    We will not go into detail on the pros and cons of the two approaches. You can look at the drivers/block/loop.c driver for a clear example using both module_param and _ _setup.
    我们不会对prod和codns这两个方法做详细的讨论。你可以在drivers/block/loop.c中看到详细的驱动例子,它们使用了module_param和__setup.

  • 相关阅读:
    could not read data from '/Users/lelight/Desktop/ViewControllerLife/ViewControllerLife/Info.plist': The file “Info.plist” couldn’t be opened because there is no such file.
    NSNotification 消息通知的3种方式
    按钮点击播放音效
    字符串变枚举变量
    Flutter的使用教学笔记
    UI控件的位置
    博客园大佬主页跳转
    retain, copy, assign区别
    OC自定义文档头部注释
    OC语言自定义打印
  • 原文地址:https://www.cnblogs.com/WuCountry/p/1392065.html
Copyright © 2020-2023  润新知