Introduction to U/cos-ii 20160525

Source: Internet
Author: User
Tags cos

Talk about the experience of just learning Ucos
1) First highlight the real-time operating system (RTOS) features, the most obvious is to provide timely response and high reliability
2) based on the implementation of the operating system of the application design, one of the most important concept is "task", task design is the task function is the design of the whole
Applications, and other software design efforts are built around a
3) In a user task function, you must include at least one system service function (typically a function that waits for a class so that other functions have a chance to run), otherwise the excellent
Lower priority tasks will not get the chance to run, the Interrupt service program cannot call the class function that is some wait function, prevent interrupt service program is interrupted
4) Task functions are divided into three categories:
A single execution, that is, a task to exit once execution is performed.
Periodic execution, that is, a task that is performed at a certain time, when the task sleeps when it is not time, so that the CPU can perform other tasks.
An event triggers execution, which executes a task when a particular event occurs, and when no corresponding event occurs, the task sleeps, and the CPU can perform any other
Works
5) When using UCOS-II, be aware that in the main function, add two initialization functions: Osinit (), Osstart (). Osinit () initializes the internal ucosii
Variable, Osstart () function to start a multitasking environment
6) Ostaskcreateext, create a task, the first parameter is a function pointer, that is, after creating, execute the function pointer to the body of the function:
int8u ostaskcreateext (void (*task) (void *PD),//Build Extended Task (Task code pointer, function pointer)
void *pdata,//passing parameter pointers
OS_STK *ptos,//Assign task stack top pointer
int8u Prio,//Assign task priority
int16u ID,//(future) priority identification (same as priority)
OS_STK *pbos,//Assign task stack bottom pointer
INT32U stk_size,//Specify the capacity of the stack (for inspection)
void *pext,//pointer to user-attached data field
int16u opt)//Set up a task setting option
Example: Ostaskcreateext (Taskrxproc,
Null
&taskstkrxproc[128-1],
3,
3,
Taskstkrxproc,
Task_stk_len_rx_proc,
Null
Os_task_opt_stk_chk | OS_TASK_OPT_STK_CLR)//enable stack checking for the task| Clearthe stack when the task is create

Other related system functions follow-up re-talk
7) The shared area of the operating system is the critical section, each task access must be mutually exclusive, the common methods to ensure mutual exclusion are:
First, enter and then exit the critical section, second, use the semaphore and the mutex signal
In addition, note that the processing of critical section code requires no interruption, the processing is completed to allow interrupts, to avoid other tasks or interrupt service to enter the critical section
Ucos provides two macros to implement, where
Os_enter_critical () Enter critical section, no interruption
Os_exit_critical () Exits the critical section, allowing interrupts
8) In addition to mutual exclusion, resource synchronization is the communication between tasks, the main (synchronous) mode is:
Semaphore, Event flag Group, message mailbox, Message Queuing these kinds of methods

Specific follow-up re-introduction

Introduction to U/cos-ii 20160525

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.