Python - Concurrent Programming: Fundamentals

9.1 Process Fundamentals

  1. What is the procedure -? Program is a pile of files.

  2. What is the process? - File / program process is being executed is a resource unit (abstract concept)

  3. Process execution by whom -? CPU final run the program.

    The role of the operating system scheduler, the program is loaded into memory on the disk, and then handed to the CPU for processing. A CPU running a program, a process called open

9.1.1 Operating System

  1. Operating System Definition

    The operating system is present between hardware and software, management, coordination and control the interaction of software and hardware.

  2. The role of the operating system (the interview will ask)

    1. The complex hardware interfaces encapsulated into operation, ease of use.
    2. Reasonable relationship of multiple processes and CPU scheduling assignments of ordering allowed

    If there is no operating system, you are to write a program, you can simply complete two.

    • First layer: you have to learn the underlying hardware: cpu, memory, disk use is how it works.
    • Second layer: to call these underlying hardware.

9.1.2 History of operating systems (multi-channel technology)

Computer: Mechanical computer (Abacus)

Computer: the history of

  1. The first generation of computers: 1940-1955

    World War II: Release computer, manual operation, reservation, line interpolation procedure similar to the plate, into the room, a person using various hardware operating in conjunction with Plug your program.

    Features: There is no concept of the operating system, all hardware connections are yourself

    Pros: one person

    Cons: A person using a waste of resources, all the programs are serial processing

  2. The second generation computer: Tape storage - Batch System 1955-1965

    I do not need a programmer to continue operation of the hardware, all hardware operations are already molding machine

    Each programmer will carve its own program on the disk, you can go, the middle staff will run your code disk, print the final result.

    Advantages: time saving programmer hardware connecting the various operations

    Cons: You can not use the computer alone can not fix bug.CPU or serial processing at runtime

  3. Third-generation computers, integrated circuits, multiprogramming system.

    The concept of an integrated circuit, all of the hardware becomes too small, arranged in the circuit board.

    Early 1960s: computer production lines: incompatible

    1. For scientific computing, compute-intensive operations.

    2. Commercial banking user Insurance, archiving, printing and so on. IO-intensive.

      Obstruction; IO obstruction, recv, accept, read input, write, sleep , etc., are blocked.

    system / 360 Series: The combining two types into a computer.

Third-generation computers to solve two problems:

  1. Artificial midway participation disk transfer work, and the problems of input and output devices of different machines

  2. Multi-channel technology

    Multi-channel multi-channel technology means that multiple programs, multi-channel technology to solve multiple program competition or share the same resources (such as CPU) The orderly scheduling problem solution that is multiplexed, multiplexing the multiplexed into multiplexed in time and space.

     # 多道技术产生的技术背景
    CPU在执行一个任务的过程中,若需要操作硬盘,则发送操作硬盘的指令,指令一旦发出,硬盘上的机械手臂滑动读取数据到内存中,这一段时间,CPU需要等待,时间可能很短,但对于CPU来说已经很长很长,长到可以让CPU做很多其他的任务,如果我们让CPU在这段时间内切换到去做其他的任务,这样CPU不就充分利用了吗。

Two multi-channel technology to solve the problem:

  1. Multiplexed on time:

    When a program while waiting for I / O, CPU can be used by another program, it can be stored in memory if enough jobs simultaneously, the CPU utilization rate may be close to 100%, similar to what we have learned mathematical primary integrated method (operation the system uses a multi-channel technology, you can control the switching process, or the CPU to execute permissions competition between processes. this will not only be switched on when a process encounters IO, a process CPU time will be too long switch, or by the operating system away execute permission of the CPU)

  2. Multiplexing in space

    The first generation, second-generation computer memory allows only a load a process.

    Third-generation computers began, multi-channel technology solutions to improve the memory utilization: multiplexing on the space - a memory can load multiple processes

    Multiplexing in space: When faced with a problem, data isolation.

    Massachusetts Institute of Technology (MIT) developed in 7094 had a modified machine, CTSS compatible time-sharing system.

    A question: is not exclusive

9.1.3 Process Description

  1. The difference between the process and procedures

    Program is a pile of files.

    A process that is being executed file / program

  2. Several concepts :( interview will ask)

    Serial: All of a process of a settlement by the CPU

    Concurrent: simultaneously executing a plurality of processes a single CPU (toggle), looks like a run

    Parallel: multiple CPU actually run multiple processes simultaneously

    Obstructive: obstruction encountered called IO

    Non-blocking: no IO

  3. Creation process

    What is more open process - socket:? Server, client two processes

    Python, if you want a more open process, must be a primary process, opening a number of sub-processes

    Process open process experience: in memory to open up a space, resources and data load, the CPU executes the call, you may also use this space resources

    Linux, Windows: open the main child process

    The same point: principles: open primary process child process, the two processes are isolated from each other independent of space, independently of each other

    difference:

    Linux: initial data space of the child process is entirely a copy from the main (parent) process.

    Windows: The initial data space of the child process is completely copy from the main (parent) of a process, but different.

Guess you like

Origin www.cnblogs.com/Agoni-7/p/11247173.html