python- process with a thread

Question 1: What is the process?

  • To execute a program, the program is called the execution state of the process.

  • A process which has at least one thread: the primary thread.

  • Memory resources used by different processes are independent of each other, independently of each other and interference.

  • The process is the smallest unit operating system allocates resources.

  • Process definitely better than the thread resources used more.

Question 2: What is the thread

  • The operating system is capable of calculating the minimum unit of scheduling.

  • It is included in the process, the actual operation of the unit process.

  • A thread refers to the control flow of the process in a single sequence.

  • A process can be complicated by multiple threads.

Characteristics of the process: Question 3

  • Dynamics: the essence of the process is a process of program execution in a multitasking system, the process is dynamically generated, dynamic extinction.

  • Concurrency: any process can be executed concurrently along with other processes.

  • Independence: the process is the basic unit of a stand-alone, but also the system unit resource allocation and scheduling of independence.

  • Asynchronous: As mutual restraint between processes, so that the process has intermittent execution process that is performed independent, unpredictable rate.

Structural features of the process: Question 4

  • Three parts of the process control program block, and processes the data composition

Question 5: Composition of CPU

  • By the arithmetic unit CPU, a controller, and registers

  • Operator is a member of the data processing. (Arithmetic operations, logic operations, data transfer, shift, etc.)

  • The controller is responsible for fetching instructions from the memory (memory and hard disk), the command and the devices for coordinating computer operating member

  • Internal CPU registers are independent high-speed temporary storage means (small capacity)

Question 6: What is the process of switching

  • The process of switching the processor is recovered from running processes, and then the process to be executed by processor-intensive.

Question 7: python and java

  • python: both can support multiple processes can also support multi-threading. (Multi-threaded multi-core CPU can not use the parallel computing capabilities, intensive IO type, you can use multiple processes in parallel computing power of multi-core CPU, compute-intensive type)

  • Only multithreaded java

  • The reason python multithreading can not take advantage of multi-core CPU is: GIL lock generates a lot of synchronous operation, not parallel, inefficient, can not use multi-core CPU.

Question 8: What is synchronous, asynchronous, blocking

  • There is a synchronization dependency relationship between cis execution step.

  • Asynchronous task is to have no dependent relationship that can simultaneously to perform.

  • Obstruction: Wait for the task (reading and writing files, network IO, suspend, sleep), into the ready state after the completion of

Question 9: process running

  • 1) Ready: The process has the resources needed in addition to the processor, waiting for allocation of processor resources, as long as the allocation of the processor, the process can be performed.

  • 2) operating status: the number of process consumes processor resources, the process in this state is less than the number of processors.

  • 3) blocking state: As the process of waiting for some conditions, can not proceed until further conditions are met.

 

 

 

 

 

Question 10: Process State Transition

 

 

  • Memory (main memory): provides storage directly to the CPU, high-speed, low-volume, expensive, can not permanently store data, disappears off, we need to re-transferred data from auxiliary storage. Common memory is: CPU cache

  • External memory (secondary memory): main memory to provide data, low-speed, high-capacity, low-cost, permanently stored data. Common secondary storage: hard disk, CD, U disk, disk, removable hard disk.

  • Active Ready: refers to the process in main memory and can be scheduled in the state.

  • Still Ready: refers to the process is switched to the ready state in the auxiliary storage, this state can not be directly dispatched.

  • Active blocking: refers to the process already in main memory, waiting for the event to generate once they enter the active state of readiness.

  • Still blocking: refers to the blocking state when the process is swapped to secondary storage, waiting for events to generate once they come to a standstill ready state.

Creation process: Question 11

(Once the operating system found the event requires the creation of a new process, then the calling process to create a primitive Creat () to create a new process step by subordinates)

  • Application blank PCB (process control block).

  • Allocation of resources for the new process. (Program and data memory space)

  • Initialization process control block (initialization identifying information, initialize status information processor, control processor initialization information)

Terminate the process: Question 12

  • Ends normally: normal procedures, smooth implementation

  • Abend: During the process is running, due to the emergence of some errors and failure to force the process to terminate.

  • Outside intervention: operating system or operator intervention, character request process, the parent process is terminated.

  • If your system has an appeal for an event after the termination of the process, OS would terminate the calling process statement, according to the following procedure to terminate the specified process.

Case of events that cause the process to block and wake up: Question 13

  • When executing process requesting the operating system to provide services, for some reason, the operating system does not immediately meet the requirements of the process, the process can become blocked waiting for, once the requirements are met, the process is awakened.

  • When the process starts module operation, if the process must continue to be performed after the operation is complete, you must first enable the process to block waiting for the operation to complete, after the operation is completed, the wake-up process

  • For the process of mutual cooperation, if one of the processes you need to get the data provided by another process to run a bunch of data processing, is to play the required data has not been reached, the process can only be (wait) blocked waiting for data to arrive the process is awakened

  • Systems are often set up some system processes have a particular function whenever this post into the job done, he gave up direct obstruction to wait for the arrival of the task, the task after arriving, the process is awakened.

Question 14: Wake-up blocking, blocking the process of process

  • In the process of implementation, when found above a certain event, unable to continue, then the process will be blocked by calling the primitive block the process directly blocked, blocked processes is an active process of breeding behavior

  • When blocked processes expected events, such as I / O completion or the period of data has arrived, wake-up call about the process by primitive wakeup (), the event will wait for the process wake.

Process scheduling algorithm: Question 15

  • FIFO

  • Round-robin algorithm

  • Highest priority algorithm

16 questions: the difference between concurrency and parallelism

  • Concurrency: In a period of time, while doing several tasks. A teacher in one hour, five students were watching jobs

  • At the same time, while doing the task. 5 teacher to see a student's work in one hour, respectively

Remarks:

Multi-process: the CPU can be a multi-core, application scenarios: computationally intensive
multithreaded: Because GIL lock, the CPU can not use multi-core, Scenario: the IO intensive
coroutine: single-threaded, there is no parallel, concurrent Carney it is not necessary achieve lock (lighter weight, can not use multi-core CPU)

Guess you like

Origin www.cnblogs.com/su-sir/p/12583852.html