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

  • 相关阅读:
    Could not autowire. No beans of 'TbItemMapper' type found. less... (Ctrl+F1) Checks autowiring prob
    使用IntelliJ IDEA创建Maven聚合工程、创建resources文件夹、ssm框架整合、项目运行一体化
    IntelliJ IDEA Ultimate 下载与安装
    Android Studio 下载与安装配置
    MySQL Community Server 8.0.11下载与安装配置
    Eclipse EE下载安装与配置
    Tomcat 下载安装与配置
    篮球术语
    GPU对数据的操作不可累加
    经典把妹桥段:Flower dance开头对话
  • 原文地址:https://www.cnblogs.com/mollnn/p/14701218.html
Copyright © 2011-2022 走看看