计算机的基本任务就是运行应用程序,也就是进程。下面列出了andoird在手机上运行的进程:(adb shell, ps命令)
USER PID PPID VSIZE RSS WCHAN PC NAME
root 1 0 548 196 c00b8c14 0000d5cc S / init
root 2 0 0 0 c006bf70 00000000 S kthreadd
root 3 2 0 0 c005cc50 00000000 S ksoftirqd / 0
root 4 2 0 0 c007e408 00000000 S watchdog / 0
root 5 2 0 0 c0068eec 00000000 S events / 0
root 6 2 0 0 c0068eec 00000000 S khelper
root 10 2 0 0 c0224f90 00000000 S suspend / 0
root 81 2 0 0 c0068eec 00000000 S kblockd / 0
root 89 2 0 0 c01f2f7c 00000000 S kseriod
root 111 2 0 0 c0068eec 00000000 S kmmcd
root 117 2 0 0 c0068eec 00000000 S btaddconn
root 118 2 0 0 c0068eec 00000000 S btdelconn
root 135 2 0 0 c00448e0 00000000 S bpmd
root 141 2 0 0 c008b5f4 00000000 S pdflush
root 142 2 0 0 c008b5f4 00000000 S pdflush
root 143 2 0 0 c008f948 00000000 S kswapd0
root 189 2 0 0 c0068eec 00000000 S aio / 0
root 195 2 0 0 c01721f0 00000000 S mtdblockd
root 340 2 0 0 c01b4eb0 00000000 S accessory notif
root 349 2 0 0 c0068eec 00000000 S camera_task / 0
root 376 2 0 0 c0061438 00000000 S w1_control
root 378 2 0 0 c0061438 00000000 S w1_bus_master1
root 386 2 0 0 c0068eec 00000000 S charge
root 428 2 0 0 c02ca26c 00000000 S krfcommd
root 430 2 0 0 c0068eec 00000000 S rpciod / 0
root 724 2 0 0 c0216908 00000000 S mmcqd
root 726 1 772 180 c019dbc4 afe0c1dc S / system / bin / sh
system 727 1 840 188 c022d8a0 afe0c47c S / system / bin / servicemanager
root 729 1 1920 336 ffffffff afe0c1dc S / system / bin / mountd
root 730 1 704 176 c0257854 afe0ce0c S / system / bin / debuggerd
root 731 1 4132 628 c027e2f8 afe0ce0c S / opl / bin / tcmd
root 732 1 852 248 c00b92b0 afe0c5a4 S / opl / bin / adapter
radio 733 1 12796 648 ffffffff beaab18c S / system / bin / rild
root 734 1 72000 14172 c00b92b0 afe0c5a4 S zygote
root 735 1 33848 4512 ffffffff afe0c47c S / system / bin / mediaserver
root 736 1 1080 216 c00b8c14 bedc021c S / system / bin / dbus-daemon
root 737 1 832 208 c02b6e80 afe0c1dc S / system / bin / installd
root 740 1 856 260 c00b92b0 afe0c5a4 S / opl / bin / bpd
root 741 1 828 172 c00b8c14 afe0d27c S / opl / bin / battmond
root 768 1 720 272 c02265ec afe0c1dc S / system / bin / logcat
root 769 1 716 264 c02265ec afe0c1dc S / system / bin / logcat
root 816 2 0 0 c0068eec 00000000 S battery.0
system 825 734 5741 28 28360 ffffffff afe0c47c S system_server
radio 877 734 1582 60 20040 ffffffff afe0d404 S com.android.phone
app_5 879 734 1008 88 13616 ffffffff afe0d404 S android.process.acore
system 882 734 1446 64 24296 ffffffff afe0d404 S android.process.omsservice
app_45 884 734 9230 4 10932 ffffffff afe0d404 S com.motorola.motohome
app_22 890 734 1170 68 30228 ffffffff afe0d404 S oms.home
app_3 918 734 9876 0 12652 ffffffff afe0d404 S oms.widgetmanager
app_5 928 734 1008 88 13336 ffffffff afe0d404 S com.android.inputmethod.borqs
app_24 930 734 1051 76 19168 ffffffff afe0d404 S com.db4o.servo.search
app_18 960 734 1041 80 15208 ffffffff afe0d404 S com.android.mms
app_8 979 734 1188 60 14044 ffffffff afe0d404 S android.process.media
app_9 991 734 9198 0 12264 ffffffff afe0d404 S com.android.alarmclock
app_15 998 734 1031 44 12908 ffffffff afe0d404 S oms.dcd
system 1018 734 94732 13792 ffffffff afe0d404 S oms.dm
app_14 1025 734 95636 13036 ffffffff afe0d404 S com.android.calendar
app_42 1041 734 93292 11316 ffffffff afe0d404 S com.motorola.smsautoreg
app_40 1090 734 97152 15192 ffffffff afe0d404 S com.motorola.mtc
app_38 1102 734 93832 12868 ffffffff afe0d404 S com.streamezzo.browser.android
app_26 1115 734 96596 15084 ffffffff afe0d404 S oms.mediacenter
app_37 1126 734 98208 15212 ffffffff afe0d404 S com.hyfsoft.docviewer
app_20 1146 734 99260 15320 ffffffff afe0d404 S com.android.music
app_47 1157 734 100204 15964 ffffffff afe0d404 S com.motorola.camera
app_11 1183 734 122672 23576 ffffffff afe0d404 S com.android.browser
app_6 1199 734 117032 20388 ffffffff afe0d404 S oms.mobilemusic
system 1244 734 99292 15940 ffffffff afe0d404 S com.android.settings
app_23 1311 734 96932 16004 ffffffff afe0d404 S oms.bru
root 1334 2 0 0 c0216908 00000000 S mmcqd
app_8 1351 734 100308 15876 ffffffff afe0d404 S com.android.camera
app_1 1424 734 111904 17024 ffffffff afe0d404 S oms.messaging
app_4 1436 734 101172 15504 ffffffff afe0d404 S oms.mail
app_2 1484 734 100716 18128 ffffffff afe0d404 S com.ms
app_16 1663 734 101024 16748 ffffffff afe0d404 S oms.android.filemanager
root 1684 1 3364 176 ffffffff 0000e8f4 S / sbin / adbd
root 1692 1684 776 348 c0059cd4 afe0d0ac S / system / bin / sh
root 1724 1692 920 356 0000 0000 afe0c1dc R ps
让我们来看一下这些进程都是什么。首先是init进程,也就是linux 1号进程,父进程是0。init由0号进程创建,完成系统的初始化. 是系统中所有其它用户进程的祖先进程。
0号进程Linux引导中创建的第一个进程,完成加载系统后,演变为进程调度、交换及存储管理进程。
2号进程kthreadd PPID 0,它的子进程有很多,像ksoftirqd,watchdog等内核进程。
在然后是sh, ServiceManager,mountd, rild, zygote,
mediaserver, logcat等等,他们的父进程都是init, init按init.rc启动进程,这些进程都是用C/C++遍写的。
下面是应用程序进程,在Android系统中,应用程序进程都是由Zygote进程的子进程。Zygote进程在启动时会创建一个Dalvik虚拟机实例,每当它fork一个新的应用程序进程时,都会将这个Dalvik虚拟机实例复制到新的应用程序进程里面去,从而使得每一个应用程序进程都有一个独立的Dalvik虚拟机实例。