Quiz 7 Flashcards

1
Q

What are “threads”?

A

“thread” is a set of program codes within a process that performs a well-defined task(s) in parallel (physically (multi-core processors) or logically (multi-tasking)) with other threads in the same process

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

How do threads reduce the high context switching overhead in processes?

A

They contain TCB (thread control block) which are smaller in switching information between

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

How do threads reduce the high overhead of processes when processes try to share data in shared memory?

A

IPC will have a global variable that can be shared between common threads of a process

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

What information do multiple threads in a process can share?

A

Global Variables

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

Can threads in a process share global variables in other processes? If yes, briefly describe how. If, not briefly explain why not.

A

No, because that is a privacy and data issue. Other processes can steal data and starvation or Race condition.

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

What information must be managed in TCB ( thread control block, also known as “private PCB”) and what information should be still in the PCB ( also known as “global PCB”)?

A

TCB should contain Pc register and unique variables

In the PCB should still be User ID, Total CPU time, Total amount of needed memory

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

Which of PCB (global PCB) or TCB (private PCB for each thread) do processor registers belong to? Briefly (but with a proper emphasis on the essential reason) justify your opinion.

A

They exist for each TCB because they are private data that doesn’t need to be shared with all TCBs, also it avoids other TCBs or threads from overwriting the registers causing a Race Condition

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

Which of the following items in the PCB for a process should belong to the global PCB or TCB (private PCB)?
(a) Processor registers
(b) Program Counter (PC) register
(c) User ID
(d) Process ID
(e) The list of opened files
(f) The list of the assigned I/O devices
(g) Stack Pointer (SP) register

A

a - TCB
b - TCB
c - PCB
d - PCB
e - TCB
f - PCB
g - TCB

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

Which of PCB (global PCB) or TCB (private PCB for each thread) does Program Counter (PC) register belong to? Briefly (but with a proper emphasis on the essential reason) justify your opinion.

A

The exist for each TCB because each thread has their own set of instructions, if everyone used the same PC register, then threads would loose their current location in their instructions.

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

Which of PCB (global PCB) or TCB (private PCB for each thread) does User ID (UID) information belong to? Briefly (but with a proper emphasis on the essential reason) justify your opinion.

A

Exists with the PCB, because all of the threads of a like process will have the same user ID, therefore it can be seen as a global variable since they all share the same one and they will all be ran at the same time when the process starts

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

Most of the operating systems today includes Stack Pointer (SP) register in their private PCB (i.e., “TCB”). What are the advantages in this design? Mention at least two different advantages.

A

Exists with each TCB, each thread will need to save their data/memory, they aren’t sharing registers therefore they need to know where their data is located since all of the registers are unique

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

As we discussed in the classroom, “threads” are introduced after many system programmers were using “processes” for multi-tasking (we even discussed that “threads” were introduced to avoid two problems in “processes”). After all, while “processes” and “threads” have many things in common (and “threads” seem to be better than “processes”). Then why do we still use “processes” (mention at least two different reasons)?

A

Security is the major reason, you would never want to share data for a bank account with other threads. That is a very private data source, therefore processes are used to keep that data secured. Also if one thread has a bad bug and shares it through global variables to other threads, it will crash all of the threads

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

What are the two different implementations of “threads”?

A

User thread and Kernel Thread

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

What are the two modes of processors

A

User mode and Kernel Mode

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

What is the primary role of a “Kernel mode”?

A

It is the mode of a processor where a processor has no restriction for the operations it performs.

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

What is the primary role of a “user mode”?

A

To restrict accesses to resources and restrict high-impact activities (killing processes, allocating memory space, preempting processes, and etc. )

16
Q

Which of the following(s) can a processor in the user mode perform?
a - Preempt a process (in the running state) in the short-term scheduling.
b- Read the value of the “real-time clock”
c - Read the contents in a file at a local storage device
d - Kill a process under multitasking OSes
e - none of the above

A

B and C

17
Q

What are the advantages in the user-mode threads?

A

Portability and Execution speed

18
Q

What are the advantages in the kernel-mode threads?

A

Preemptive thread scheduling and Robustness

19
Q

Show the typical internal structure of a process that consists of multiple threads

A

___________________________________
| user ID | TCB |
| Total CPU TIme| TCB |
| Total amount | TCB |
| of memory | TCB |
—————————-