Threads give up lab [RT-Thread Study Notes 4], rt-thread Study Notes

Source: Internet
Author: User

Threads give up lab [RT-Thread Study Notes 4], rt-thread Study Notes

API: rt_thread_yield

Call in the thread function. This thread releases the MCU. If there are other tasks with the same priority in the waiting status, the right to use the MCU is obtained.

Giving a thread out is an opportunity for the OS to schedule tasks.

Create two threads and observe their results:

// The thread gets the test void yield_test1 (void * parameter) {rt_uint32_t count = 0; while (1) {rt_kprintf ("thread test1 count: % d \ n ", count ++); rt_thread_yield () ;}} void yield_test2 (void * parameter) {rt_uint32_t count = 0; while (1) {rt_kprintf ("thread test2 count: % d \ n ", count ++); rt_thread_yield ();}}

Start them:

// The threads give way to the experiment. The two threads have the same priority. Otherwise, the MCU tid2 = rt_thread_create ("yield1", yield_test1, RT_NULL, 2048,10, 5); if (tid2! = RT_NULL) rt_thread_startup (tid2); tid2 = rt_thread_create ("yield2", yield_test2, RT_NULL, 2048,10, 5); if (tid2! = RT_NULL) rt_thread_startup (tid2 );
 

Two threads are output in turn:

\ |/

-RT-Thread Operating System

/| \ 2.0.0 build Aug 29 2014

2006-2013 Copyright by rt-thread team

Thread test1 count: 0

Thread test2 count: 0

Thread test1 count: 1

Thread test2 count: 1

Thread test1 count: 2

Thread test2 count: 2

Thread test1 count: 3

Thread test2 count: 3

Thread test1 count: 4

Thread test2 count: 4

Thread test1 count: 5

Thread test2 count: 5

........

If there is no thread to let out the operation, it will be the turn of another thread to output after the end of a thread time slice. It won't be output in turn.
How does rt-thread build a gui?

RT-Thread/GUI is designed for the RT-Thread operating system, and RT-Thread features are used in corresponding places, it is a graphic interface with independent intellectual property rights, which is almost written from scratch (excluding JPEG, PNG, and other graphic libraries ). Under the terms of the RT-Thread license, it can be used in commercial products for free. Features of RT-Thread/GUI include:
-Multi-threaded graphical user interface;
-Depends on the Real-Time graphical user interface of the RT-Thread scheduler;
-Introduce the Panel concept in an innovative embedded system to reduce the multi-thread and Multi-Window graphical user interface programming costs:
* Workbench, which corresponds to multiple threads;
* View, corresponding to different user interface views;
* Window, corresponding to multiple windows;
-Comprehensive object-oriented design in C language:
* The object has runtime type information;
* Automatic destruction of objects makes memory management easier;
-Rich controls:
* Button, checkbox, radiobox
* Textbox
* Progressbar, slider
* Listview, filelist_view

Domestic RTOS, such as Dujiangyan real-time operating system? RT-Thread? And so on. Are there other things besides these two? Is there a company dedicated to RTOS?

RT-Thread RTOS
This is an open-source real-time operating system developed by RT-Thread studio in China. RT-Thread is a real-time kernel (fully preemptible priority scheduling, scheduler time complexity O (1), but in the development process, the RT-Thread real-time operating system is fully supported by embedded development engineers from all over the country and has become a complete and full-featured operating system: file system, network protocol stack, graphical interface components... Only you can't think of it, but you can't do it: RT-Thread is a platform. You can bring your ideas together. The RT-Thread developers are at your side in the big community of the small platform.

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.