in Operating System
1,851 views
1 vote
1 vote
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
in Operating System
1.9k views

3 Comments

A and D can be ruled out

C can also be correct as threads is also definied as light weight processe.

Processor creation and switching are overhead too
0
0
Given answer is C but I marked B
0
0
Answer is c see my answer!
0
0

4 Answers

1 vote
1 vote

2 Comments

ok thanks..
0
0
That's not correct !
0
0
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

2 Comments

Even I think the same, but the answer given is c).
0
0
Answer is (C) please see my explanation!
0
0
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).

2 Comments

what about the context switching.
0
0
Truth is that's an ambiguous question! But given "amount of overhead on creating and Cs" note the *and* so as we know amount of overhead is not much the best option seems to be the other one.
0
0
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