16 - Threads Flashcards

1
Q

What are some problems with using processes in operating systems?

A

Processes have heavyweight PCBs, expensive context switching, separate address spaces, and limited shared memory, resulting in high memory usage and slower performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a thread, and how does it differ from a process?

A

A thread is a unit of execution within a process. It shares the process’s memory and resources while having its own program counter, register set, and stack, making it lighter weight than a process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the advantages of using threads over processes?

A

Threads allow for lower overhead in context switching, efficient resource sharing, and faster execution due to their lightweight nature.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the typical overhead of context switching for processes compared to threads in Linux?

A

Process creation and termination (via fork()/exit()) can take about 250 microseconds, kernel-level thread operations around 90 microseconds, and user-level thread operations approximately 5 microseconds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are kernel-level threads (KLTs) and what benefits do they offer?

A

Kernel-level threads are managed by the operating system’s kernel, supporting true parallelism on multi-core systems and enabling synchronization via OS-level primitives, though they incur moderate overhead.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are user-level threads (ULTs) and why are they faster?

A

User-level threads are managed entirely by user-space libraries, avoiding kernel intervention. This results in significantly lower overhead (around 5 microseconds) for creation and management.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do modern operating systems support multithreading compared to earlier systems like MS-DOS?

A

Modern operating systems like Windows, Linux, and macOS allow multiple processes to each support multiple threads, whereas earlier systems like MS-DOS supported only a single thread per process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What role do the program counter, register set, and stack play in a thread?

A

They define a thread’s execution state: the program counter indicates the next instruction, the register set holds temporary data, and the stack manages function calls and local variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does the Java Runtime Environment (JRE) handle threads?

A

The JRE supports multithreading by allowing a single process to manage multiple threads concurrently within the same memory space.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What benefits do threads provide in applications such as web servers?

A

Threads allow web servers to handle multiple concurrent requests efficiently by sharing common data, reducing overhead and improving performance compared to using separate processes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly