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 ();