The concept differs from the process and thread

 The concept of processes and threads.

(1) process is a computer entity due to run the program.

Process is really running the program, the user orders to run the program, it will have a process. The same program can generate multiple processes.

Process There are three basic states: running, ready state, blocking state.

(2) A thread is the smallest unit of program execution flow. Usually by the thread ID, the current instruction pointer, register set and stack components. A thread is a physical process, independent of the system is the basic unit of scheduling and dispatching, thread and with it the thread shared memory in a process (but each thread has its own independent stack, the heap is shared by all threads).

 

The difference between threads and processes?

(1) scheduling: In the traditional operating system, the basic unit has the resources and independence scheduling is a process. After the introduction of the thread, the thread is the basic unit independent scheduling process is the basic unit of own resources. In the same process, thread switching does not cause the process of switching, and switching threads in different processes carried out, it will cause the process of switching.

(2) have the resources: the process is the basic unit with the resources, threads do not have the resources, but threads can share a shared resource that is part of the process.

(3) concurrency: Process can execute concurrently, and multiple threads within the same process can be executed concurrently, so that the operating system has good concurrency, greatly improving system throughput.

(4) overhead: Creating and revoking process, the system must be recomputed or recycled resources, such as memory, I / O devices. In the process of switching, to save the current settings and the new schedule of the implementation process of the process CPU CPU environment environment; and when a thread switch, simply save your settings and register a small amount of content. The process address space shared by multiple threads within the same process, and therefore relatively easy to achieve synchronization and communication between these threads.

Independent of each other between the process address space, between the various threads of the same process of resource sharing processes, threads within a process is not visible to other processes: (5) address space and other resources.

(6) communications: inter-process communication needs the operating system, but between threads can be directly read / write process data segment to communicate.

typical scheduling algorithms include : first come, first served (FIFS), short operating priority algorithm (SJF),

Priority scheduling algorithm, scheduling priority than a high response, round-robin algorithm, multilevel feedback queue scheduling algorithm.

cause and a necessary condition for Deadlock.

The reason: competition (1) system resources.

       (2) the process of promoting an illegal order.

Requirements:

       (1) mutually exclusive conditions.

       (2) is not deprived conditions.

       (3) Request and holding conditions.

       (4) loop wait condition.

       Bankers algorithm is known for deadlock avoidance algorithm.

common replacement algorithms : optimal replacement algorithm (OPT), FIFO page replacement algorithm (FIFO), least recently used (LRU) replacement algorithm. 

 

Guess you like

Origin www.cnblogs.com/yuanqiangfei/p/11267631.html