+ All Categories
Home > Documents > MINIX3 Processes

MINIX3 Processes

Date post: 30-May-2018
Category:
View: 217 times
Download: 0 times
Share this document with a friend

of 118

Transcript
  • 8/14/2019 MINIX3 Processes

    1/118

    : :

    Email: [email protected] :http://ccc.kmit.edu.tw

    : 01/17/10

    2. Processes

    mailto:[email protected]://ccc.kmit.edu.tw/http://ccc.kmit.edu.tw/mailto:[email protected]
  • 8/14/2019 MINIX3 Processes

    2/118

    2.1. Introduction to Processes

    2.1.1. The Process Model

    2.1.2. Process Creation

    2.1.3. Process Termination 2.1.4. Process Hierarchies

    2.1.5. Process States

    2.1.6. Implementation of Processes 2.1.7. Threads

    2 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    3/118

    2.1 The Process Model

    3 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    4/118

    2.1.2 Process Creation

    4 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    5/118

    2.1.3 Process Termination

    5 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    6/118

    2.1.4 Process Hierarchy

    6 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    7/118

    2.1.5 Process States

    7 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    8/118

    2.1.6 Implementation of

    Processes

    8 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    9/118

    9 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    10/118

    2.1.7 Threads

    10 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    11/118

    11 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    12/118

    12 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    13/118

    2.2. Interprocess

    Communication

    2.2.1. Race Conditions

    2.2.2. Critical Sections

    2.2.3. Mutual Exclusion with Busy Waiting 2.2.4. Sleep and Wakeup

    2.2.5. Semaphores

    2.2.6. Mutexes 2.2.7. Monitors

    2.2.8. Message Passing

    13 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    14/118

    2.2.1 Race Conditions

    14 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    15/118

    2.2.2 Critical Section

    15 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    16/118

    2.2.3 Mutual Exclusion with

    Busy Waiting

    Disabling Interrupts

    Lock Variables

    Strict AlternationPetersons Solution

    The TSL instruction

    16 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    17/118

    Disabling Interrupts

    17 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    18/118

    Lock Variables

    18 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    19/118

    Strict Alternation

    19 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    20/118

    Petersons Solution

    20 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    21/118

    The TSL instruction

    21 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    22/118

    2.2.4 Sleep and Wakeup

    22 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    23/118

    The Producer-Consumer

    Problem

    23 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    24/118

    2.2.5 Semaphores

    24 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    25/118

    Consumer Problem using

    Semaphores

    25 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    26/118

    2.2.6. Mutexes

    26 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    27/118

    2.2.7. Monitors

    27 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    28/118

    Consumer Problem using

    Monitor (1)

    28 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    29/118

    Consumer Problem using

    Monitor (2)

    29 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    30/118

    2.2.8. Message Passing

    30 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    31/118

    2.3. Classical IPC Problems

    2.3.1. The Dining Philosophers Problem

    2.3.2. The Readers and Writers Problem

    31 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    32/118

    . . .Philosophers Problem

    (DPP)

    32 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    33/118

    A nonsolution to DPP

    33 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    34/118

    A solution to DPP (1)

    34 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    35/118

    A solution to DPP (2)

    35 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    36/118

    2.3.2. The Readers and

    Writers Problem

    36 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    37/118

    2.4. Scheduling

    2.4.1. Introduction to Scheduling

    2.4.2. Scheduling in Batch Systems

    2.4.3. Scheduling in Interactive Systems 2.4.4. Scheduling in Real-Time Systems

    2.4.5. Policy versus Mechanism

    2.4.6. Thread Scheduling

    37 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    38/118

    2.4.1. Introduction to

    Scheduling

    Process Behavior

    When to Schedule

    Categories of Scheduling AlgorithmsScheduling Algorithm Goals

    38 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    39/118

    Process Behavior

    39 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    40/118

    Scheduling Algorithm

    Goals

    40 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    41/118

    2.4.2. Scheduling in Batch

    Systems

    First-Come First Served

    Shortest Job First

    Shortest Remaining Time Next Three-Level Scheduling

    41 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    42/118

    First-Come First Served

    42 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    43/118

  • 8/14/2019 MINIX3 Processes

    44/118

    Shortest Remaining Time

    Next

    44 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    45/118

    Three-Level Scheduling

    45

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    46/118

    2.4.3. Scheduling in

    Interactive Systems

    Round-Robin Scheduling

    Priority Scheduling

    Multiple QueuesShortest Process Next

    Guaranteed Scheduling

    Lottery Scheduling Fair-Share Scheduling

    46

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    47/118

  • 8/14/2019 MINIX3 Processes

    48/118

    Priority Scheduling

    48

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    49/118

    Multiple Queues

    49

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    50/118

    Shortest Process Next

    50

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    51/118

    Guaranteed Scheduling

    51

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    52/118

    Lottery Scheduling

    52

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    53/118

    Fair-Share Scheduling

    53

    - 01/17/10

    2 4 4 S h d li i R l

  • 8/14/2019 MINIX3 Processes

    54/118

    2.4.4. Scheduling in Real-

    Time Systems

    54

    - 01/17/10

    2 4 5 P li

  • 8/14/2019 MINIX3 Processes

    55/118

    2.4.5. Policy versus

    Mechanism

    55

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    56/118

    2 5 O i f P

  • 8/14/2019 MINIX3 Processes

    57/118

    2.5. Overview of Processes

    in MINIX 3

    2.5.1. The Internal Structure of MINIX 3

    2.5.2. Process Management in MINIX 3

    2.5.3. Interprocess Communication in MINIX 3

    2.5.4. Process Scheduling in MINIX 3

    57

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    58/118

    2 5 2 Process Management

  • 8/14/2019 MINIX3 Processes

    59/118

    2.5.2. Process Management

    in MINIX 3

    59

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    60/118

    Minix Startup

    60

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    61/118

    Initialization of the Process

  • 8/14/2019 MINIX3 Processes

    62/118

    Initialization of the Process

    Tree

    62

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    63/118

  • 8/14/2019 MINIX3 Processes

    64/118

    2 6 Implementation of

  • 8/14/2019 MINIX3 Processes

    65/118

    2.6. Implementation of

    Processes in MINIX 3

    2.6.1. Organization of the MINIX 3 Source Code

    2.6.2. Compiling and Running MINIX 3

    2.6.3. The Common Header Files

    2.6.4. The MINIX 3 Header Files

    2.6.5. Process Data Structures and Header Files 2.6.6. Bootstrapping MINIX 3

    2.6.7. System Initialization

    2.6.8. Interrupt Handling in MINIX

    2.6.9. Interprocess Communication in MINIX 3 2.6.10. Scheduling in MINIX 3

    2.6.11. Hardware-Dependent Kernel Support

    2.6.12. Utilities and the Kernel Library

    65

    - 01/17/10

    2 6 1 Organization of the

  • 8/14/2019 MINIX3 Processes

    66/118

    2.6.1. Organization of the

    MINIX 3 Source Code

    66

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    67/118

    MINIX (1) boot/ : (addaout.c, boot.c/h, bootlock.s, boothead.s, bootimage.c,

    doshead.s, image.h, installboot.c, jumpboot.s, masterboot.s, mkfhead.s,

    mkfile.c, rawfs.c/h

    kernel/ : (clock.c, config.c/h, debug.c/h, exception.c, glo.h, i8259.c,

    ipc.h, kernel.h, klib88.s, klib386.s, klib.s, main.c, mpx88.s, mpx386.s,

    mpx.s, priv.h, proc.c/h, protect.c/h, proto.h, sconst.h, start.c, system.c,

    table.c, type.h, utility.c,

    system/ : do_xx , (do_abort.c, do_copy.c, dodevio.c, do_endksig.c, do_exec.c, do_exit.c, do_fork.c, do_getinfo.c, do_getksig.c, do_int86.c, do_iopenable.c,

    do_irqctl.c, dodo_exec.c, do_fork.c, do_kill.c, do_memset.c, do_newmap.c,

    do_nice.c, do_privctl.c, do_sdevio.c, do_segctl.c, do_setalarm.c,

    do_sigreturn.c, do_sigend.c, do_times.c, do_trace.c, do_umap.c,

    do_unused.c, do_vcopy.c, do_vdevio.c)

    67

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    68/118

  • 8/14/2019 MINIX3 Processes

    69/118

    MINIX (3) init/ : init.c , Process Father Process.

    is/ : information server, dump.(dump.c, dmp_ds.c, dmp_fs.c, dmp_kernel.c,

    dmp_pm.c, dmp_rs.c, glo.h, inc.h, is.h, main.c, proto.h)

    pm/ : Process Management, (alloc.c, break.c, const.h, exec.c, forkexit.c, getset.c,

    glo.h, main.c, misc.c, mproc.h, param.h, pm.h, proto.h, signal.c, table.c,

    time.c, timers.c,trace.c, type.h, utility.c

    rs/ : Reincarnation( ) Server, (inc.h, main.c, manager.c/h, proto.h, service.c)

    sm/ : System Process Manager, ( *.c makefile)

    69

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    70/118

    MINIX (4) drivers/ : IO (drivers.h)

    at_wini/ : driver for the IBM-AT winchester controller.

    bios_wini/: hard disk driver that uses the ROM BIOS.

    cmos/ : access the CMOS chip to get or set the system time.

    dp8390/ : Ethernet device driver for NS dp8390 based ethernet cards. (dp8390.c, ne2000.c, rtl9029.c, wdeth.c)

    dpeth/ : Ethernet device driver for 3Com Etherlink (3c501) boards, 3c501.c, 3c503.c,

    3c509.c, 8390.c, devio.c, dp.c, ne.c, netbuff.c, wd.c,

    floppy/ : Floppy Disk Driver, floppy.c

    fxp/ : Ethernet device driver for Intel 82557, 82558, 82559, 82550, and 82562 fast ethernet controllers. : fxp.c ( ), mii.c ( )

    lance/ : Ethernet driver for AMD LANCE based ethernet cards. (lance.c)

    libdriver/: Device Independent Device Driver Interface. (driver.c, drvlib.c)

    libpci/ : PCI (pci.c, pci_table.c, pci_amd.h, pci_intel.h, pci_via.h, pci.h)

    log/ : system log device (log.c, diag.c, kput.c)

    memory/ : (memory.c)

    printer/: printer driver. It is a fairly simple driver,supporting only one printer.

    Characters that are written to the driver are written to the printer without

    any changes at all.

    random/ : random number generator, (main.c, random.c, sha2.c)

    rescue/ : rescue device driver (rescue.c)

    rtl8138/ : device driver for Realtek rtl8139 based ethernet cards.

    sb16/ : driver for a DSP (Digital Sound Processor) on a SoundBlaster 16 soundcard.

    tty/ : terminal driver (tty.c, rs232.c, pty.c, keyboard.c, console.c, vidcopy.c)

    70

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    71/118

    MINIX (5) tools/ : (Makefile, mkboot, tell_config)

    include/ : *.h (a.out.h, alloca.h, ansi.h, assert.h, configfile.h, ctype.h, courses.h,

    dirent.h, env.h, errno.h, fcntl.h, float.h, grp.h, inttype.h, lib.h, libgen.h,

    libutil.h, limits.h, locale.h, math.h, mathconst.h, netdb.h, pwd.h, regex.h,

    regexp.h, setjmp.h, sgtty.h, signal.h, stdarg.h, stddef.h, stdint.h, stdio.h,

    stdlib.h, string.h, tar.h, termcap.h, termios.h, time.h, timers.h, tools.h, ttyent.h,

    unistd.h, utime.h, utmp.h)

    arpa/ : inet.h ibm/ : bios.h, cmos.h, cpu.h, diskparm.h, int86.h, interrupt.h, memory.h, partition.h,

    portio.h, ports.h

    minix/ : bitmap.h, callnr.h, cdrom.h, com.h, config.h, const.h, devio.h, dl_eth.h, dmap.h,

    fslib.h, ioctl.h, ipc.h, jmp_buf.h, keymap.h, minlib.h, partition.h, paths.h,

    sound.h, swap.h, sys_config.h, syslib.h, sysutil.h, type.h, u64.h,

    71

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    72/118

    MINIX (6) net/ : hton.h, if.h, ioctl.h, netlib.h

    gen/ : arp_io.h, dhcp.h, eth_hdr.h, eth_io.h, ether.h, icmp.h, icmp_hdr.h, if_ether.h,

    in.h, inet.h, ip_hdr.h, ip_io.h, nameser.h, netdb.h, oneCsum.h, psip_hdr.h,

    psip_io.h, resolv.h, rip.h, route.h, socket.h, tcp.h, tcp_hdr.h, tcp_io.h, udp.h,

    udp_hdr.h, udp_io.h, vjhc.h

    netinet/ : in.h, tcp.h

    sys/ : asynchio.h, dir.y, file.h, ioc_cmos.h, ioc_disk.h, ioc_file.h, ioc_memory.h,

    ioc_scsi.h, ioc_sound.h, ioc_tape.h, ioc_tty.h, ioctl.h, mtio.h, param.h, ptrace.h, resource.h, select.h, sigcontext.h, socket.h, stat.h, statfs.h, svrctl.h, time.h,

    types.h, uio.h, un.h, utsname.h, wait.h

    72

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    73/118

    2.6.2. Compiling and Running MINIX 3

    Rebuild MINIX Operating System cd /usr/src/tools/

    make

    Make Bootable image su

    make clean

    time make image

    Make bootable floppy make fdboot

    type fd0 when you are asked to complete the path.

    73

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    74/118

    Memory Layout

    74

    - 01/17/10

  • 8/14/2019 MINIX3 Processes

    75/118

    2.6.3. The Common Header Files

    75 - 01/17/10

    0~ 6200 Header File

  • 8/14/2019 MINIX3 Processes

    76/118

    Data Type Size

    76 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    77/118

    2.6.4. The MINIX 3 Header Files

    77 - 01/17/10

    Seven Message Type used

  • 8/14/2019 MINIX3 Processes

    78/118

    Seven Message Type used

    in MINIX

    78 - 01/17/10

    2 6 5 P D t St t d

  • 8/14/2019 MINIX3 Processes

    79/118

    2.6.5. Process Data Structures and

    Header Files

    Discriptor table Define how system resources are used and prevent process from accessing

    memory assigend to other processes.

    GDT : Global Descriptor Table

    LDT : Local Descriptor Table

    IDT : Interrupt Descriptor Table

    79 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    80/118

    Privilege Table

    80 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    81/118

    2.6.6. Bootstrapping MINIX 3

    Boot Process : SEC 2.6, page 155.

    When the system is started, the hardware (actually, a program in ROM) reads the

    first sector of the boot disk, copies it to a fixed location in memory, and executes

    the code found there.

    On an unpartitioned MINIX3 diskette, the first sector is a bootblock which loads

    the boot program, as in Fig. 2-36(a).

    Hard disk are partitioned, and the program on the first sector (called master boot

    on MINIX sytems) first relocates itself to a different memory region, the reads the

    partition table, loaded with it from the first sector. Then it load and executes thefirst sector of the active partition, as shown in Fig. 2-36(b).

    Boot block : The first sector (512 byte).

    81 - 01/17/10

    Disk Structure for

  • 8/14/2019 MINIX3 Processes

    82/118

    Disk Structure for

    Bootstrapping

    82 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    83/118

    Making boot program

    The MINIX 3 boot sector is modified at the time it is written to the

    disk by a special program called installboot which writes the boot

    sector and patches into it the disk address of a file named boot on

    its partition or subpartition

    In MINIX 3, the standard location for the boot program is in a

    directory of the same name, that is, /boot/boot. But it could be

    anywhere the patching of the boot sector just mentioned locates

    the disk sectors from which it is to be loaded. This is necessary

    because previous to loading boot there is no way to use directory

    and filenames to find a file.

    83 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    84/118

    Boot Parameters

    84 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    85/118

  • 8/14/2019 MINIX3 Processes

    86/118

    2.6.7. System Initialization

    86 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    87/118

    8088 or 80386 ?

    87 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    88/118

    2.6.8. Interrupt Handling in MINIX

    88 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    89/118

    Interrupt V.S. System Call

    89 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    90/118

    8259 Interrupt Controller

    90 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    91/118

    System Startup - Restart

    91 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    92/118

  • 8/14/2019 MINIX3 Processes

    93/118

    93 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    94/118

    2.6.10. Scheduling in MINIX 3

    94 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    95/118

    Process Queue

    95 - 01/17/10

    2 6 11 Hardware-Dependent Kernel

  • 8/14/2019 MINIX3 Processes

    96/118

    2.6.11. Hardware-Dependent Kernel

    Support

    96 - 01/17/10

    2 6 12 Utilities and the Kernel

  • 8/14/2019 MINIX3 Processes

    97/118

    2.6.12. Utilities and the Kernel

    Library

    97 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    98/118

    2.7. The System Task in

  • 8/14/2019 MINIX3 Processes

    99/118

    y

    MINIX 3

    2.7.1. Overview of the System Task

    2.7.2. Implementation of the System Task

    2.7.3. Implementation of the System

    Library

    99 - 01/17/10

    2.7.1. Overview of the

  • 8/14/2019 MINIX3 Processes

    100/118

    System Task

    100 - 01/17/10

    Message types accepted by

  • 8/14/2019 MINIX3 Processes

    101/118

    the system task. (1)

    101 - 01/17/10

    Message types accepted by

  • 8/14/2019 MINIX3 Processes

    102/118

    the system task. (2)

    102 - 01/17/10

    2.7.2. Implementation of the

  • 8/14/2019 MINIX3 Processes

    103/118

    System Task

    103 - 01/17/10

    2.7.3. Implementation of the

  • 8/14/2019 MINIX3 Processes

    104/118

    System Library

    104 - 01/17/10

    How many message

  • 8/14/2019 MINIX3 Processes

    105/118

    passing per read required ?

    105 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    106/118

  • 8/14/2019 MINIX3 Processes

    107/118

    2.8.1. Clock Hardware

    107 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    108/118

    108 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    109/118

  • 8/14/2019 MINIX3 Processes

    110/118

    110 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    111/118

    111 - 01/17/10

    2.8.3. Overview of the Clock Driver

  • 8/14/2019 MINIX3 Processes

    112/118

    in MINIX 3

    The Clock Task

    The Clock Interrupt Handler

    Watchdog Timers

    Millisecond Timing

    Summary of Clock Services

    112 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    113/118

    The Clock Task

    113 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    114/118

  • 8/14/2019 MINIX3 Processes

    115/118

    Watchdog Timers

    115 - 01/17/10

  • 8/14/2019 MINIX3 Processes

    116/118

  • 8/14/2019 MINIX3 Processes

    117/118

  • 8/14/2019 MINIX3 Processes

    118/118


Recommended