������: guru (������~~��业=���), ����: BIBLE
�� ��: ���共�停���Unix Internels����一��
����站: UNIX��� (2001��10��14��17:18:33 ������), 站���偶�
������: BlueOcean (Blue), ����: Unix
�� ��: [转��] ���共�停���Unix Internels����一��
����站: BBS 水木�华站 (Mon Apr 27 12:59:09 1998) WWW-POST
���掖�师����������本�宝�,������Bible���暮��。
��台�精�����看�����本����慕��埽�����转�����隆�
�本���铱���牡�一����细����thread�������,�����谴�实�值慕嵌龋�COOL��
Unix, I love you!
������: syc@cc.ntu.edu.tw (Shiau Yong-Ching), ����: Linux
�� ��: [转��] ���共�停���Unix Internels����一��
����站: National Taiwan University (Wed Jul 9 23:23:08 1997)
转��站: sobee!netnews.ntu!not-for-mail
�诔���前, �透�����掖�学�����TAnet & UNIX...
UNIX Internals
The New Fronters
����
"UNIX系统�陌�装���丫��沙���10��,
预�洗����只����������"
-- Ken Thompson��Dennis Ritchie
�UNIX��式���师�植�诙���
1972��6��12��
����UNIX���籍�芏�,���蔷�蟛糠侄�只���������使��,����UNIX��式��频��不
��,�����UNIX系统���牡������歉�����..�����羌����������:
* Bach��The Design of the UNIX Operating System, 1986 --����System V
Release 2
* Leffler����, The Design and Implementation of the 4.3BSD UNIX
Operating System, 1988 -- ����4.3BSD UNIX
* Goodheart��Cox, The Magic Garden Explained, 1994 -- ����System V
Release 4.0
然��,��些�都只����缘�����/�囟���UNIX系统��写��,���俑����一�������
�鄣�. ��Uresh Vahalia��UNIX Internals -- The New Frontiers�本��
���谴�一����鄣慕嵌�����Unix系统.�诒�����,������������业��,学����
�母���UNIX系统,��细�慕����烁�系统�����法,���愿�系统����缺������
��细���铱凸鄣谋冉�,实����系统����员,��式���师,���������识����
UNIX������玫亩���.
�������越���UNIX System V Release 4.2为��,�����博��������业�UNIX,
������������椎�失.����������1996,�墙���UNIX���牡����虏慰�����.
�业亩������没�谢�������������.��UNIX��使��,�����约���式��频木���
�潜����,����Bach��The Design of the UNIX Operating
System也�榷���,������本
��图��������.
����������鼙����芯��傻牟���,也���谴蟛糠�UNIX��������要�私�牟���,������
��些�薹���原����,����没��时��专��Unix������.��抖��叩某潭�没���囟��募���.
���艿����也�����说�,���位����.
Chapter 1 Introduction
失���UNIX
����愿��业�UNIX��������,唯��IBM��AIX���羌���支��未��.�����
��AIX��支����,���本����芑�����失��,��为AIX�����UNIX���牡�
��展����影����.同���, HP-UX也��一��. 唯一���知����,�����
������UNIX�����System V���������UNIX.
����写��应��1995������,然��1995,1996��UNIX�动����一��,����
���UNIX���谈��������浅戮傻�UNIX系统,����������SVR4����,����
没���到����, 应��影�不���, ��������没��什������募���,也����
�冉�平庸:p, 也��������为���潜冉喜�����,��学���不太�蚪坏���缘�拾�...
��������要��������UNIX����史,�������1995/96�化太����,��些����
�������呓���史 :)
���常���到��UNIX系统�����诘�UNIX System V Release 4.x,
UNIX���姆�������BSD UNIX 4.x (������4.3, 4.4)�约�UNIX�拇���,
Carnegie-Mellon��学��Mach (ch��k����,��Mac).��������占������叩�
UNIX--Sun��SunOS�约�Solaris. Digital Equipment Corporation(���
Digital,��DEC) ��OSF/1,���诟����Digital UNIX,������为
使����Mach���亩�沾�瞬��俟�,�毓��蚀���.
�酃�全��, Sun ����说�������蟹�实����UNIX����,实�诓������.
��史��
1960���末��,Bell Telephone Laboratories, General Electric ��
Massachusetts Institude of Technlogy�����蟹�一����使���叩���
业系统, Multics.�思苹��1969������取��. 取����墓��麓���械�
��,���点不��,�����key part�����:
* Ken Thompson��DEC PDP-7��写�烁���Space Travel�牡���.
* PDP-7欠缺��式��展����,so, Ken Thompson + Dennis Ritchie写��UNIX����.
* Ken Thompson写��B����(��BCPL�莼�������直������)
* Dennis Ritchie��B�某��������C����.
* 1973��11��Unix version 4,使��C���愿�写���.
Unix�牡�一篇Paper "The UNIX Time Sharing System"��Ken Thompson��Dennis
Ritchie
���,��1973��十��the ACM Symposium on OS (SOSP)�������.���诖������碌�
the Communications of the ACM����.����UNIX�����牡�一�谓哟�.
UNIX���������原��
1956��AT&T�艿�������斯������.�����诩�AT&T����������签����一��协��,
���芫�营��话�报�薰�之业��.BTL�����AT&T.
UNIX��SOSP������,学�����UNIX����原始�����蟛欢�,����AT&T����训�
�供原始���学����,�司������UNIX�广泛����.
Berkeley��Computer Science Research Group, CSRG��UNIX�姆�展���撕芏�墓���.
Berkeley��UNIX��为BSD UNIX. BSD��UNIX�墓�����virtual memory, TCP/IP, Fast
File System(FFS), reliable signals, socket����.
4.4BSD��原����VM����Mach��VM,�������Logged File System. (LFS).
CSRG����BSD4.4之��凸��糯���.原����:
* ����牟���
* BSD����色�丫���������业系统�霞���(���圆���DIY��)
* 系统�丫��蟮讲���一��小�����维���某潭���
��一�夜�司Berkeley Software Design, Inc.(BSDI)��������������4.4BSD,
������业��为.���堑�BSD����BSD/386. BSDI���BSD/386������Berkeley
�母�写,�丫�没��AT&T��原始����.����AT&T���嵌�Berkeley��BSDI�������.
��������BSDI�电话: 1-800-ITS-UNIX.��一����������4.4BSD�姆���.
���1994���������,双����珊徒�,�������. BSDI�����瞬���AT&T���
��原始���4.4BSD原始��,��为4.4BSD-Lite. �������墓��戮�������路��
�拇���,�������386BSD��������.
UNIX System #
������司����������将AT&T�������庸�司, BTL����为AT&T Bell Laboratories.
����AT&T�������������谐�. AT&T�������业��UNIX����System III,
System V, System V Release 2 (SVR2) System V Release 3, System V Release
4/4.2
System V���������碌���色(���毒傻�UNIX),��regions�芄������������(��
BSD�牟�太��同), IPC, remote file sharing, shared libraries,
STREAMS�芄��鹊�.
UNIX����业��
��业����UNIX也为UNIX���?����色,��SunOS��Network File System (NFS),
vnode/vfs interface支援���氐���系统,一���碌�VM�芄�(为SVR4�����)
AIX�堑�一��支援journaling file system����业UNIX. ULTRIX (DEC�木�UNIX)
��支援multiprocessor UNIX������之一.
Mach
Mach��Carnegie-Mellon��学(CMU)��microkernel(微����)��业系统.(1980���)
������越��越��,UNIX也�战��哟��佣���������, microkernel�母������
��Kernel去�叽�菁,��������要�牟���,���诺墓��芏���user�撞�某�式(����
server)����删秃���,��思���kernel�母��佣�.
Mach���目����
* ��UNIX����
* �诘�������,�处�����隙���执��
* �屎戏�散式���环��
���毡�版本��Mach2.5,�������业UNIX��DEC OSF/1, NextStep�幕�.
Mach3.0������������全Microkernel���本.
��准����
UNIX�谋�准������版本一���.��小����细�慕����烁�����准��������.
���鄣����碌���讯为Novell��UNIX�瘫�������X/Open,�约�Sun Solaris 2.5��.
1986��IEEE指����一��委员���贫���一��一��������业系统�谋�准,��为
POSIX (Portable Operating Systems Interface,������细�X,为�撕���,也����为
��������UNIX�谋�准).<-��������说��,��������写��.
X/Open��一���晒���缘��猿�����傻幕�,�����1984.��目�谋冉���实,
����为�诙��UNIX��准�����一��.���前����姆��汇集���械谋�准,
�����一����通�幕���.XPG (X/Open Portability Guide)������拇���.
目前UNIX����瘫�应������X/Open��拥��.
���吮�准����,UNIX����也�泻�������.
UI, Unix International,��AT&T��Sun为��������.��要�牟�����SVR4��OpenLook.
OSF, Open Software Foundation为��IBM,DEC,HP为�椎墓�司投�实��庸�司.
OSF��UNIX�墓�����Motif��准,DCE (Distributed Computing Environment).
��NT����������,UI�呓���,AT&T��要UNIX��(专������plan9��业系统?),
SVR4�拇��吮����Sun��Solaris,����Sun也���偌��OpenLook,同时支援CDE
(Common Desktop Environment,���谆�一�����Motif).
Chapter 2 The Process and the Kernel
����Prcoess�母������结构��执��态,没什���乇��.�����Unix Progarmming
��小��习.
�冉��乇����vfork������.��些��������������执��UNIX��, vfork = fork with
copy on write�拇��.实����vfork��, child�呛�parent����一�定址�占�(�冉���
multi-threading), child�����薷�parent������.
����目前unix�������原始��vfork
��一���税�..
Chapter 3 Threads and Lightweight Processes
�����到Modern UNIX������之一: threads. ��Win95/NT, OS2�拇���之��
���应���械���目染�税�.��叨�����Threads��Lightweight processes.
��些系统, threads = LWP,����为�����鄣���要,����threads != LWP.
thread��一����小��执�械�元, ���一��process��系统����活动状态.��统��
process���墙���一��thread�某�式.一����式��5��thread����说同一����式����
���������同时�诮���,也�������小��式�����������诺�一���艿���思.(��
�话���病,���业����缘暮���) �冉系徒�一��目�����一��process��5��
instruction flow�����stack.����呛�模��,����Mach�亩���疟冉������.
Thread������:kernel threads, lightweight processes, user threads.
kernel threads����kernel�泻眉�������,一��������源���一���碌���思.
�����������同���录�������, kernel���远�每����同���录��������������.
kernel threads�牟����浅����,����没�懈���,���叶�Kernel�结构�邪���.
支援kernel threads��kernel����multithreaded kernel.
Lightweight Process����Kernel支援��user thread.也����说,每��LWP,kernel
��使��一��thread������/支援.���LWP���钥�����kernel thread������.��
��LWP�拇���呛艽��,��为��牵����Kernel��context switching.
user threads����使���呖占�,透��library模���thread,����要�����要���俚�
kernel支援,context switching�冉峡�,��为���酶��page table�鹊榷���,
使��������为������.user threads�供�倏��哟�系统�木�呀������.
kernel���峡�����全��知��user threads�拇���, ��一��系统����
�供�����同�� library���供��同policy. user threads����一��应�贸�式
��要��multi-threading����式, ��为�朔�式没��kernel����, ��������盈,
����效��. �到����,���欠�怨����, OS2��Win95/NT��multithreading支援
�械��曰���?������牟����������母�mulitthreading�墓���耶...
�������thread library��Mach's C threads,��POSIX pthreads.
Solaris����一��Kernel threads���,��一些����执��LWP,��些����一些系统��
����.
kernel thread�冉��写����应����取��interrupt
handler.��interrupt����时,kernel���圆�
��一��thread(����)���������interrupt.一��������re-entrant������
thread��scheduling��些��思,�������������������,也������趣,������.
Mach��Threads
Mach kernel�����������: task��thread.
Task�蔷�态�����,�啥�址�占��系统��源(port rights)����.
task�供��一��thread��执�谢���.
thread��Mach�幕�执�械�元.
Mach�供��cthread��式����������threads.
Mach 3.0 Continuation
Mach3.0��threads�母慕�������思,��为continuation,���������为��
��省stack��使��,��一��multi-threaded kernel��, thread越��(����:)
��stack space也���越��,亟����.
���碌某�式片�虾艹���,也��一��kernel thread��block��原��(也����
��要stack��时��.
syscall(args) {
... /* ����说,����DMA����一��disk block....*/
thread_block(); /* wait until completed */
process(args1);
return;
}
��� syscall block住�幕�,��要����一��stack����.要�强�����process()����要
�玫�stack��������系幕�,�蔷筒��帽���stack.��然����要��tail�����
�������static variable��.
����原��式�捅������:
syscall() {
...
thread_block(process);
/* not reached */
}
process() { /* ���沾���*/
...
thread_syscall_return(status);
}
省������stack��要����一����wake up��thread�蘸�也�歉�continuation,
����直�痈�����,省��一��cache/TLB misses.
Digital UNIX
������OSF/1�����Mach������tasks&threads实������UNIX�����Process����.
--
Buck barks in the darkness
--
Target Locked:Guru In Darkness.
��只��一只�������诺�狮�印�����
�� ��源:��UNIX��� www.tiaozhan.com/unixbbs/��[FROM: 202.114.36.175]
--
Only the Paranoid Survive!
Andrew S.Grove
[m[1;32m�� ��源:������未��站 bbs.pku.edu.cn��[FROM: 162.105.45.67][m