Nucleus PLUS system architecture and components

Source: Internet
Author: User
Tags constant definition

(1) Methodology of components and software components1. Definition of Software components

In general, components are components that can be clearly identified in the system, and an opaque function implementation body. In software development, components are simple encapsulation of data and methods, and they have standardized and agreed interfaces. Components are object-oriented, feature-independent, highly reusable, and independent from languages and platforms. A software component is a relatively independent component of a software system. It is an execution unit that provides a set of service code through a specified interface, this execution unit features high cohesion and low coupling. The interface of the component is separated from the implementation of the component. The caller only needs to know the interface and access the interface to use the component. The interface is relatively fixed. Changes in component functions and implementations should not cause changes to the interface. Software components are key technologies for software reuse.

2. Software Component methodology:

Component Technology is a software development technology that emerged in the early 1990s S. It was developed on the basis of structured design and object-oriented technology, it is a standard system for software development after object-oriented technology and an extension of object-oriented development technology. Software Component development is mainly used in the process of developing and maintaining the system structure. The purpose of using software components as a separate process is to use components as the "parts" of the construction software ". With the concept and technology of components, software development can draw on successful instances in architecture and modern manufacturing, first construct the overall architecture of software, and then based on the Component Reuse Technology, assemble the required functional components on the architecture as needed, and finally form an application. Version updates can only be implemented by replacing the old component with the new component, without modifying the entire program or re-compiling the entire program.

(2) system architecture of Nucleus PLUS

The Nucleus PLUS system is composed of software components to enhance the code clarity, reliability, and reusability of the system, making the system modular and easy to maintain. Nucleus PLUS consists of multiple software components, each of which has a unique purpose and a specific external interface. Each component is implemented by calling these interfaces. In most cases, the data structure inside the component cannot be directly accessed by other components. This component architecture allows each software component of Nucleus PLUS to be easily replaced and reused.

Each software component consists of two header files and several source files. The source files are mostly written in C language, and a few are written in assembly language. One header file is used for data type definition and constant declaration, and the other is used to declare the external interface of the component. The following table provides an overview of each component file. components do not necessarily contain all the files in the Table. XX indicates the abbreviation of the component.

In a processor architecture that supports user mode and management mode, the Nucleus PLUS kernel and all application tasks run in management mode. This method is simple and has low overhead for task system calls, but each task can access any resource.

All user code source files that need to call the Nucleus PLUS system service or use the Nucleus data type must contain the header file "NUCLEUS. h ". The file contains the data type, constant definition, and all function declarations of the Nucleus PLUS Service. In fact, all functions starting with "NU _" in "NUCLEUS. h" do not actually exist in the source code of each component of Nucleus. Most Nucleus functions have a function (defined in each component) that actually executes operations and a "shell" function that checks errors before calling a function. The error check function can be disabled. The macro may not mark "NU_NO_ERROR_CHECKING. The definition of NU_NO_ERROR_CHECKING determines whether the "NU _" function is actually mapped to the component function.

(3) components of Nucleus PLUS

A total of 16 components of the Nucleus Plus system are discussed as follows (mainly describes the functions of the components ):

1. Common Service Component (CS)

All the control data structures controlled by the Nucleus PLUS component are linked lists. CS is responsible for providing the link structure and linked list operation functions, including adding and deleting nodes.

2. initialize the Component Initialization Component (IN)

Initializes and starts the Nucleus Plus system. The initialization and startup process consists of two parts: the hardware target board dependency (processor-related and board-Level Initialization) is first initialized, and then the initialization of each of the core PLUS components and user programs.

INT_Initialize subprogram is the first to run in the Nucleus PLUS system and is responsible for initialization of all hardware boards related to the target. After INT_Initialize is completed, the control is transferred to the advanced Nucleus PLUS initialization subroutine INC_Initialize and no return is returned. INC_Initialize calls all the objects such as the initialization function of the Nucleus plus component, the Application_Initialize is called to create a user task, and the control is handed over to the scheduling function TCT_schedule. The system starts up. For details about the initialization process, see "startup, running thread, and interrupt handling of Nucleus PLUS".

3. Thread Scheduling Component Tread Control Component (TC)

Responsible for preemptible real-time tasks and HISR scheduling and management of Nucleus Plus. Each user application consists of multiple tasks. A task is a semi-independent program segment with a specific purpose. A task is in one of five states: running, ready, suspended, terminated, and completed. Tasks have different priorities. High-priority tasks can seize low-priority tasks. tasks with the same priority are scheduled in the "ready" order, with the priority decreasing from 0 to 25.

Each task of Nucleus PLUS has a Control struct called Thread Control Block (TCB)-TC_TCB. Tasks support dynamic creation and deletion. TC manages all tasks through a two-way linked table TCD_Created_Tasks_List, the global variable TCD_Total_Tasks indicates the total number of tasks that have been created.

TCD_Priority_List is a 256-sized TCB pointer array (the array size is the same as the priority level of the Nucleus PLUS ), each array pointer is the header of a table (a blank element indicates a task without this priority). The element of this table is a TCB pointer of a ready task with the same priority. That is, Nucleus PLUS maintains a pointer array to schedule the linked list of tasks with different priorities.

