²éÕÒLinuxÄÚºËÔ´´úÂëµÄ×î¼Ñ;¾¶
ÎÊÌ⣺²éÕÒLinuxÄÚºËÔ´´úÂëµÄ×î¼Ñ;¾¶£¬ÐèÒªÏêϸ´úÂëʾÀý
ÔÚѧϰLinuxÄں˿ª·¢»òÕß¾ÙÐÐϵͳµ÷ÓÅʱ£¬²éÕÒLinuxÄÚºËÔ´´úÂëÊǺÜÊÇÖ÷ÒªµÄÒ»ÏîÊÂÇé¡£ÏàʶLinuxÄÚºËÔ´´úÂë½á¹¹¡¢º¯Êý½ç˵¼°ÊµÏÖϸ½Ú¿ÉÒÔ×ÊÖú¿ª·¢Õ߸üÉîÈëµØÃ÷È·²Ù×÷ϵͳµÄÊÂÇéÔÀí£¬½ø¶øÌá¸ß¿ª·¢Ð§ÂÊÏ¢Õù¾öÎÊÌâµÄÄÜÁ¦¡£
ÄÇô£¬ÔÚ²éÕÒLinuxÄÚºËÔ´´úÂëʱ£¬ÓÐÄÄЩ×î¼Ñ;¾¶ÄØ£¿ÏÂÃ潫ÍŽáÏêϸµÄ´úÂëʾÀýÀ´ÏÈÈÝһЩҪÁì¡£
1. ÔÚÏßä¯ÀÀLinuxÄÚºËÔ´´úÂë
×î¼òÆӵķ½·¨ÊÇͨ¹ýÔÚÏßä¯ÀÀÆ÷À´Éó²éLinuxÄÚºËÔ´´úÂ룬ÕâÑùÄܹ»¿ìËٵزéÕÒµ½ËùÐèµÄ´úÂë¡£¿ÉÒÔʹÓÃÍøÕ¾ºÃ±È[lxr.linux.no](http://lxr.linux.no/)µÈÔÚÏßÔĶÁÆ÷À´ä¯ÀÀLinuxÄÚºËÔ´´úÂë¡£
ÀýÈ磬¼ÙÉèÎÒÃÇÒª²éÕÒsys_exitº¯ÊýµÄʵÏÖ´úÂ룬¿ÉÒÔÔÚÔÚÏßä¯ÀÀÆ÷ÖÐËÑË÷¸Ãº¯ÊýµÄÒªº¦×Ö£¬ÕÒµ½¶ÔÓ¦µÄ´úÂëÎļþ¡£Ïêϸ´úÂëʾÀýÈçÏ£º
/* * Free all assets associated with a process, * and notify "group_stop" of its death. */ void do_exit(long code) { struct task_struct *tsk = current; struct mm_struct *mm = tsk->mm; struct exit_call_struct *p; WARN_ON(atomic_read(&tsk->fs_excl)); tracehook_finish_exit(tsk); if (vtime_accounting_enabled() && !do_task_stat(tsk)) vtime_exit(tsk); cgroup_exit(tsk); if (!tsk->io_context) tsk->io_context = &noop_ioc; /* sync mm's RSS info back to its owner when required */ if (mm) sync_mm_rss(mm); /* * Make sure we are holding no locks: */ DEBUG_LOCKS_WARN_ON(!rwsem_is_locked(¤t->mm->mmap_sem) && !rwsem_is_locked(¤t->mm->page_table_lock)); BUG_ON(tsk->journal_info != NULL); do_memory_accounting(tsk); security_ops->task_free(tsk); thread_group_exit(code); }
µÇ¼ºó¸´ÖÆ
¹ØÓÚ³õѧÕß»òÕßÖ»ÊDzéÔÄÉÙÁ¿´úÂëµÄ¿ª·¢ÕßÀ´Ëµ£¬Ê¹ÓÃÔÚÏßä¯ÀÀÆ÷¿ÉÒÔ¼òÆÓ¿ì½ÝµØ»ñÈ¡ËùÐèµÄÄÚºËÔ´´úÂëÐÅÏ¢¡£
2. ʹÓÃgit¹¤¾ßÉó²éLinuxÄÚºËÔ´´úÂë
ÁíÒ»¸öÒªÁìÊÇͨ¹ýgit¹¤¾ßÖ±½Ó¿Ë¡LinuxÄÚºËÔ´´úÂë¿ÍÕ»£¬ÕâÑù¿ÉÒÔÔÚÍâµØ¾ÙÐвéÔĺÍÐ޸ġ£Ê×ÏÈÐèҪװÖÃgit¹¤¾ß£¬È»ºóʹÓÃÒÔÏÂÏÂÁîÀ´¿Ë¡Linux¿ÍÕ»£º
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
µÇ¼ºó¸´ÖÆ
¿Ë¡Íê³Éºó£¬ÔÚÍâµØÎļþϵͳÖоÍÄܹ»ÕÒµ½ËùÓеÄLinuxÄÚºËÔ´´úÂ롣Ȼºó¿ÉÒÔʹÓÃÎı¾±à¼Æ÷»òÕß´úÂëÔĶÁ¹¤¾ßÀ´Éó²éºÍÐ޸ĴúÂë¡£Ïêϸ´úÂëʾÀýÈçÏ£º
/* * Main exit path for a task. Do some of the accounting and invoke * the relevant process signal handler. */ void do_exit(long code) { struct task_struct *tsk = current; /* Free all assets associated with the process */ exit_task_struct(tsk); /* Notify group_stop of the process's death */ exit_notify(code); /* Call the scheduler to switch to a new process */ schedule(); }
µÇ¼ºó¸´ÖÆ
ͨ¹ýgit¹¤¾ßÉó²éLinuxÄÚºËÔ´´úÂëµÄ·½·¨¸üÊʺ϶ÔÄں˿ª·¢ÓÐÐèÇóµÄ¿ª·¢Õߣ¬¿ÉÒÔÔÚÍâµØ¾ÙÐдúÂëµÄÉó²é¡¢µ÷ÊÔºÍÐ޸ġ£
½áÓï
ͨ¹ýÔÚÏßä¯ÀÀÆ÷ºÍgit¹¤¾ßÉó²éLinuxÄÚºËÔ´´úÂëÊÇѧϰÄں˿ª·¢ºÍϵͳµ÷ÓŵÄÖ÷Ҫ·¾¶Ö®Ò»¡£ÔÚ²éÕÒÄÚºËÔ´´úÂëʱ£¬¿ÉÒÔƾ֤ÏêϸµÄÐèÇóÑ¡ÔñºÏÊʵķ½·¨£¬²¢Í¨¹ýÏêϸµÄ´úÂëʾÀýÀ´¸üºÃµØÃ÷È·ºÍÔËÓÃÄÚºËÔ´´úÂ롣ϣÍû±¾ÎĶԸ÷ÈËÔÚ²éÕÒLinuxÄÚºËÔ´´úÂëʱÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊDzéÕÒLinuxÄÚºËÔ´´úÂëµÄ×î¼Ñ;¾¶µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