MINIX ( 730000) ( 730000) MINIX MINIX2.0 MINIX : MINIX TP3 1 MINIX UNIX Tanenbaum UNIX MINIX LINUX MINIX MINIX MINIX1.0 UNIX V7 MINIX2.0[3] POSIX MINIX3 MINIX Gabriel A. Wainer 1994-1995 [5] 1998 I/O 2002 RT-MINIXv2 [6] MINIX2.0 MINIX2.0 MINIX MINIX MINIX 2 MINIX MINIX2.0 int nnn nnn 1983- E-mail:gongwb@yahoo.cn 1
06721 main() lock pick proc() restart() [2][4] MINIX2.0 2.1 minix2.0 GDT, IDT irq table[] CPU CPU CPU CPU (IDTR) idt[] CPU 06164 _hwint00:! Interrupt routine for irq 0 (the clock). 06165 hwint_master(0) src/kernel/mpx386.s hwint00 06140 06160 CPU CPU CPU idt[] CPU idt[] 07785 gate table[] 07873 for idt[] call save CPU 06160 restart save src/kernel/mpx386.s 06254 06262-06267 CPU minix CPU CPU ss esp proc[nr TASKS + NR PROCS] ss esp struct stackframe s p reg 04583 struct stackframe s... CPU idt[] hwint master hwint slave call save 06274 esp 06486 k stktop: 06267 push CPU stackframe s p reg 06268-06271 ds es MINIX k reenter 2
hwint slave() hwint master() call ( irq table + 4*irq) k reenter ( -1 06338 ) push restart hwint slave() hwint master() restart1 CPU restart1 jmp hwint slave() hwint master() push restart1 restart pop hwint master() hwint slave() 06152 call irq table[] ret restart restart1 CPU 06322 restart 06337 restart1 restart src/kernel/mpx386.s 06322 06329-06331 held head held tail unhold() interrupt() 06333 stackframe s p reg stackframe s I/O k reenter pop CPU proc ptr esp 4 iretd 2.2 int n (include/minix/type.h) proc[nr TASKS + NR PROCS] p nr CPU int SYS386 VECTOR idt[] SYS386 VECTOR 07765 prot init() 07882 int_gate(sys386_vector, (phys_bytes) (vir_bytes) s_call, 07883 PRESENT (USER_PRIVILEGE << DPL_SHIFT) INT_GATE_TYPE); s call int gate() idt[] int gate() idt[] CPU s call 06288 s call: 06306 save CPU call sys call push C sys call() C 06315 restart: proc ptr 3
2.3 07785 gate table[] 07786-07801 06348!* exception handlers 06350 06412 CPU idt[] 06350 06412 06350 _divide_error: 06351 push DIVIDE_VECTOR 06352 jmp exception exception: errexception: 06420 exception C exception() CPU restart ret C exception() panic() wreboot() MINIX2.0 C exception() call save restart: ret restart: 3 MINIX 3.1 MINIX Table 1 MINIX MINIX MINIX I/0 I/0 I/0 I/0 MINE MINIX MINIX MINIX Table 2 Table 3 MINIX Table 2 xtint() xtsave xtstart 4
I/O Table 1: init (mm) (fs) (nets) I/O Table 2: MINIX 1 init (mm) (fs) (nets) I/O Table 3: MINIX 2 init (mm) (fs) (nets) NR TASKS include/minix/config.h 02680 #define ENABLE_XT_TASKS 1 include/minix/const.h 02953 NR TASKS #define NR_TASKS (9 + ENABLE_WINI + ENABLE_SCSI + ENABLE_CDROM \ + ENABLE_NETWORKING + 2 * ENABLE_AUDIO+ENABLE_XT_TASKS) src/kernel/proc.h EXTERN struct proc *xtproc = proc[nr_tasks]; xtproc src/kernel/mpx386.s xtint() xtsave xtstart Table 4 xtint() src/kernel/mpx386.s 06188 06189 _hwint06: xtint()! Interrupt routine for irq 6 (RT_Task) CPU xtint() 5
Table 4: define xtint() \ xtsave: xtstart: cli cld mov esp, xtproc call xtsave pushad lldt P LDT SEL(esp) ret o16 push ds lea eax, P STACKTOP(esp) o16 push es o16 push fs o16 push gs mov dx, ss mov ds, dx mov es, dx mov ( tss+tss3 S SP0), eax o16 pop gs o16 pop fs o16 pop es o16 pop ds popad mov eax, esp add esp, 4 mov esp, k stktop push xtstart xor ebp, ebp jmp RETADR-P STACKBASE(eax) iretd xt task() src/kernel/ include/minix/com.h 03516 #define XT (TTY - ENABLE_XT_TASKS) src/kernel/table.c 05676 #define XT_STACK SMALL_STACK src/kernel/table.c main() 05699 tasktab[] tty task #if ENABLE_XT_TASKS { xt_task, XT_STACK, "XT" }, #endif makefile 3.2 1. PC MINIX2.0 MINIX 2. MINIX2.0 MINIX2.0 MINIX MINIX 6
MINIX indows Vmware Workstation Linux Bochs[1] 4 MINIX MINIX MINIX MINIX MINIX2.0 [1] Linux 0.11 V2.0 www.oldlinux.org [2] 80386 [3] ( )Tanenbaum,Andrew S. ( )Woodhull,Albert S. [4] 80X86 [5] Gabriel A. Wainer, Implementing Real-Time services in MINIX, ACM Operating Systems Review, July 1995. [6] Pessolani, Pablo A, RT-MINIXv2: Architecture and Interrupt Handling, 33th JAIIO, Argentine Symposium on Computing Technology (AST2004), 2004. MINIX Operating System s Interrupt Mechanism Analysis And Real-time Extensions Gong Weibing Zhu Wenjun (School of Mathematics and Statistics, Lanzhou University, Lanzhou, 730000, China) (School of Mathematics and Statistics, Lanzhou University, Lanzhou, 730000, China) Abstract: MINIX is a teaching-oriented operating system.it is the first completely free source code provided for public.due to this strong point,it is very convenient to study OS for us.and we can also understand OS s fundamental principle more profoundly through studying the source code.it s layered structure is very simple and basic for an OS.We will analyze the source code to interpret MINIX2.0 OS s interrupt mechanism,including hardware interrupt,soft interrupt and exception.and we will also supply the method extended a real-time task. Keywords: MINIX OS Interrupt Mechanism Hardware Interrupt Soft Interrupt Exception Realtime Extensions Real-time Task 7