线程和进程之间的区别_进程和线程之间的区别

深碍√TFBOYSˉ_ 2022-12-07 13:28 454阅读 0赞

2804fe72438fec0442e9afc6ab59bb78.png

线程和进程之间的区别

Here you will learn about difference between process and thread i.e. process vs thread.

在这里,您将了解进程与线程之间的区别,即进程与线程之间的区别。

Process: In simple words a process is executing a program. But not all, it’s only an instance of a computing program. Several processes may be associated with the same program. Process contains program code and its current activity.

流程:简单来说,就是流程正在执行程序。 但是,并非全部,这只是计算程序的一个实例。 多个进程可能与同一程序相关联。 流程包含程序代码及其当前活动。

Thread: We can say thread is a light weight process. A thread of execution is the smallest sequence of programmed instructions that can be managed independently by scheduler. Threads reside inside the process. Each thread belongs to exactly one process. No thread exists outside the process.

线程:我们可以说线程是一个轻量级的过程。 执行线程是可以由调度程序独立管理的已编程指令的最小序列。 线程驻留在进程内部。 每个线程恰好属于一个进程。 进程外没有线程。

Difference between Process and Thread

Image Source

图片来源

进程与线程–进程与线程之间的区别 (Process vs Thread – Difference between Process and Thread)




















































Process Thread
1) System calls involved in process. 1) No system calls involved.
2) Context switching required. 2) No context switching required.
3) Different process have different copies of code and data. 3) Sharing same copy of code and data can be possible among different threads..
4) Operating system treats different process differently. 4) All user level threads treated as single task for operating system.
5) If a process got blocked, remaining process continue their work. 5) If a user level thread got blocked, all other threads get blocked since they are treated as single task to OS. (Noted: This is can be avoided in kernel level threads).
6) Processes are independent. 6) Threads exist as subsets of a process. They are dependent.
7) Process run in separate memory space. 7) Threads run in shared memory space. And use memory of process which it belong to.
8) Processes have their own program counter (PC), register set, and stack space. 8) Threads share Code section, data section, Address space with other threads.
9) Communication between processes requires some time. 9) Communication between processes requires less time than processes.
10) Processes don’t share the memory with any other process. 10) Threads share the memory with other threads of the same process
11) Process have overhead. 11) Threads have no overhead.



















































处理 线
1)参与过程的系统调用。 1)不涉及系统调用。
2)需要上下文切换。 2)不需要上下文切换。
3)不同的过程具有不同的代码和数据副本。 3)可以在不同线程之间共享相同的代码和数据副本。
4)操作系统对不同的进程有不同的对待。 4)所有用户级线程都被视为操作系统的单个任务。
5)如果某个进程被阻塞,其余进程将继续其工作。 5)如果用户级线程被阻止,则所有其他线程都被阻止,因为它们被视为OS的单个任务。 (注意:在内核级线程中可以避免这种情况)。
6)流程是独立的。 6)线程作为进程的子集存在。 他们是依赖的。
7)进程在单独的内存空间中运行。 7)线程在共享内存空间中运行。 并使用它所属的进程的内存。
8)进程具有自己的程序计数器(PC),寄存器集和堆栈空间。 8)线程与其他线程共享代码部分,数据部分,地址空间。
9)流程之间的通信需要一些时间。 9)流程之间的通信所需时间少于流程。
10)进程不与任何其他进程共享内存。 10)线程与同一进程的其他线程共享内存
11)过程有开销。 11)线程没有开销。

Threads are used for small tasks, whereas processes are used for more ‘heavyweight’ tasks – basically the execution of applications. Another difference between thread and process is that threads within the same process share the same address space, whereas different processes do not.

线程用于小型任务,而进程用于更多的“重量级”任务-基本上是应用程序的执行。 线程与进程之间的另一个区别是,同一进程内的线程共享相同的地址空间,而不同的进程则不共享。

翻译自: https://www.thecrazyprogrammer.com/2018/01/difference-process-thread.html

线程和进程之间的区别

发表评论

表情:
评论列表 (有 0 条评论,454人围观)

还没有评论,来说两句吧...

相关阅读

    相关 线之间进程之间同步

           今天学习的内容为:利用互斥事件来控制线程之间、进程之间的同步问题。        其实,进程之间的同步也就类似于线程之间的同步。互斥事件的作用就是为了保证任一个

    相关 进程线区别

    进程是具有一定独立功能的程序关于某个数据集合上的一次运行活动,它是系统进行资源分配和调度的一个独立单位。例如,用户运行自己的程序,系统就创建一个进程,并为它分配资源,包括各种表

    相关 进程线区别

    进程是什么? 程序并不能单独运行,只有将程序装载到内存中,系统为它分配资源才能运行,而这种执行的程序就称之为进程。程序和进程的区别就在于:程序是指令的集合,它是进程运行的