UC/OS-II kernel Architecture Analysis (6)-uC/OS-II Memory Management

Source: Internet
Author: User
1. Basic principles of mempart

UC/OS-II divides memory space into multiple memory partitions as needed, each of which consists of memory blocks of the same size. It is mainly included in the C source file OS _mem.c.

  • OS _ext OS _mem osmemtbl [OS _max_mem_part];
  • OS _ext OS _mem * osmemfreelist;
  • Mempart control block struct:

Typedef struct OS _men {

Void * osmemaddr ;//First address

Void * osmemfreelist ;//Start address of the free space in the Partition

Int32u osmemblksize ;//Size of the block member space in the Partition

Int32u osmemnblks ;//Number of Block Structures

Int32u osmemnfree ;//Number of remaining idle Blocks

Int8u osmemname [];

} OS _mem;

 

2. mempart management functions
  • OS _mem * osmemcreate (void * ADDR, int32u nblks,

Int32u blksize, int8u * ERR );

  • Void * osmemget (OS _mem * pmem, int8u * ERR );//Apply for memory partition Blocks
  • Int8u osmemput (OS _mem * pmem, void * pblk );//Release memory partition Blocks
  • Int8u osmemquery (OS _mem * pmem, OS _mem_data *);
  • Int8u osmemnameget (OS _mem * pmem, int8u * pname, int8u * ERR );
  • Int8u osmemnameset (OS _mem * pmem, int8u * pname, int8u * ERR );

3. Several Questions about mempart

(1) Can I apply for a heap space of 1 B at a time?

(2) uC/OS-II stack space and stack space when applying for what is different?

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.