Quiz 7 Flashcards
What are “threads”?
“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 do threads reduce the high context switching overhead in processes?
They contain TCB (thread control block) which are smaller in switching information between
How do threads reduce the high overhead of processes when processes try to share data in shared memory?
IPC will have a global variable that can be shared between common threads of a process
What information do multiple threads in a process can share?
Global Variables
Can threads in a process share global variables in other processes? If yes, briefly describe how. If, not briefly explain why not.
No, because that is a privacy and data issue. Other processes can steal data and starvation or Race condition.
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”)?
TCB should contain Pc register and unique variables
In the PCB should still be User ID, Total CPU time, Total amount of needed memory
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.
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
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 - TCB
b - TCB
c - PCB
d - PCB
e - TCB
f - PCB
g - TCB
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.
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.
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.
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
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.
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
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)?
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
What are the two different implementations of “threads”?
User thread and Kernel Thread
What are the two modes of processors
User mode and Kernel Mode
What is the primary role of a “Kernel mode”?
It is the mode of a processor where a processor has no restriction for the operations it performs.