Minix Learning

  • View
    604

  • Download
    0

Embed Size (px)

Text of Minix Learning

  • MINIX Learning MINIX

  • ML == MINIX Learning

    MirBSD Learning ;-)

    MINIX

  • MirBSD?

    NetBSDOpenBSDOS

    MBSD

  • 2

    Tanenbaum MINIX(2)

    Virtual BoxMINIX

  • MINIX 5

  • MINIX 5

    (90x15)

  • OS(1)

    MINIX(2)

    MINIX(3)

    MINIX(4)

    (5)

  • 1. MINIX

    UNIXTanenbaumUNIXOS

    >

  • OS

    ,

    ,

  • , ,

  • BRK

    FFFF

    0000

    [] A.S.Tanenbaum MINIX1-11

  • A

    B

    C

    D

    [] A.S.Tanenbaum MINIX2-1(c)

  • OS =>

  • ,

  • ()

    OS()

    OS

    [] A.S.Tanenbaum MINIX1-16

  • MINIX

    [] A.S.Tanenbaum MINIX2-26

    Tty

    init

    4

    3

    2

    1

  • MINIX

    [] A.S.Tanenbaum MINIX2-26

    Tty

    init

    4

    3

    2

    1

  • MINIX

    [] A.S.Tanenbaum MINIX2-26

    Tty

    init

    4

    3

    2

    1

  • MINIX

    [] A.S.Tanenbaum MINIX2-26

    Tty

    init

    4

    3

    2

    1

  • MINIX

    [] A.S.Tanenbaum MINIX2-26

    Tty

    init

    4

    3

    2

    1

  • MINIX

    [] A.S.Tanenbaum MINIX2-26

    Tty

    init

    4

    3

    2

    1

    FORK, BRK

    MOUNT, READ

  • MINIX

    [] A.S.Tanenbaum MINIX2-26

    Tty

    init

    4

    3

    2

    1

    , ,

  • 2. MINIX

    ROM

    [] A.S.Tanenbaum MINIX2-31(a)

  • 512Bboot

    512 [B] 512 [B]

    1 [KB]

    2boot

    bootOS

    /minix/minix/

  • 16 [bit]32 [bit]MINIX

    mpx88.smpx386.s

    #include #if _WORD_SIZE == 2 #include mpx88.s #else #include mpx386.s #endif

  • mpx386.s

    32 bit CPU

    C

  • Ccstart

    push edx push ebx push SS_SELECTOR push MON_CS_SELECTOR push DS_SELECTOR push CS_SELECTOR call _cstart

    cstart32bit

    OS

  • main.c

    restart()main

  • restart() mpx386.s

    MINIX

    proc_ptr

    proc[NR_TASKS+INIT_PROC_NR].p_pid = 1; bill_ptr = proc_addr(IDLE); lock_pick_proc();

    /* */ restart();

  • init initgetty

    getty:

    gettylogin

    login:

    login

    init

    getty

    login

    tcsh

    lsvimpwd

  • 3. MINIX

    [] A.S.Tanenbaum MINIX2-26

    Tty

    init

    4

    3

    2

    1

  • ,

  • , USB

  • UNIX

    UNIX

    UNIX

    [] A.S.Tanenbaum MINIX3-14(b)

  • MINIX

    [] A.S.Tanenbaum MINIX3-14(a)

  • PUBLIC void driver_task(dp) struct driver *dp; { int r, caller, proc_nr; message mess; () while(TRUE) { receive(ANY, &mess); caller = mess.m_source; proc_nr = mess.PROC_NR; () switch(mess.m_type) { case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break; case DEV_CLOSE: r = (*dp->dr_close)(dp, &mess); break; () default: r = EINVAL; break; } () mess.m_type = TASK_REPLAY; mess.REP_PROC_NR = proc_nr;

    mess.REP_STATUS; send(caller, &mess); } }

  • struct driver { _PROTOTYPE( char *(*dr_name), (void) ); _PROTOTYPE( int (*dr_open), (struct driver *dp, message *m_ptr) ); _PROTOTYPE( int (*dr_close), (struct driver *dp, message *m_ptr) ); _PROTOTYPE( int (*dr_ioctl), (struct driver *dp, message *m_ptr) ); _PROTOTYPE( struct device *(*dr_prepare), (int device) ); _PROTOTYPE( int (*dr_schedule), (int proc_nr, struct iorequest_s) *request ); _PROTOTYPE( int (*dr_finish), (void)); _PROTOTYPE( void (*dr_cleanup), (void) ); _PROTOTYPE( void (*dr_geometry), (struct partition *entry) );

    };

  • 4. MINIX

    OS

  • [] A.S.Tanenbaum MINIX4-3

    OS

    A

    OS

    A

    B

    OS

    A

    B

    C

    OS

    B

    C

    OS

    B

    C

    D

  • 216043XXX5X7XXXX

    0K-4K4K-8K8K-12K12K-16K16K-20K20K-24K24K-28K28K-32K

    0K-4K4K-8K8K-12K12K-16K16K-20K20K-24K24K-28K28K-32K32K-36K36K-40K40K-44K44K-48K48K-52K52K-56K56K-60K60K-64K

    [] A.S.Tanenbaum MINIX4-8

  • MINIX

    IBMCPU

  • MINIX

  • IBM

    80386, 80486, Pentium

    IBM CPU

  • MINIX

    FORK

    EXEC

  • MINIX

    MINIX

    A

    B

    MINIX

    A

    B

    A

    MINIX

    A

    B

    C

    [] A.S.Tanenbaum MINIX4-32

  • 5. MINIX

    OS

    OS

    ()

  • ==>

  • ASCII,

    :

  • ASCII

    OS

    OS

    1 byte

  • ==

    i

  • 1K4KB4

  • 4 5 9

    2 14

    0

    1

    2

    3

    4

  • MS-DOS

    012 1434 55 96789 21011121314 015

    start

  • i

    i

    i

    i

  • i

    i 1KB1KB

    1KB

    1KB

    1KB

    1KB

    1KB

    1KB

    1KB

    1KB

    1KB

    1KB

    1KB

    1KB

  • MINIX i

    (rwx)()

    uid(ID)gid()

    ()

    0

    1

    2

    3

    4

    5

    6

    ()

    256 256 x 256 = 65536 [KB] = 64 [MB]

  • MINIXOS

    OS

    , i