Threads Flashcards

1
Q

Processes provide the abstraction of…
Threads provide the abstraction of…

A

Processes: an address space and resources
Threads: Execution states of that AS

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

PCB vs TCB, their locations, what data is stored

A

Process control block:
- Address space
- open files
- child processes
- pending alarms
> stored as kernel objects to protect them against unauthorized modifications

Thread control block:
- Instruction pointer
- registers
- stack
- state
>

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

Many to one model

A

=> User level threads
kernel only manages process -> multiple threads unknown to kernel
threads managed in user-space library
+faster thread management operations
+flexible scheduling policy
+few system resources
+can be used even if the OS doesn’t support threads
-no parallel execution
-whole process blocks if only one user thread blocks
-need to reimplement parts of the OS

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

one-to-one model

A

=> Kernel level threads
kernel knows and manages every thread, every thread known by kernel maps to one thread known by user
+real parallelism possible
+threads block individually
-OS manages every thread in the system
-Syscalls needed for thread management
-scheduling fixed in OS

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

Explain two types of threads

A

Kernel-level threads: The TCB is implemented in the OS kernel. The kernel is thus fully aware of the threads and responsible for managing them

User-level threads: The thread is fully implemented in a user-space program or library. The kernel is not aware of the threads.

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

What are the disadvantages of many to one thread model

A
  • blocking system calls block the entire application
  • can’t benefit from multiple CPUs/ cores
  • high implementation work
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

explain hybrid thread model

A

m-to-n model: m user-level threads are mapped to n kernel-level threads. The hybrid thread model combines the flexibility of a user-space thread library with the benefits of kernel-level threads (true parallelism, individual thread blocking).

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

Why does a switch to a thread of a different process normally take longer than a switch to a thread in the same process?

A

When switching to a thread in a different process, the OS needs to perform a full context switch, which includes switching to a different PCB and address space. The most state can remain the same for a thread switch in the same process. The current kernel stack and register state needs to be exchanged.

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

Name structures in memory and an operation that the kernel needs to allocate until the CPU executes a newly created kernel-level thread

A

Data Structures:
- Create a new thread control block (in kernel space)
- allocate a stack (user memory)
- allocate a kernel stack (kernel memory)
Operations:
- add the new thread to the (process’s) list of threads
- perform a context switch to the new thread

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

Actions taken by the kernel to perform context-switch between processes

A

-> preserve the previous execution state (context) on the stack and in that process’ PCB
-> exchange stack pointers
-> load new state from the new stack and PCB

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

Explain the terms process, address space and thread. How do they relate to each other?

A

A thread is an independent entity of execution, representing control flow. A thread resides within an address space. The combination of a thread and its address space is a single-threaded process.

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

Which events can trigger one-to-one thread switch

A

voluntary:
- callling yield()
- executing a blocking syscall (like read())
involuntary:
- preemption, for example due to end of time slice, high priority thread becoming ready, device interrupt, exception that can’t be handled immediately etc.

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

Which events can trigger a many-to-one thread switch

A

a m-to-n thread is never preempted but must call ult_yield() from time to time to allow other ULTs to make progess.

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