Reputation:
A thread is usually defined as a lightweight process because the OS maintains smaller data structures for a thread than for a process.
I have two questions:
My reason: since per thread only stack and register are different , so (1) is true and (2) is false .
Is it correct ?
Edit: This is the original question
A thread is usually defined as a "light weight process" because an operating system (OS) maintains smaller data structures for a thread than for a process. In relation to this, which of the following is TRUE?
(A) On per-thread basis, the OS maintains only CPU register state
(B) The OS does not maintain separate stack for each thread
(C) On per-thread basis, the OS does not maintain virtual memory state
(D) On per-thread basis, the OS maintains only scheduling and accounting information
Upvotes: 0
Views: 1938
Reputation: 7486
A thread shares its virtual memory with the process it belongs to. This makes all the constructs we commonly see in multi-threading possible, where we simply exchange data between threads by writing to variables.
This also means that threads are quicker to start, since the OS does not need to load/setup the binary image, run initialization code etc. like it does for separate processes (created with e.g. fork(2)
).
However, threads are independent units to the operating systems CPU scheduler and thus the OS does keep indeed separate scheduling information for each thread.
Upvotes: 4