Threads Flashcards

1
Q

Thread

A

Execution Stream within a process, separate stack, program counter, thread control block

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

Thread vs Fork

A

Threads are faster and more lightweight, threads share address and OS state, reducing protection between them

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

Thread Control Block

A

Contains program counter, stack pointer, register state, and stack, execution state

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

Benefits of Threads

A

Can bypass IO blocking, shared memory, faster context switching(No virtual memory change)

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

Concurrency vs Parallelism

A

Concurrency interleaves program execution while parallelism runs instructions of separate cores

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

What do Threads Share

A

Address space(Global variables, heap, code) and OS State(files, sockets, locks)

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

Execution State

A

Whether a thread is New, Running, Blocked, Ready, or Finished

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

Interleaving

A

Context Switches cause threads to mix their instructions together with no guarantee one thread will execute an instruction before the other

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

Number of threads when program starts

A

One thread for main

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

pthread_join()

A

Blocks until passed in thread exits

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

Function to create thread

A

pthread_create()

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

User level threads

A

Threads managed by one thread without kernel being aware.

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

Advantages of User-Level Threads

A

User-level do not require going into kernel therefore are faster, can run on any OS.

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

Disadvantages of Kernel-Level Threads

A

Being contained on one kernel thread, any block on one user thread will block all threads. Cannot go to sleep without all threads going to sleep.

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

Pthreads

A

C library for multi-threaded programming.

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