For details about the task scheduling process, see the blog "Nucleus PLUS task scheduling".

HISR is the lower half of the interrupt processing routine and can access most of the Nucleus PLUS tasks (which cannot be automatically suspended ). HISR is also preemptible, and its priority is 0-2. HISR is activated by LISR, so it must be created and registered in advance.

The management of HISR is similar to the management of tasks. Each HISR has a control structure TC_HCB and an exclusive stack. TCD_Created_HISRs_List is the header that stores the two-way linked list of created HISR routines, TCD_Total_HISRs indicates the total number of HISR instances that have been created. In addition, TC maintains two activated HISR tables. The table items are the headers and tails of three HISR two-way linked lists with priority activated. TC also maintains LISR routines through the linked list, including interrupt vector registration and LISR entry functions. The TC component provides functions such as creating, deleting, and activating HISR.

4. Clock Component Timer Component (TM)

Manages all the Nucleus Plus timer devices. The basic timing unit of Nucleus Plus is a Tick, which is equivalent to a hardware timer interruption. At the system level, the timer is used for Task Management-timed sleep and wake-up. At the user application level, the timer is used in places where a timeout processing mechanism is required.

The timer supports dynamic creation/deletion. Each timer has a control structure such as TM_TCB, TMD_HISR, or TM_APP_TCB, which are used for system task timer, HISR timer, and application dedicated timer respectively. TM maintains the list of created and activated timers through the linked list. TM provides a system timer TMD_System_Clock.

Timer functions include creation, start, stop, reset, deletion, and timeout processing.

5. For the mail Component Mailbox Component (MB), the following shows the communication mechanism between processes (such as Mailbox, queue, pipeline, semaphores, and event groups) of the Nucleus PLUS. For details, refer to the blog post "Interprocess Communication (IPC) mode".

Manages all the mailbox services of Nucleus Plus and provides a low-cost inter-process communication mechanism. Each mailbox contains a message with a length of 4 32-bit characters. Mailboxes can be dynamically created/deleted by users, and can be suspended or restored.

Each Mailbox has a Control Block Mailbox Control Block (MCB) MB_MCB, and MB maintains the created Mailbox through a two-way linked list. Task suspension/wakeup in the mailbox supports FIFO order and task priority order. It is also implemented by maintaining a two-way linked list. Each task is suspended in the mailbox and a control block MB_SUSPEND structure is created.

MB provides functions such as mailbox creation, deletion, message sending/retrieval, resetting, clearing, and broadcasting.

6 Queue Component (QM) and 7 Pipeline Component Pipe Component (PI)

Manage all the core Plus queue services and all the core Plus queue services respectively. The management of the two parts is similar to that of the MB, the difference is that the queue message is one or more 32-bit characters, and the pipeline message is one or more 8-bit bytes.

8. Semaphore Component (SM)

Manages all the Nucleus Plus semaphores for synchronization between multiple tasks. Semaphores support dynamic creation/deletion. SM provides a semaphore count range of 0-4,294,967,294, which is similar to MB management.

9. Event Flag Component (EV)

Manages all the services of the Nucleus Plus event group. Each event group contains 32 event flags ), that is, each bit of a 32-bit unsigned integer is an event flag (1 indicates that the event occurred, and 0 indicates that the event has not occurred ). Its management is similar to that of MB.

10. Storage allocation Component Partition Memory Component (PM)

Manages all the core Plus partition memory. The memory pool of the partition memory refers to the memory that is determined by the total number of memory specified by the user and the number of bytes of each partition. The partition memory supports dynamic creation and task suspension/Wakeup (FIFO or task priority order ).

Each Partition Memory requires a Control Block Partition Memory Control Block (PCB)-PM_PCB (Memory occupied, not included in the Partition Memory ), PM maintains the memory of all created partitions through a two-way linked list. The available partitions in each partition memory are controlled by a single-chain table ending with a null value. Each available partition starts with the header structure PM_HEADER.

11. Dynamic Memory Component (DM)

Responsible for managing all the core Plus dynamic memory services. The starting position and length of the dynamic memory pool are specified by the user. It supports dynamic creation/deletion and task suspension/wakeup. The dynamic memory is allocated according to the first fit algorithm, and there is no fixed number of shards. The management of DM is similar to that of PM.

12, I/O Driver Component Iinput/Output Driver Component (I/O)

Responsible for managing the driver services of all the Nucleus Plus input/output devices and providing a common and similar s driver service interface, services include initialization, allocation, release, input/output, device status retrieval, and service application termination.

13. Error Component (ER)

Manages all the errors in the Nucleus Plus system.

14. Historical Component History Component (HI)

Responsible for managing the historical devices of Nucleus Plus.

15. License Component (LI)

Responsible for License Management of Nucleus Plus.

16. Version Control Component Release Component (RL)

Responsible for Version Management of Nucleus Plus.

Related Article

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.