过程:
进程意味着任何程序都在执行中。进程控制块控制任何进程的操作。进程控制块包含有关进程的信息,例如进程优先级、进程 ID、进程状态、CPU、寄存器等。进程可以创建其他进程,这些进程称为子进程。进程需要更多时间来终止,并且它是隔离的,这意味着它不与任何其他进程共享内存。
该进程可以具有以下状态,例如新的、就绪的、运行的、等待的、终止的、暂停的。
主题:
线程是进程的一部分,意味着一个进程可以有多个线程,并且这些多个线程包含在一个进程中。一个线程有 3 种状态:运行、就绪和阻塞。
与进程相比,线程终止所需的时间更少,并且类似的进程线程不会隔离。
进程和线程的区别:
S.NO | Process | Thread |
---|---|---|
1. | Process means any program is in execution. | Thread means segment of a process. |
2. | Process takes more time to terminate. | Thread takes less time to terminate. |
3. | It takes more time for creation. | It takes less time for creation. |
4. | It also takes more time for context switching. | It takes less time for context switching. |
5. | Process is less efficient in term of communication. | Thread is more efficient in term of communication. |
6. | Process consume more resources. | Thread consume less resources. |
7. | Process is isolated. | Threads share memory. |
8. | Process is called heavy weight process. | Thread is called light weight process. |
9. | Process switching uses interface in operating system. | Thread switching does not require to call a operating system and cause an interrupt to the kernel. |
10. | If one process is blocked then it will not effect the execution of other process | Second thread in the same task couldnot run, while one server thread is blocked. |
11. | Process has its own Process Control Block, Stack and Address Space. | Thread has Parents’ PCB, its own Thread Control Block and Stack and common Address space. |