1,872 views
1 votes
1 votes
The primary difference between process and thread ?

(A) The number of I/O requests mode.

(B) The amount of overhead associated with creation and context switching .

(C) The amount of memory allocation

(D) The average number of instructions executed

4 Answers

0 votes
0 votes

a) Number of IO request remain same, if we run a process or divide the process into multiple threads and run on the system.
b) Creation of  process or context switch between process is relative expensive as compare to thread.
c) In process we allocated  a separate space, whereas in thread we assign a shared space, still on an average they almost take same space.
d) On average number of instruction executed will remain same.

So according to me option B is correct.

Refer : https://stackoverflow.com/questions/5440128/thread-context-switch-vs-process-context-switch

0 votes
0 votes

(C) is correct!

(A) and (D) and not correct/ nor are they a primary difference!

That leaves us with (B) and (C)

See this https://stackoverflow.com/questions/4894609/will-a-cpu-process-have-at-least-one-thread

For example, in the Linux kernel, the creation of a process is little different to creating a new thread. That's because the kernel schedules threads rather than processes.

Processes are now considered to be groups of threads with the same thread group ID (TGID), that TGID being the thread ID (TID) of the first thread created for that process.

#1)When you fork or vfork or clone (without CLONE_THREAD), you get a new thread with a new TID and the TGID is set to that TID - that's a new process.

#2)When you clone with CLONE_THREAD, you get a new thread with a new TID but the TGID remains the same as your cloner. That's a different thread in the same process.

That's how Linux (as an example) distinguishes between processes and threads without having to make the scheduler too complicated. The scheduler can choose to ignore thread groups entirely if it wishes. It's actually incredibly clever.

Now having known that consider option (B)

The amount of overhead associated with creation and context switching 

Now we can understand that there's not much overhead associated with creation of a process and thread.

However we definitely know that  (C) The amount of memory allocation for a new process is greater than a new thread! because threads share address space!. 

Hence answer is (c).

0 votes
0 votes

(C) is correct!

(A) and (D) and not correct/ nor are they a primary difference!

That leaves us with (B) and (C)

See this https://stackoverflow.com/questions/4894609/will-a-cpu-process-have-at-least-one-thread

For example, in the Linux kernel, the creation of a process is little different to creating a new thread. That's because the kernel schedules threads rather than processes.

Processes are now considered to be groups of threads with the same thread group ID (TGID), that TGID being the thread ID (TID) of the first thread created for that process.

#1) When you fork or vfork or clone (without CLONE_THREAD), you get a new thread with a new TID and the TGID is set to that TID - that's a new process.

#2) When you clone with CLONE_THREAD, you get a new thread with a new TID but the TGID remains the same as your cloner. That's a different thread in the same process.

That's how Linux (as an example) distinguishes between processes and threads without having to make the scheduler too complicated. The scheduler can choose to ignore thread groups entirely if it wishes. It's actually incredibly clever.

Now having known that consider option (B)

The amount of overhead associated with creation and context switching 

Now we can understand that there's not much overhead associated with creation of a process vs thread.

However we definitely know that  (C) The amount of memory allocation for a new process is greater than a new thread! because threads share address space!. 

Hence answer is  (c)

Related questions

1 votes
1 votes
1 answer
1
Na462 asked Jul 12, 2018
1,694 views
According to me Answer is C, because Multithreading i.e. User application threads cannot use different processors because processor see all the thread of user process as ...
1 votes
1 votes
2 answers
2
rahul sharma 5 asked Dec 6, 2017
691 views
Why threads have less context than process? Context means various attributes that we store in the PCB,so the attributes like state,property,PC,etc.. should be there in b...
0 votes
0 votes
0 answers
3
0 votes
0 votes
1 answer
4
Parshu gate asked Sep 18, 2017
1,164 views
Multi-threaded application cannot take advantage of multiprocessing.What does this mean?