Remaining review Flashcards
What information is in the PCB?
- process state
- application code, data, files
- virtual address space and mapping
- stack
- registers
Thus when splitting up, it only contains the address space and mappings
Limitations for single PCB (when full): Scalability Overheads Performance Flexibility
What do each of the data structures from the SOLARIS papers contain?
ULT KLT Process (PCB) CPU LWP
CPU:
- current KLT
- list of KLTs (threads that run there)
Process:
- list of KLTs
- virtual address space
- signal handlers
- user credentials
KLTs:
- kernal registers
- pointers to LWP and CPU
- Stack pointer
- Scheduling info
LWP:
- user-level registers
- system call arguments
- signal masks
- resource usage info
What allows for thread management between the ULTs and the kernel when either doesn’t know how many threads are available on each side?
Thus, system calls and special signals allow the kernel and ULT library to interact and coordinate
ex) pthread_setconcurrency
Benefits and Negatives of 1-1 KLT and ULT mapping
Benefits:
- know exactly how many threads dealing with on both sides
- easier to manage threads
Drawbacks:
- must go through the kernel every time and pay cost of system call
- relying on the mechanisms and policies of the kernel
Benefits and Negatives of many-1 KLT and ULT mapping
Benefits:
- portable and doesn’t depend on OS limits
Drawbacks:
- OS has no insight to application needs
- OS may block entire process if one ULT thread blocks on I/O
Benefits and Negatives of many-many KLT and ULT mapping
Benefits:
- You get the best of both 1-1 and many-1
Drawbacks:
- Requires extra coordination between ULTs and KLTs -
Situation:
T1 ULT is currently mapped to T1 thread on kernel and holds a mutex lock
The other ULTs are blocked
ULT T4 holds the T4 kernel thread and wants the mutex
Why does length of critical section of mutex matter in this situation?
FOR SHORT CRITICAL SECTIONS, DON’T LOCK BUT SPIN
AND FOR LONG CRITICAL SECTIONS, DEFAULT BEHAVIOR IS TO BLOCK
Use adaptive mutexes for this
T/F -> Interrupts can be directed to any CPU that has them enabled
True
We may set interrupt on just a single core - the single core is designated for handling the interrtupts
Avoids overheads and pertubations on all other cores
This results in improved performance
What are the types of signals?
Types of Signals:
1) one-shot signals -> “n signals pending == 1 signal pending” : at least once
Must be explicitly re-enabled
Future instances of this signal will be handled by the default OS handlers or ignored
2) real-time signals -> if n signals raised, then handler is called n times as well
Queuing behavior instead of overriding behavior
What are the top and bottom halfs of interrupt handlers?
This is an optimization for hanlder interrupts where the interrupt is divided into 2 sections:
Top:
- Minimum amount of processing
- Fast and nonblocking
Bottom:
- Arbitrary complexity
How does the ULT library and the kernel work together to handle signals that are enabled on some threads, but not the ULT thread currently mapped to the KLT?
- there’s a special ULT lib routine for handling the signal where it has knowledge of all the ULTs that can handle
- It can make another ULT handle the signal that has the signal maks enabled (this is especially simple when the ULT that can handle is unbound)
- In the case that the ULT that can handle is bound to a KLT, the ULT lib makes a system call to the KLT thread of the ULT that can handle. The KLT then goes back to the ULT lib handler and then makes the ULT that has enabled handle the signal.
- in some cases if all ULTs are disabled for a handler, the there is a cycle that takes that eventually leads to all KLTs disabling the signal masks as well
What is a task in Linux? What is in the task structure?
execution context of a KLT
task structure - pid - task group id - mm_struct - files_struct - list_head (list of tasks affiliated with a single process) - cpus_allowed Tasks share portions of the address space via some pointer data structures (mm, files)
How is a new task created in linux? What do the sharing flags do?
clone()
Sharing flags dictate which portion of the state of the tasks will be shared between the parent and the child task - different values when set or cleared
Why does Linux use the 1-1 KLT to ULT mapping?
Kernel sees every ULT
Kernel traps are much cheaper
More resources: memory, large ranges of ID’s,
No overhead for searching for enabled mask