Kernel Object Framework

This article is shared from the China Mobile OneOS WeChat public account " Kernel Object Framework ".

The kernel is the most basic and most important part of the operating system. The kernel is above the hardware abstraction layer and below the component layer, including the kernel runtime library, kernel object framework, real-time kernel, etc. The operating system kernel architecture is shown in the figure below.

Kernel runtime library : a set of small function implementation subsets to ensure that the kernel can run independently, including memory copying, string processing, etc.;

Kernel object framework : used to manage and access all kernel objects, unified management of kernel objects makes the system more flexible and extensible;

Real-time kernel : including task management, task scheduling, inter-task synchronization, inter-task communication, memory management, interrupt management, clock management, etc. The specific functions are expanded below.

It includes relatively complete real-time operating system features such as task processing, software timers, semaphores, mailboxes and real-time scheduling. The minimum resource occupancy is 3KB ROM and 1.2KB RAM.

Kernel Object Framework

For unified management and access to all kernel objects. Tasks, mutexes, semaphores, events, message queues, mailboxes, memory heaps, devices, etc. are all managed using this framework.

object container

First, the system initializes a corresponding object container for each type of kernel object, and the container includes an object linked list and quantity records.

The data structure of the object container is as follows:


struct os_object_info 
{ 
     enum os_object_type    type;        /* 对象类型 */ 
     os_list_node_t         object_list;  /* 对象链表 */ 
}

Among them, type represents the type of the record object, and list is a linked list structure, which is used to store kernel objects of the same type. Both adding and deleting objects are operated on the linked list, which ensures the operation efficiency.

object instance

The same attributes of various kernel objects are abstracted into a basic structure, which is used as an object control block. Each kernel object is extended from the base class, and corresponding private attributes are added according to the specific type. Similar to object-oriented inheritance and derivation.

The control block structure is as follows:


struct os_object 
{ 
     char             name[OS_NAME_MAX];    /* 内核对象名称     */ 
     os_uint8_t     type;                   /* 内核对象类型    */ 
     os_uint8_t     flag;                   /* 内核对象的参数  */ 
     os_bool_t      is_static;              /* 内核对象内存标识 */
     os_list_node_t  list;                   /* 内核对象管理链表 */
};

The header of each kernel object contains this structure. The member is_static identifies whether the kernel object storage space is statically defined by the user or dynamically applied by the kernel, and the member list is used to connect with the object container and sibling objects.

OneOS is a lightweight operating system launched by China Mobile for the Internet of Things. It features tailorable, cross-platform, low power consumption, and high security. It supports mainstream CPUs such as ARM Cortex-M/R/A, MIPS, and RISC-V. The architecture is compatible with POSIX, CMSIS and other standard interfaces, supports Micropython language development, and provides graphical development tools, which can effectively improve development efficiency and reduce development costs, helping customers develop stable, reliable, safe and easy-to-use IoT applications. Official website address: https://os.iot.10086.cn/
OneOS software address: http://www.oschina.net/p/cmcc-oneos
OneOS project address: https://gitee.com/cmcc-oneos/ OneOS
OneOS technical exchange group: 158631242

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324084665&siteId=291194637