zoukankan      html  css  js  c++  java
  • Operation System Concepts Ch.3 Process

    Basic Concepts

    Policy: time-sharing (context switch) + scheduling

    jobs (for batch), user programs or tasks (for time-shared systems)

    Process: a program in execution

    Parts: text section, program counter, stack, data section, heap

    Program is passive, process is active (program becomes process when loaded)

    States: new, running, waiting, ready, terminated

    PCB: data structure for process, track the state of process

    Executing and Switching

    Direct Execution: we need protection (dual mode and system call) and time sharing (context switch)

    Limited Direct Execution:

    OS: create entry
    OS: allocate memory, load program, set up stack
    OS: fill kernel stack
    return from trap, move to user mode
    Program: run main()
    Program: call system call
    Hardware: save regs to kernel stack
    Hardware: move to kernel mode, jump to handler
    OS: handle trap
    return from trap
    restore regs from kernel stack
    move to user mode
    jump to PC after trap
    ...
    

    Time-sharing: switch between processes, via timer interrupt

    Proc A
    H:  timer interrupt
    H:  save regsA to kstackA
    H:  move to kernel mode
    H:  jump to timer handler
    OS: save regsA to PCBA
    OS: restore regsB from PCBB
    OS: switch to kstackB
    H:  restore regsB from kstackB
    ...
    Proc B
    

    Reg saves/restores

    timer interrupt: user regs are implicitly saved by hardware into kstack

    **os switch: kernel **regs are explicitly saved by OS into PCB

    Scheduling

    scheduling: job queue, ready queue, device queues

    CPU scheduler, job shceduler, medium-term scheduler

    Operations

    Parent process create children, form a tree, pid

    Child duplicate address space of parent, may has a program loaded into it

    fork() creates new process, and exec() replace memory space with a new program, abort() to terminate

    cascading termination: all succ are terminated

    wait() to wait it finish, no parent waiting as zombie, parent terminated without wait and then become orphan

    InterProcess Communication

    Shared memory: under control of user processes, not os

    Message Passing: send and receive, blocking/non-blocking

    MP is useful for small ones, easier to implement in distributed system

    SM is faster (less use of syscall), but SM suffers from cache coherency, so in multiprocessor system, MP may be better

    now MP is preferred

    etc

    socket: endpoint for communication

    RPC: abstracts procedure calls betweeen processes on network systems

    Pipes: a buffer, ordinary/named

  • 相关阅读:
    CentOS 下实现两台服务器之间的共享NFS
    CentOS 下安装无线哥的老爷机DELL的无线驱动
    PHP 如何读取一个1G的文件大小
    php 经典的算法题你懂的
    mongodb与mysql命令对比
    TCP协议的三次握手和四次挥手过程
    java 发送带Basic Auth认证的http post请求实例代码
    HTTP基本认证(Basic Authentication)的JAVA实例代码
    Http协议
    MySQL主从同步那点事儿
  • 原文地址:https://www.cnblogs.com/mollnn/p/14701218.html
Copyright © 2011-2022 走看看