Concurrent Programming Fundamentals

The definition of a process'

  1. Narrowly defined

    Process is an instance of a program running (an instance of a computer program that is being executed).

  2. Broadly defined

    Process is run active program has a certain function on an independent data set. It is the basic unit of the operating system performed dynamically. In the traditional operating system, a process that is the basic allocation unit, is the basic unit of execution.

 

Second, the concept of process

  1. Process is an entity. Each process has his own address space, under normal circumstances, including the text area (text region), the data region (data region) and stack (stack region). Code is executed by a processor stored text area; dynamically allocated memory area stores data used during execution process variables; stack area stored procedure call instruction activities and local variables.

  2. Is a process 'execution procedures'. Program is a lifeless entity, only the processor attached to the program of life, it can become an active entity, which is the process.

 

Three characteristics, process

  • Dynamic

    The essence of the process is a program executed in a multi-channel program processes in the system, the process is dynamically generated, dynamic extinction.

  • Concurrency

    Any process can be executed concurrently with other processes together

  • Independence

    Process is a basic unit can operate independently, but also the system of allocation of resources and scheduling of independent units.

  • Asynchrony

    Due to the interaction between processes, so that the process has intermittent execution of that process by independent, unpredictable pace to move forward.

  • Structure

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

 

Scheduling IV process

  1. FCFS scheduling algorithm

    Suitable for busy process of the CPU, to the detriment of heavy I / O-type process.

  2. Short operating priority scheduling algorithm

    Is not conducive to a long process, can not guarantee timely processing of the urgency of the process is, the length of the process is to estimate the out.

  3. Round-robin method

    The processing time of the CPU time slice is divided into fixed size, if a process run out of time slice prescribed system after being selected schedule, but did not complete the mission requirements, then it releases its own self-occupied CPU ready queue and routed the end, waiting for the next scheduling. At the same time, the process scheduler went Scheduling a process currently in the queue ready.

  4. Multilevel feedback queue

    • A plurality of ready queues, given different priorities. Higher priority queue, each time a predetermined sheet process smaller.

    • After the new process into the memory, first put at the end of the queue. When the turn execution process, if not completed within the time slice, the process proceeds to the end of the second queue are sequentially executed.

    • Only when idle on a queue, the queue process will run next.

 

Fifth, the process of parallel and concurrent

  1. parallel

    Both perform, requires a plurality of processors

  2. Complicated by

    Limited resources, both alternately turns using resources.

 

Tri-state VI process

  1. Ready

    The process has been assigned to all the necessary resources other than the CPU, as long as the processor can get immediate execution, then the process of state is called the ready state.

  2. Operating status

    When the process has been the processor, the processor on which the program is implemented, this time called the execution state of the process status

  3. Blocking state

    Executing process, due to waiting for an event can not be executed, and they give up the processor is blocked. Cause the process to block a variety of events may, for example, waiting for I / O completion, the application buffer can not meet, waiting for the signal and so on.

 

Seven, synchronous and asynchronous

  1. Synchronize

    Upon completion of a task need to rely on another task, only waiting to be dependent on the completion of the task, the task can be considered complete dependence. This is a reliable task sequence, or either succeed or fail, the two tasks state consistent.

  2. asynchronous

    No need to wait to be dependent on completion of the task, but notification is dependent on what work tasks to complete, depending on the tasks executed immediately, as long as they completed the task is complete. As a final task was dependent on whether truly complete, depending on its mission can not be determined, therefore unreliable task sequence.

 

Eight, the process of creating and ending

  1. Creation process

    Create a new process is executed by an existing process for creating a system call process created

    1. Four kinds of forms to create a new process

      • System initialization (foreground process is responsible regardless of user interaction with the user daemon runs in the background and only when needed wake-up process, become daemon.)

      • A process opens a child process during operation (os.fork, subprocess.Popen, etc.)

      • User interactive requests (Double-executable)

      • A batch initialization operations (application only on mainframe batch system)

    2. Windows creates process

      CreateProcess system call, CreateProcess create both treatment processes, is also responsible for the correct program into the new process.

  2. End of the process

    1. Normal exit

      The user clicks on a cross, the program is finished so that normal exit system call in windows using ExitProcess

    2. Error Exit

    3. Serious error

      Execute an illegal instruction, references to nonexistent memory, etc., you can catch the exception

    4. Was killed by another process

      task kill

Guess you like

Origin www.cnblogs.com/binyuanxiang/p/11716853.html