GATE CSE · Operating Systems
Generate diverse GATE-level questions covering user-level vs kernel-level threads, multithreading models, and performance implications.
Concept summary for GATE CSE 2027 · 11 practice questions available
A thread is the smallest unit of CPU execution within a process. Multiple threads share the same process address space but execute independently.
| | Thread | Process |
|---|---|---|
| Address space | Shared with other threads | Separate |
| Resources | Shared (files, heap, code) | Separate |
| Communication | Easy - shared memory | Requires IPC |
| Creation overhead | Low (lightweight) | High (heavyweight) |
| Context switch | Faster | Slower |
| Fault isolation | One thread crash can kill all | Process isolation |
Per-thread: Program counter, registers, stack, thread ID, state
Shared across threads: Code, data, heap, open files, signals
Many-to-One (Green threads)
One-to-One
Many-to-Many
Two-level model: Many-to-many + allows one-to-one binding for critical threads
fork() with threads: Does child get all threads or just one?
exec() with threads: Replaces entire process (all threads)
Thread cancellation:
Thread Local Storage (TLS): Each thread has its own copy of certain data - useful for thread-specific state
Threads share heap and global data - race conditions possible. Each thread has its OWN stack and program counter. One-to-one (Linux) enables parallelism; many-to-one cannot run in parallel. Thread creation is faster than process creation - key advantage for server applications. After fork() in multi-threaded program: only calling thread exists in child - be careful with mutexes held by other threads (may cause deadlock in child).