Operating system knowledge-threads, operating systems-threads

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.