zoukankan      html  css  js  c++  java
  • GNU make manual 翻译( 一百三十八)

    继续翻译

    5.4 Parallel Execution
    ======================

    GNU `make' knows how to execute several recipes at once. Normally,
    `make' will execute only one recipe at a time, waiting for it to finish
    before executing the next. However, the `-j' or `--jobs' option tells
    `make' to execute many recipes simultaneously. You can inhibit
    parallelism in a particular makefile with the `.NOTPARALLEL'
    pseudo-target (*note Special Built-in Target Names: Special Targets.).

    On MS-DOS, the `-j' option has no effect, since that system doesn't
    support multi-processing.

    If the `-j' option is followed by an integer, this is the number of
    recipes to execute at once; this is called the number of "job slots".
    If there is nothing looking like an integer after the `-j' option,
    there is no limit on the number of job slots. The default number of job
    slots is one, which means serial execution (one thing at a time).

    One unpleasant consequence of running several recipes simultaneously
    is that output generated by the recipes appears whenever each recipe
    sends it, so messages from different recipes may be interspersed.

    Another problem is that two processes cannot both take input from the
    same device; so to make sure that only one recipe tries to take input
    from the terminal at once, `make' will invalidate the standard input
    streams of all but one running recipe. This means that attempting to
    read from standard input will usually be a fatal error (a `Broken pipe'
    signal) for most child processes if there are several.

    It is unpredictable which recipe will have a valid standard input
    stream (which will come from the terminal, or wherever you redirect the
    standard input of `make'). The first recipe run will always get it
    first, and the first recipe started after that one finishes will get it
    next, and so on.

    5.4 并行执行
    ======================

    GNU make 知道如何马上执行几个片段。通常,make 将一次只执行一个片段,等它执行完毕了,才执行下一个。但是-j 或者 --jobs 选项告诉make 去同时执行多个片段。你可以通过 .NOPARALLEL 伪目的来在特定的makefile中禁止 并发性。 (*note Special Built-in Target Names: Special Targets.)

    在MS-DOS 系统, -j 选项没有效果,因为此系统不支持多任务处理。

    如果-j 选项后面跟着一个整数,那么这个数代表可以同时执行的片段数目; 被称为 任务槽数。

    如果没有 -j 选项的数值,那么对任务槽没有数目限制。任务槽的缺省值是1,意味着串行执行。

    有一个不好的事情是,当几个片段并行运行的时候,各个片段产生的输出会各自输出,导致输出的信息看其俩有些混乱。

    另一个问题是,两个处理不能从一个设备上互为输入;因此要确认只有一个片段一次要从终端取得一次输入,make 会只保留一个运行片段的输入流而禁止其它的。这意味着,对于众多的子进程而言,想要从标准输入中读数据会造成严重错误(一个破坏的管道信号)。

    对于哪一个片段将要获得有效的输入流(来自于终端或者被你所重定向)是无法精确的。第一个片段将要总是先获得它,然后下一个片段再获得,依次类推。

    后文待续

  • 相关阅读:
    Moss2010 部署命令
    socket形象描述
    Android UI 的更新
    android AIDL 进程间通信
    中文设置成粗体的方法
    android 主件之 Service
    android activity
    拦截Activity的后退键处理
    android 解析json数据格式
    防止事件导致的oncreate的多次调用
  • 原文地址:https://www.cnblogs.com/gaojian/p/2708899.html
Copyright © 2011-2022 走看看