Python development--13. Operating systems, processes, and threads

Source: Internet
Author: User

first, the operating system1. Definition

An operating system is a system program used to coordinate, manage, and control the hardware and software resources of a computer, located between hardware and applications. The operating system runs in the kernel state, has full access to all hardware, and can perform any instruction that the machine can run. The rest of the software runs in the user state. In the user state, only a subset of the machine instructions is used, and the instruction that affects the control of the machine or the IO (input/output) operation is forbidden.

2. History of development(1) vacuum tube and punch card

Operation Flow: The programmer puts the perforated paper tape (or card) corresponding to the program and data into the input machine, then initiates the input machine to input the program and the data into the computer memory, then runs the program against the data via the console switch, calculates the output of the printer, and after the user takes away the result and unloads the paper tape (or card), The next user is on the computer.

Advantage: The programmer will be able to adjust the program in time while using the whole resource.

Cons: Waste of resources

(2) Transistor and batch processing system

Operation Flow: Batch input ===> calculate ===> batch output sequentially

Pros: Batch processing can be done to save time

Disadvantage: the need for human control input and output, is still sequential calculation (serial), unable to debug the program in time

(3) IC chip and multi-channel program design

Three technologies to solve three problems: external equipment online operation, multi-channel technology, multiple online terminal + multi-channel technology

(4) Personal computerIi. processes and Threads1. Process

narrowly defined: It is a process of execution of a procedure.

Generalized definition: is a program with a certain independent function on a data set of a running activity. It is the basic unit of the operating system dynamic execution, in the traditional operating system, the process is not only the basic allocation unit, but also the basic execution unit. A process is an entity, and each process has its own address space. A process is an "executing program," a program that is an inanimate entity that can become an active entity when it is given to the program's life, which we call a process.

The process is generally composed of three parts: program, data set and process control block. The program is used to describe what the process is going to accomplish and how it is done, and the data set is the resource that the program needs to use during execution, and the process control block is used to document the external characteristics of the process, to describe the process of its execution, and it can be used to control and manage the process, which is the only sign of the system-

2. Threads

A thread is also called a lightweight process, which is a basic CPU execution unit and the smallest unit in a program's execution, consisting of a thread ID, a program counter, a register collection, and a stack. The introduction of threads reduces the overhead of program concurrency and improves the concurrency performance of the operating system. The thread does not have its own system resources.

3. Relationship

(1) A thread can belong to only one process, while a process may have multiple threads, but at least one thread.
(2) A resource is allocated to a process, and all the threads of the same process share all the resources of that process.
(3) The CPU is assigned to a thread, that is, a thread that actually runs on the CPU.

Pros and Cons: The thread execution overhead is small, but not conducive to resource management and protection, and the process is the opposite.

4. Parallelism and concurrency

Parallel processing (Parallel processing) is a computational method that can perform two or more processes simultaneously in a computer system. Parallel processing can work on different aspects of the same program at the same time. The main purpose of parallel processing is to save time to solve large and complex problems. Concurrent processing (concurrency processing): Refers to a time period in which several programs are running to completion, and these programs are running on the same processor (CPU), but only one program at any point on the processing machine (CPU) runs

The key to concurrency is the ability to handle multiple tasks, not necessarily at the same time. The key to parallelism is the ability to handle multiple tasks at the same time.

5. Synchronous and asynchronous

Synchronization means that when a process executes a request, if it takes a while for the request to return the information, the process waits until the return message is received, and the process does not need to wait all the time, but continues to perform the following operations, regardless of the state of the other process. The system notifies the process when a message is returned, which can improve the efficiency of execution. For example, the telephone is synchronous communication, the short interest is asynchronous communication.

Python development--13. Operating systems, processes, and threads

Related Article

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.