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

  • 相关阅读:
    schema文件中cube的事实表使用视图方法
    Saiku国际化总结
    saiku安装方法总结
    MySQL中的datetime与timestamp比较(转载)
    js中的刷新方法
    如何用 Node.js 和 Elasticsearch 构建搜索引擎
    Win7搭建NodeJs开发环境以及HelloWorld展示—图解
    NodeJS开发环境搭建
    从零开始nodejs系列文章
    windows 下安装nodejs及其配置环境
  • 原文地址:https://www.cnblogs.com/mollnn/p/14701218.html
Copyright © 2011-2022 走看看