引述自 The Linux Kernel Module Programming Guide
原文 :
What exactly is a kernel module? Modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system. For example, one type of module is the device driver, which allows the kernel to access hardware connected to the system. Without modules, we would have to build monolithic kernels and add new functionality directly into the kernel image. Besides having larger kernels, this has the disadvantage of requiring us to rebuild and reboot the kernel every time we want new functionality.
自譯 :
Kernel module 其實就是一段程式碼,根據需求(service),module 可以載入 kernel 裡,或是從 kernel 中卸除,並不需要重新啟動作業系統(Linux),module 擴展了 kernel 的功能。
舉例,假設有一個 module 是屬於 device driver 類型,那麼這個 module 在 kernel 中可以直接存取與系統連線的硬體;相對地,若是 kernel 沒有提供 module 這樣的機制,我們必須在建置一個單體核心(ex. Linux)時,選擇直接加入新的功能到 kernel 裡,除此之外,kernel會變的較龐大一些(視所加入功能多寡),另外還有個缺點,在每次 kernel 希望新增功能時,就必須要再重新建置 kernel,且重新啟動系統,讓 kernel 重新載入新功能。
結論,簡單的來說,kernel 提供了 module 機制,新增功能(kernel 所沒有提供的)就會變的較有彈性,若是想要修改原有功能一小部份,對於在開發時也較為方便。
留言