linux 进程的作用,linux的几个进程的作用

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----------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值