linux¿ª»úÆô¶¯
linuxÓÐ×Ô¼ºÒ»Ì×ÍêÕûµÄÆô¶¯Ìåϵ£¬×¥×¡ÁËlinuxÆô¶¯µÄÂöÂ磬linuxµÄÆô¶¯¹ý³Ì½«²»ÔÙÉñÃØ¡£
ÔĶÁ֮ǰ½¨ÒéÏÈ¿´Ò»Ï¸½Í¼¡£
±¾ÎÄÖмÙÉèinittabÖÐÉèÖõÄinit treeΪ£º
/etc/rc.d/rc0.d
/etc/rc.d/rc1.d
/etc/rc.d/rc2.d
/etc/rc.d/rc3.d
/etc/rc.d/rc4.d
/etc/rc.d/rc5.d
/etc/rc.d/rc6.d
/etc/rc.d/init.d
1. ¹ØÓÚlinuxµÄÆô¶¯
2. ¹ØÓÚrc.d
3. Æô¶¯½Å±¾Ê¾Àý
4. ¹ØÓÚrc.local
5. ¹ØÓÚbashÆô¶¯½Å±¾
6. ¹ØÓÚ¿ª»ú³ÌÐòµÄ×Ô¶¯Æô¶¯
1. ¹ØÓÚlinuxµÄÆô¶¯
initÊÇËùÓнø³ÌÖ®¸¸
init¶ÁÈ¡/etc/inittab£¬Ö´ÐÐrc.sysinit½Å±¾
(×¢ÒâÎļþÃûÊDz»Ò»¶¨µÄ,ÓÐЩunixÉõÖÁ»á½«Óï¾äÖ±½ÓдÔÚinittabÖÐ)
rc.sysinit½Å±¾×÷Á˺ܶ๤×÷:
init $PATH
config network
start swap
set hostname
check root file system, repair if needed
check root space
....
rc.sysinit¸ù¾ÝinittabÖ´ÐÐrc?.d½Å±¾
linuxÊǶàÓû§ÏµÍ³£¬gettyÊǶàÓû§Óëµ¥Óû§µÄ·ÖË®Áë
ÔÚgetty֮ǰÔËÐеÄÊÇϵͳ½Å±¾
2. ¹ØÓÚrc.d
ËùÓÐÆô¶¯½Å±¾·ÅÖÃÔÚ /etc/rc.d/init.dÏÂ
rc?.dÖзÅÖõÄÊÇinit.dÖнű¾µÄÁ´½Ó£¬ÃüÃû¸ñʽÊÇ£º
S{number}{name}
K{number}{name}
S¿ªÊ¼µÄÎļþÏò½Å±¾´«µÝstart²ÎÊý
K¿ªÊ¼µÄÎļþÏò½Å±¾´«µÝstop²ÎÊý
number¾ö¶¨Ö´ÐеÄ˳Ðò
3. Æô¶¯½Å±¾Ê¾Àý
ÕâÊÇÒ»¸öÓÃÀ´Æô¶¯httpdµÄ /etc/rc.d/init.d/apache ½Å±¾£º
´úÂë:
#!/bin/bash
source /etc/sysconfig/rc
source $rc_s
case "$1" in
start)
echo "Starting Apache daemon..."
/usr/local/apache2/bin/apachectl -k start
evaluate_retval
;;
stop)
echo "Stopping Apache daemon..."
/usr/local/apache2/bin/apachectl -k
Ïà¹ØÎĵµ£º
New things to learn about Linux Scheduler):
1. Rotating Staircase Deadline cpu scheduler policy
2. CFS (Completely Fair Scheduler)
3. BFS (Brain Fuck Scheduler)
http://lwn.net/Articles/
http://kerneltrap.org/
......
/*
*By Neil Chiao (neilchiao at gmail.com)
*תÔØÇë×¢Ã÷³ö´¦£ºneilengineer.cublog.cn
*±¾ÎIJ¿·ÖÄÚÈÝÀ´×ÔÍøÂç
*»¶Óµ½“ÐÂÐÇÍå(www.xinxingwan.com)”Ö¸µ¼
*/
1¡¢LinuxÍøÂçÉ豸Çý¶¯µÄÌåϵ½á¹¹
LinuxÍøÂçÇý¶¯³ÌÐòµÄÌåϵ½á¹¹¿É»®·ÖΪ4¸ö²ã´Î¡£LinuxÄÚºËÔ´´úÂëÖÐÌṩÁËÍøÂçÉ豸½Ó¿Ú¼°ÒÔÉϲã´ÎµÄ´ ......
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <fcntl.h>
int g_count;
void Exit()
{
printf("I will exit, press any key to continue...(g_count = %d)\n", g_count);
exit(0);
}
int main(int argc, char* argv[])
{
struct sigaction almact;
pid_t ......
Ò»¡¢Ê²Ã´ÊÇinit
¡¡¡¡initÊÇLinuxϵͳ²Ù×÷Öв»¿ÉȱÉٵijÌÐòÖ®Ò»¡£ ÊÇÒ»¸öÓÉÄÚºËÆô¶¯µÄÓû§¼¶½ø³Ì¡£
¡¡¡¡ÄÚºËÆô¶¯£¨ÒѾ±»ÔØÈëÄڴ棬¿ªÊ¼ÔËÐУ¬²¢Òѳõʼ»¯ËùÓеÄÉ豸Çý¶¯³ÌÐòºÍÊý¾Ý½á¹¹µÈ£©Ö®ºó£¬¾Íͨ¹ýÆô¶¯Ò»¸öÓû§¼¶³ÌÐòinitµÄ·½Ê½À´Æô¶¯ÆäËûÓû§¼¶µÄ½ø³Ì»ò·þÎñ¡£ËùÒÔ£¬initʼÖÕÊǵÚÒ»¸ö½ø³Ì£¨ÆäPIDʼÖÕΪ1£©¡£
¡¡¡¡ÄÚºË ......
Ç° ÑÔ
´Ó×ÀÃæµ½·þÎñÆ÷£¬LinuxµÄÓ¦ÓÃÕý±äµÃÔ½À´Ô½¹ã·º£¬Òµ½ç¶ÔLinuxרҵÈ˲ŵÄÐèÇóÁ¿Ò²ÔÚ¼±¾çÔö³¤¡£¸ßУѧÉú¡¢ITÒµ½çÈËÊ¿¶¼Ï£Íûͨ¹ýѧϰLinux֪ʶ´Ó¶øÌáÉý×Ô¼ºµÄ¾ºÕùÁ¦£¬ÒÔ»ñµÃ¸ü¸ßµÄн³ê¡£µ«ÊÇÄ¿Ç°¹ØÓÚLinuxµÄÊé¼®´ó²¿·Ö¶¼Ö»ÊÇÆ«ÖØÓÚ×ÀÃæÓ¦Ó㬻òÕßÊÇֻͣÁôÔÚһЩ±íÃæµÄ¼òµ¥²Ù×÷¡£ÄÜÓÉdzÈëÉȫÃæϸÖµؽéÉÜLinuxµÄ ......