zoukankan      html  css  js  c++  java
  • 第二章 PROCESSES AND THREADS

    2019-06-17

    20:23:39

     In both UNIX and Windows systems, after a process is created, the parent and child have their own distinct address spaces 

    Again, no writable memory is shared.

     

    User process 3’s program counter, program status word, and sometimes one or more registers are pushed onto the (current) stack by the interrupt hardware. The computer then jumps to the address specified in the interrupt vector. That is all the hardware does.

     


    PROBLEMS


    1. In Fig. 2-2, three process states are shown. In theory, with three states, there could be six transitions, two out of each state. However, only four transitions are shown. Are there any circumstances in which either or both of the missing transitions might occur?

      The transition from blocked to running is conceivable. Suppose that a process is blocked on I/O and the I/O finishes. If the CPU is otherwise idle, the process could go directly from blocked to running. The other missing transition, from ready to blocked, is impossible. A ready process cannot do I/O or anything else that might block it. Only a running process can block.(第一种情况是可能发生的,从阻塞到运行,而第二种状态是不可能发生的(从就绪到阻塞))。

    可以想象从阻塞到运行的过渡。
    假设I / O上的进程被阻塞,I / O就完成了。
    如果CPU处于空闲状态,则该进程可以直接从阻塞状态转为运行状态。
    从准备到阻止的另一个缺失的过渡是不可能的。
    准备好的进程不能执行I / O或其他任何可能阻止它的进程。
    只有正在运行的进程才能阻止。


    2. Suppose that you were to design an advanced computer architecture that did process switching in hardware, instead of having interrupts. What information would the CPU need? Describe how the hardware process switching might work. (假设进程交换由硬件控制,代替由软件控制的中断)

    2. You could have a register containing a pointer to the current process-table entry. When I/O completed, the CPU would store the current machine state in the current process-table entry. Then it would go to the interrupt vector for the interrupting device and fetch a pointer to another process-table entry (the service procedure). This process would then be started up.

    2.您可以拥有一个包含指向当前进程表条目的指针的寄存器。
    当I / O完成时,CPU会将当前机器状态存储在当前进程表条目中。
    然后它将进入中断设备的中断向量并获取指向另一个进程表条目的指针(服务过程)。
    然后启动该过程。


     3. On all current computers, at least part of the interrupt handlers are written in assembly language. Why?(为什么一些中断处理是由汇编语言写?)

     Generally, high-level languages do not allow the kind of access to CPU hardware that is required. For instance, an interrupt handler may be required to enable and disable the interrupt servicing a particular device, or to manipulate data within a process’ stack area. Also, interrupt service routines must execute as rapidly as possible.

    通常,高级语言不允许访问所需的CPU硬件
    例如,可能需要中断处理程序来启用和禁用服务于特定设备的中断,或操纵进程堆栈区域内的数据。
    此外,中断服务程序必须尽快执行


  • 相关阅读:
    10 个深恶痛绝的 Java 异常。。
    为什么公司宁愿 25K 重新招人,也不给你加到 20K?原因太现实……
    推荐一款代码神器,代码量至少省一半!
    Spring Cloud Greenwich 正式发布,Hystrix 即将寿终正寝。。
    hdu 3853 LOOPS(概率 dp 期望)
    hdu 5245 Joyful(期望的计算,好题)
    hdu 4336 Card Collector(期望 dp 状态压缩)
    hdu 4405 Aeroplane chess(概率+dp)
    hdu 5036 Explosion(概率期望+bitset)
    hdu 5033 Building (单调栈 或 暴力枚举 )
  • 原文地址:https://www.cnblogs.com/JasonPeng1/p/11042002.html
Copyright © 2011-2022 走看看