Operating system knowledge-threads, operating systems-threads
Thread
A thread is also called a mini process. Threads are lighter and easier to create than processes. It is easier to switch. If a large number of intensive computing and IO operations exist. Multiple Threads are allowed to overlap these activities.
Example. When we use a text processing software to process text, there will be multiple threads. It interacts with the user's gui. One is to process automatic backup of files. For a single thread. During backup, keyboard operations are ignored. Unfriendly to users.
Thread Model
A process has an execution thread, which contains a program counter, register, and stack record history. Processes are used to combine resources, and threads are the basic unit of CPU scheduling.
The content in the process on the left is shared by all threads, and the data on the right is the content in a single thread, which is not shared with other threads.
After a thread completes the work, it exits through (thread_exit ).
Another common thread call (thread_yield) allows the thread to automatically discard the CPU and run the other thread.
POSIX thread
To implement portable programs. IEEE sets thread standards.
Implement threads in the user space. Place the entire thread in the user space. The kernel is unknown.
User-level threads can be used to implement their own scheduling algorithms.
The implementation thread in the kernel. Use System Call. The cost of creating and canceling threads in the kernel is very high. So use the identifier that makes this thread unavailable.
Hybrid Implementation
The kernel recognizes the kernel thread for scheduling. Some kernel threads reuse multiple user threads.