Python threading Process

Source: Internet
Author: User

Multi-Channel technology:

Multi-Channel program design Technology

The so-called multi-Channel program design technique means that multiple programs are allowed to enter memory and run simultaneously. That is, putting multiple programs into memory and allowing them to run alternately on the CPU, sharing the various hardware and software resources in the system. When a program pauses to run due to an I/O request, the CPU immediately goes to run another program.

The process of running a multi-channel program:
The A and B programs are stored in memory at the same time, they can be interleaved and alternately run on the CPU under the control of the system: when a program abandons the CPU due to request I/O operation, the B program can occupy the CPU, so that the CPU is no longer idle, and I/O operation is not idle, obviously , CPU and I/O devices are in a "busy" state, greatly improve the utilization of resources, and thus improve the efficiency of the system, A, b all the time required to complete <<t1+t2.

The program does not run alone, and the program is assigned resources to run only if it is loaded into memory, and this execution is called a process. The difference between a program and a process is that a program is a set of instructions, which is a static descriptive text of the process, and a process is an execution activity of a program, which belongs to the dynamic concept.

In multi-channel programming, we allow multiple programs to be loaded into memory at the same time, which can be implemented concurrently under the dispatch of the operating system. This is the design that greatly improves the CPU utilization. The advent of the process makes it possible for each user to feel the CPU alone, so the process is proposed for multi-channel programming on the CPU.

Definition of the process:

Is the program's running activity on a data set

The difference between a program and a process is that a program is a set of instructions, which is a static descriptive text of the process, and a process is an execution activity of a program, which belongs to the dynamic concept.

Definition of Thread

A thread is the smallest unit that the operating system can perform operations on. It is included in the process and is the actual operating unit of the process. A thread refers to a single sequential control flow in a process in which multiple threads can be concurrently, each thread performing different tasks in parallel

Process/Thread Switching principle

1. Time slices

2. I am experiencing IO operation switching

2. Priority switching

Python GIL

No matter how many threads you start, how many CPUs you have, Python will only allow a single thread to run at the same time when it executes.

Python threading Die Fast

Importing Modules Import Threading

Python threading Process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.