Thread. c

Source: Internet
Author: User

Thread_block () is used to terminate current_thread and change it to the blocked state. It cannot be run. It enters the ready queue only after thread_unblock () is called.
Thread_yield () is used to directly put current_thread into the ready queue and can be called again at any time.
List_entry returns a thread.
Idle_thread is usually not in ready_list.
1. In thread_start (), that is, at the beginning of the system, idle_thread is in ready_list.
2. Call idle_thread when ready_list is empty.
Idle () is called at thread_start.
{
1. Set the semaphore whose Initialization is 0 to 1, and put idle_thread into the ready queue.
2. Set the idle_thread status to blocked.

}
Running_thread () returns a running thread

Thread_current () is added with a check running_thread
Init_thread ()
{
1. initialize thread
2. Set status to blocked
3. Reduce the stack space
4. Magic Value
5. Add all_list
}
Next_thread_to_run ()
{
Is the ready queue empty? Return idle_thread: return the first of the ready queue and remove it.
}
Thread_schedule_tail (prev)
{
Thread_tick of current_thread clears 0
Activate Process
If the prev has been dying, it is destroyed.
}
Schedule ()
{
The function called is thread_block, thread_exit, and thread_yield, because the premise is that the current_thread status cannot be running.

}

 

In conclusion, thread has some external interfaces.

1. thread_create ()

2. thread_block ();

3. thread_unblock ()

4. thread_name ()

5. thread_current ()

6. thread_yield ()

7. thread_set_priority ()

8. next_thread_to_run ()

Related Article

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.