P2L4 Thread Design Considerations - Data Structures And Management Flashcards Preview
Threads can be supported at ____ level, at _____ level, or both.
Threads can be supported at user level, at kernel level, or both.
Supporting threads at the kernel level means, …… To do this, the OS ______ maintains some ________, for our threads of data structure to represent threads, and it performs all of the operations like ______, __________, et cetera, in order to allow these threads to share the_______ resources.
Supporting threads at the kernel level means, that the OS kernel itself is multithreaded. To do this, the OS kernel maintains some abstraction, for our threads of data structure to represent threads, and it performs all of the operations like synchronizations, scheduling, et cetera, in order to allow these threads to share the physical resources.
Supporting threads at the user level means that there is a user-level ______, that is linked with the application, and this ______ provides all of the ___________ in the runtime support for threads.
Supporting threads at the user level means that there is a user-level library, that is linked with the application, and this library provides all of the management in the runtime support for threads.
Three ways user-level threads can be mapped onto the underlying kernel level-threads:
__________
__________
__________
Pros and cons?
Three ways user-level threads can be mapped onto the underlying kernel level-threads:
one-to-one
many-to-one,
many-to-many
Pros and cons - TODO
To the user level threads, each kernel level thread looks like a _____.
To the user level threads, each kernel level thread looks like a CPU.
Single threaded process. All of the information for this process such as:
______
______
______
is contained in the PCB
Single threaded process. All of the information for this process such as:
stack
register
virtual address mapping
is contained in the PCB
One-to-One
All of the information for this process is contained in the ____. Whenever the process makes a system call, it traps it into the kernel.
Assuming ___ CPU.
One-to-One
All of the information for this process is contained in the PCB. Whenever the process makes a system call, it traps it into the kernel.
Assuming 1 CPU.
Many-to-many
We don’t want to recreate all of the information in PCB for the multiple kernel level threads so we ____ the PCB.
The PCB will still contain the_______ ________
while another data structure will keep information about the ____ and _____ pointers of the kernel level threads.
Many-to-many
We don’t want to recreate all of the information in PCB for the multiple kernel level threads so we split the PCB.
The PCB will still contain the virtual mappings
while another data structure will keep information about the stack and register pointers of the kernel level threads.
Many to One:
Here the PCB contains the _______ _______ ________ as well as the _____ and _________ information for the kernel level thread.
Many to One:
Here the PCB contains the virtual address mappings as well as the stack and register information for the kernel level thread.
If the process links in a user level threading library, that library will need some way to represent threads, so that it can track thread ________ use and make decisions about thread _______ and synchronization.
The library will maintain some user level thread data structure containing:
thread _______
thread _______
thread _______
If the process links in a user level threading library, that library will need some way to represent threads, so that it can track thread resource use and make decisions about thread scheduling and synchronization.
The library will maintain some user level thread data structure containing:
thread ids
thread registers
thread stacks
Multiple processes relationships
The user level library keeps track all of the user level ______ for a given process.
The OS keeps track of the ______ level threads that execute on behalf of the process.
For each _____ level thread, the OS keeps track of the processes on whose behalf it executes
Multiple processes
The user level library keeps track all of the user level threads for a given process.
The OS keeps track of the kernel level threads that execute on behalf of the process.
For each kernel level thread, the OS keeps track of the processes on whose behalf it executes
Multiple processes
We need to maintain a relationships among these data structures:
____ _____ _____ structures
______ ______ _____
_____ _____ ______ structures
Multiple processes
We need to maintain a relationships among these data structures:
user level thread structures
process control blocks
kernel level thread structures
Light process state is …..
information specific to a certain kernel thread (signal mask/sys call args)
Hard process state is …..
information that applies to all threads within a process (virtual address mappings)
We can split up the information in the process control block into ____ process state which is relevant for ___ user level threads in a given process, and _____ process state that is only relevant for a subset of user level threads associated with a particular _____ level thread.
We can split up the information in the process control block into hard process state which is relevant for all user level threads in a given process, and light process state that is only relevant for a subset of user level threads associated with a particular kernel level thread.
If two kernel level threads belong to the same process … information relevant to all threads includes:
the _____ ______ ________ while information relevant to each thread specifically can include things like ______ or system call ________.
When we context switch among the two kernel level threads, we want to preserve some portion of the PCB and swap out the rest.
If two kernel level threads belong to the same process … information relevant to all threads includes:
the virtual address mapping while information relevant to each thread specifically can include things like signals or system call arguments.
When we context switch among the two kernel level threads, we want to preserve some portion of the PCB and swap out the rest.
Give 4 reasons to split up the PCB to multiple data structures
Better scalability: smaller data structures, maintained with pointers
Less overhead: If it’s one big structure, then you need a private copy for each thread even though they may share data. With pointers it’s easy to share datat
Better performance: save and restore only what needs to change on context switch
Easier customization: User-level library only needs to update a portion of the state for customized behavior
What is the name of the data structure that describes the process that the kernel thread is running?
task_struct (in the kthread_worker structure)
struct kthread_worker {
spinlock_t lock;
struct list_head work_list;
struct task_struct *task;
struct kthread_work *current_work;
};
What is the name of the kernel thread structure that’s used in Linux?
kthread_worker
struct kthread_worker {
spinlock_t lock;
struct list_head work_list;
struct task_struct *task;
struct kthread_work *current_work;
};