UC/OS-II kernel Architecture Analysis (4)-uC/OS-II Task Management

Source: Internet
Author: User
1. c executable code structure

(1) code segment. Text: The machine command that stores CPU execution. Generally,. text can be shared and read-only.

(2) Data Segment. Data:. rodata (constant data),. rwdata (initialized global variables, static variables ).

(3) uninitialized data segment. BSS: uninitialized global and static variables.

(4) stack. STACK: stores function parameters, local variables, and context During task switching.

(5) Heap. Heap: used for dynamic memory allocation.

2. Task Structure

In uC/OS-II, tasks are the basic unit of event operation and management. A uC/OS-II task contains at least program code, stacks, and TCB, and can selectively use dynamic memory space equivalent to heap. When running, tasks in the UC/OS-II are equivalent to executable code (units that can run independently ).

How to manage each part of the uC/OS-II task ???

3. Task Stack
  • Task Stack data type: typedef unsigned short OS _stk
  • Task Stack growth direction: # define OS _stk_growth 0/1
  • Basic functions of the Task Stack :???
4. task control block (1) TCB description

It is mainly used to store the current attributes of a task. (Q: How do I run a task when it is scheduled for the first time ?)

(2) Main TCB members
  • Job stack space location: ostcbstkptr, Ostcbstkbottom, Ostcbstksize;
  • Task Communication and synchronization: ostcbeventptr, Ostcbmsg;
  • Task event group flag: ostcbflagnode, Ostcbflagsrdy;
  • Task waiting/Blocking: ostcbdly, Ostcbpendto;
  • Current task status: ostcbstat;
  • Task priority: ostcbprio;

(3) TCB global variables

  • OS _ext OS _tcb ostcbtbl [OS _max_tasks + OS _n_sys_tasks];
  • OS _ext OS _tcb ostcbpriotbl [OS _lowest_prio + 1];
  • OS _ext OS _tcb * ostcbfreelist;
  • OS _ext OS _tcb * ostcblist;
  • OS _ext OS _tcb * ostcbhighrdy;
  • OS _ext OS _tcb * ostcbcur;
5. Task status switching 6. task management functions

OS _task.c: 11 Functions

  • Ostaskcreate ();
  • Ostaskcreateext ();
  • Ostaskdel ();
  • Ostaskdelreq ();
  • Ostaskchangeprio ();
  • Ostasksuspend ();
  • Ostaskresume ();
  • Ostasknameget ();
  • Ostasknameset ();
  • Ostaskstkchk ();
  • OS _taskstkclr ();
  • Ostaskquery ();

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.