Every single thread has the follow elements:
- Thread Kernel Object:TKO is a data structure.Everytime when a thread is created,a TKO will be assigned and initialized.TKO maintains a property of descriping the thread, and thread context.
- Thread Environment Block,which is related to exception.
- User-Mode Stack: this stack stores the local variables and arguments in the method,and the returnning address of the method,so the thread can move on from this address when returned from the method.
- Kernel-Mode Stack:a stack which managed by OS kernel function.
Thread context switch causes a bad performence.Here is how a context switch work :OS will move the data on CPU‘s register to the current thread‘s context, then move the target thread‘s context data into the cpu register so that the cpu can do its work.
时间: 2024-12-26 00:51:14