Threads and Processes Flashcards

1
Q

What is a Process?

A

A process is the execution of a program that allows you to perform the appropriate actions specified in a program. It can be defined as an execution unit where a program runs. The OS helps you to create, schedule, and terminates the processes which is used by CPU. The other processes created by the main process are called child process.

A process operations can be easily controlled with the help of PCB(Process Control Block). You can consider it as the brain of the process, which contains all the crucial information related to processing like process id, priority, state, and contents CPU register, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Thread?

A

Thread is an execution unit that is part of a process. A process can have multiple threads, all executing at the same time. It is a unit of execution in concurrent programming. A thread is lightweight and can be managed independently by a scheduler. It helps you to improve the application performance using parallelism.

Multiple threads share information like data, code, files, etc. We can implement threads in three different ways:

Kernel-level threads
User-level threads
Hybrid threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Key differences between Thread and Processes?

A
  • Process means a program is in execution, whereas thread means a segment of a process.
  • A Process is not Lightweight, whereas Threads are Lightweight.
  • A Process takes more time to terminate, and the thread takes less time to terminate.
  • Process takes more time for creation, whereas Thread takes less time for creation.
  • Process likely takes more time for context switching whereas as Threads takes less time for context switching.
  • A Process is mostly isolated, whereas Threads share memory.

Process does not share data, and Threads share data with each other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Multithreading?

A

Multithreading refers to multiple threads of execution within an operating system. In simple terms, two or more threads of a same process are executing simultaneously.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly