複製鏈接
請複製以下鏈接發送給好友

module

鎖定
module,n. [計] 模塊;組件;模數。[網絡] 模塊;模;模組。[專業] 模塊 [計算機科學技術];模塊 [電子、通信與自動控制技術];構件 [農業科學]。
外文名
module
發    音
[ 'mɔdju:l ]

module單詞詞義

module: [ 'mɔdju:l ]
1.[計算機] 模塊
n. 組件
2. 單元【課程學習單元】
a module in mathematics數學課的一個單元
3.宇宙飛船的分離艙

module例句用法

1. In software engineering, an individual unit or module that is utilized by higher-level programs or modules.
軟件工程中,指較高一級程序或模塊使用的一個單元或模塊。
2. Object repository support for creating shared, reusable form and data module.
用於創建共享、可重用窗體和數據模塊的對象儲存庫支持。
3. The definition of a global symbol that is not explicitly available for reference by modules linked with the module in which the definition occurs.
一種全局符號定義,它不能被與定義該全局符號的模塊相鏈接的其它模塊直接引用
4. My desk is my command module.
我的書桌就是我的主要工作場所

module英英解釋

名詞module:
1. one of the inherent cognitive or perceptual powers of the mind
同義詞faculty, mental faculty
2. detachable compartment of a spacecraft
3. computer circuit consisting of an assembly of electronic components (as of computer hardware)
4. a self-contained component (unit or item) that is used in combination with other components

module同名軟件

Linux modules是linux 2.0版本以後都支持模塊化,因為內核中的一部分常駐在內存中,(如最常使用的進程,如scheduler等),但是其它的進程只是在需要的時候才被載入。如MS-DOS文件系統只有當mount此類系統的時候才需要,這種按需加載,就是模塊。它能使內核保持較小的體積,雖然可以把所有的東東都放在內核中,這樣的話,我們就不需要模塊了,但是這樣通常是有特殊的用途(所有要運行的進程都預先知道的情況)。
模塊另一個優點是內核可以動態的加載、卸載它們(或者自動地由kerneld守護程序完成)。
Writing, Installing, and Removing Modules
WRiting Modules:
除了它們運行在內核空間中之外,模塊與其它程序類似。所以,必須定義MODULE並且包含頭文件module.h以及其它的一些內核頭文件。模塊即可以很簡單也可以很複雜。
一般的模塊格式如下:
#define MODULE
#include <linux/module.h>

/*...otherrequiredheaderfiles...*/
/**...moduledeclarationsandfunctions...*/

intinit_module()
{
	/*codekernelwillcallwheninstallingmodule*/
}

voidcleanup_module()
{
	/*codekernelwillcallwhenremovingmodule*/
}
使用內核源碼的模塊在用gcc編譯時,必須使用如下的選項:
-I/usr/src/linux/include
注意並不是所有內核中的變量都被導出供模塊使用的,即使代碼中用extern聲明瞭。在/proc/ksyms文件或者程序ksyms中顯示了被導出的符號。linux內核使用使用EXPORT_SYMBOL(x)宏來不僅導出符號,而且也導出版本號(version number)。如果是用户自己定義的變量,使用EXPORT_SYMBOL_NOVERS(x)宏。否則的話linker不會在kernel symbol table中保留此變量。可以使用EXPORT_NO_SYMBOLS宏不導出變量,缺省情況是模塊導出所有的變量。
InstallingandRemovingModules:
必須是超級用户才可以的。使用insmod來安裝一個模塊:
/sbin/insmodmodule_name
rmmod命令移除一個已經安裝了的模塊,以及任何此模塊所導出的引用。
/sbin/rmmodmodule_name
使用lsmod列出所有安裝了的模塊。
Example:
simple_module.c
/*simple_module.c
 *
 *Thisprogramprovidesanexampleofhowtoinstallatrivialmodule
 *intotheLinuxkernel.Allthemoduledoesisputamessageinto
 *thelogfilewhenitisinstalledandremoved.
 *
*/

#define MODULE
#include <linux/module.h>

/*kernel.hcontainstheprintkfunction*/

#include <linux/kernel.h>

/*
 *init_module
 *kernelcallsthisfunctionwhenitloadsthemodule
*/
intinit_module()
{
	printk("<1>The simple module installed itself properly./n");
	return0;
}
/* init_module */
/*
 *cleanup_module
 *thekernelcallsthisfunctionwhenitremovesthemodule
*/
voidcleanup_moudle()
{
	printk("<1>The simple module isnowun installed./n");
}
/* cleanup_module */
# This is the Makefile

# Makefileforsimple_module

CC     = gcc-I/usr/src/linux/include/config
CFLAGS = -O2 -D__KERNEL__ -Wall

simple_module.o : simple_module.c
install : /sbin/insmodsimple_module
remove : /sbin/rmmodsimple_module