Answer to Question #174894 in C++ for Jean Claude

Question #174894

Compare and contrast processes and threads and discuss how threads are scheduled.


1
Expert's answer
2021-03-26T23:28:43-0400

Comparing and contrasting process and thread

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.

Thread is a basic unit of CPU utilization. It comprises of thread id, a program counter, a register set and a stack. It shares with other thread belonging to the same process it's code section, data section, and other operating system resources, such as open files and signals. If a process has a multiple thread of control, it can perform more than one task at a time

Different thread do different task. 

Considering example the first thread take it locked mutex lock1 (so that other threads could not access the code) starts executing (code not added, just comments) and finally after completing its task waiting on cond1, likewise, the second thread locked mutex lock2, started executing its business logic, and, finally, waited on conditions from cond2 and the third thread locked mutex lock3, started executing its business logic and finally waited for the condition of cond3 and it continues. 


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS