linux的幾個進程的作用

來源:互聯網
上載者:User

 author:skate
time:2011/08/10

 

linux的幾個進程的作用

 

1. kswapd0

 

Linux uses kswapd for virtual memory management such that pages that have been recently accessed
 are kept in memory and less active pages are paged out to disk.
(what is a page?)…Linux uses manages memory in units called pages.
So,the kswapd process regularly decreases the ages of unreferenced pages…and at the end they are
 paged out(moved out) to disk

系統每過一定時間就會喚醒kswapd,看看記憶體是否緊張,如果不緊張,則睡眠,在kswapd中,有2個閥
值,pages_hige和pages_low,當空閑記憶體頁的數量低於pages_low的時候,kswapd進程就會掃描記憶體並且
每次釋放出32個free pages,直到free page的數量到達pages_high.

 

linux在負載比較大(記憶體很緊張)的時候一般會看到這樣的兩個進程kswapd0和kswapd1,如果這個進程佔用
系統資源很多,尤其是在rac環境會引起系統的宕機,如果這個進程佔用資源非常高,那就要考慮最佳化系統,或
添加硬體資源。

2.kjournald

這個是EXT3檔案系統的日誌進程,具有3種模式:

journal:
 logs all filesystem data and metadata changes. The slowest of the three ext3

 journaling modes, this journaling mode minimizes the chance of losing the changes
 you have made to any file in an ext3 filesystem.(記錄所有檔案系統上的中繼資料改變,最慢的一種模式,)

ordered:
 only logs changes to filesystem metadata, but flushes file data updates to disk
 before making changes to associated filesystem metadata. This is the default ext3
 journaling mode.(預設使用的模式,只記錄檔案系統改變的中繼資料,並在改變之前記錄日誌)

writeback:
 only logs changes to filesystem metadata but relies on the standard filesystem

 write process to write file data changes to disk. This is the fastest ext3
 journaling mode.(最快的一種模式,同樣只記錄修改過的中繼資料,依賴標準檔案系統寫進程將資料寫到硬碟)

修改模式EXT3的工作模式,例如

vi /etc/fstab
/dev/hda5      /opt            ext3       data=writeback        1 0

 

3.pdflush

pdflush用於將記憶體中的內容和檔案系統進行同步,比如說,當一個檔案在記憶體中進行修改
,pdflush負責將它寫回硬碟.每當記憶體中的垃圾頁(dirty page)超過10%的時候,pdflush
就會將這些頁面備份回硬碟.這個比率是可調節的,通過/etc/sysctl.conf中的
vm.dirty_background_ratio項 預設值為10。

 

也可以如下查詢:
cat /proc/sys/vm/dirty_background_ratio 查看當前的值

 

4. ACPI

是Advanced Configuration and Power Interface縮寫,acpid中的d則代表daemon ,Acpid是一個使用者空間的服務進程,它充當linux核心與應用程式之間通訊的介面,
負責將kernel中的電源管理事件轉寄給應用程式。 支援的通用操作有:“電源開關“,
”電池監視“,”筆記本 Lid 開關“,“筆記本顯示屏亮度“,“休眠”, “掛機”,等等。

acpid與核心的通訊方式:acpid用poll函數掛在/proc/acpi/event檔案上。核心在
drivers/acpi/event.c中實現了該檔案的介面,一旦匯流排事件列表(acpi_bus_event_list)
上有電源管理事件發生,核心就會喚醒掛在 /proc/acpi/event上的acpid,acpid再
從/proc/acpi/event中讀取相應的事件。

 

acpid與應用程式的通訊方式有兩種,其一是通過本地socket,其檔案名稱為/var/run/acpid.socket,
應用程式只要串連到這個socket上,不用發送任何命令就可以接收到acpid轉寄的電源管理事件。

其二是通過設定檔。在acpid收到來自核心的電源管理事件時,根據設定檔中的規則執行指定的命令。
設定檔在/etc/acpi/events/目錄下,下面是一個樣本:

 

[root@rac2 ~]# more /etc/acpi/events/power.conf
# ACPID config to power down machine if powerbutton is pressed, but only if
# no gnome-power-manager is running

event=button/power.*
action=/bin/ps awwux | /bin/grep gnome-power-manager | /bin/grep -qv grep || /sbin/shutdown -h now
[root@etl-dbrac2 ~]#

 

在對應的log檔案裡有記錄:

[root@rac2 ~]# tail -20 /var/log/acpid  |more
[Fri Jul 29 01:28:56 2011] received event "button/power PWRF 00000080 00000001"
[Fri Jul 29 01:28:56 2011] notifying client 6775[68:68]
[Fri Jul 29 01:28:56 2011] notifying client 7739[0:0]
[Fri Jul 29 01:28:56 2011] executing action "/bin/ps awwux | /bin/grep gnome-power-manager | /bin/grep -qv grep || /sbin/shutdown -h
 now"
[Fri Jul 29 01:28:56 2011] BEGIN HANDLER MESSAGES
[Fri Jul 29 01:28:57 2011] END HANDLER MESSAGES
[Fri Jul 29 01:28:57 2011] action exited with status 0
[Fri Jul 29 01:28:57 2011] completed event "button/power PWRF 00000080 00000001"
[Fri Jul 29 01:33:18 2011] starting up
[Fri Jul 29 01:33:18 2011] 1 rule loaded
[Fri Jul 29 01:33:23 2011] client connected from 6789[68:68]
[Fri Jul 29 01:33:23 2011] 1 client rule loaded
[Fri Jul 29 01:33:31 2011] client connected from 7792[0:0]
[Fri Jul 29 01:33:31 2011] 1 client rule loaded
[Sat Aug  6 03:16:37 2011] starting up
[Sat Aug  6 03:16:37 2011] 1 rule loaded
[Sat Aug  6 03:16:45 2011] client connected from 6761[68:68]
[Sat Aug  6 03:16:45 2011] 1 client rule loaded
[Sat Aug  6 03:16:54 2011] client connected from 7723[0:0]
[Sat Aug  6 03:16:54 2011] 1 client rule loaded

 

5.gnome-power-manager

 

是一個直接面對終端使用者的應用程式,也是一個中介層。作為中介層,acpid對普通應用程式來說還是過於底層,
但gnome-power-manager為其它應用程式提供了更高層的服務介面。

 

6. NetworkManager

是一個自動切換網路連接的後台進程。很多筆記本使用者都需要啟用該功能,它讓你能夠在無線網路和有線網路之間切換。大多數台式機使用者應該關閉該服務。一些 DHCP 使用者可能需要開啟它。

 

 

 

----------end----------

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.