734 views
1 votes
1 votes
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 both process and thread.So,how thread have less context than process?

2 Answers

1 votes
1 votes
Hello, here if u r asking this then first of all u please read galvin by the I m giving u some overview if we consider threds that means we r talking about light weight process which shares some common resources or data structures like stack and registers and some open files in PCB   of process therefore in context switch of threds takes very less time in compare to process context switch.
1 votes
1 votes

In computing, a context switch is the process of storing the state of a process or of a thread, so that it can be restored and execution resumed from the same point later. 

Switching from one process to another requires a certain amount of time for

1) doing the administration - Like Saving and loading registers and memory maps, updating various tables and lists, etc. What is actually involved in a context switch varies between these senses and between processors and operating systems.

NOTE: The scheduler doesn't see any difference between thread/process it sees them all equally as a task/job (In Linux)

2) Context switching involves switching registers, stack pointer, and program counter (PC) , (In threads these are the only things that'll be switched. And NOT the Address space!

3) Though in a process switch ( i.e context switch of a process) an address space switch also happens

4) Finally, Context switching itself has a cost in performance, due to running the task schedulerTLB flushes, and indirectly due to sharing the CPU cache between multiple tasks. 

5) However Switching between threads of a single process can be faster than between two separate processes, because threads share the same virtual memory maps, so a TLB flush is not necessary.

Related questions

1.8k
views
1 answers
1 votes
Na462 asked Jul 12, 2018
1,778 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 ... execute on Different Processors.Am i right ?But answer given is (A)
2.0k
views
4 answers
1 votes
ankitgupta.1729 asked Dec 14, 2017
1,970 views
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 ... (C) The amount of memory allocation(D) The average number of instructions executed
896
views
0 answers
0 votes
Na462 asked Oct 29, 2017
896 views
Threads of a process share(A) global variables but not heap(B) heap but not global variables(C) neither global variables nor heap(D) both heap and global ... files. So global variables it does share bt does it also share heap section?
1.2k
views
1 answers
0 votes
Parshu gate asked Sep 18, 2017
1,203 views
Multi-threaded application cannot take advantage of multiprocessing.What does this mean?