WO2024221468A1 - 嵌入式系统的运行方法和装置、嵌入式系统及芯片 - Google Patents

嵌入式系统的运行方法和装置、嵌入式系统及芯片 Download PDF

Info

Publication number
WO2024221468A1
WO2024221468A1 PCT/CN2023/091876 CN2023091876W WO2024221468A1 WO 2024221468 A1 WO2024221468 A1 WO 2024221468A1 CN 2023091876 W CN2023091876 W CN 2023091876W WO 2024221468 A1 WO2024221468 A1 WO 2024221468A1
Authority
WO
WIPO (PCT)
Prior art keywords
operating system
resource
allocated
processing resources
services
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2023/091876
Other languages
English (en)
French (fr)
Inventor
王恩东
黄家明
刘宝阳
陈超凡
马文凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Metabrain Intelligent Technology Co Ltd
Original Assignee
Suzhou Metabrain Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority to JP2023580598A priority Critical patent/JP7776542B2/ja
Priority to EP23825349.6A priority patent/EP4474989B1/en
Priority to KR1020257006679A priority patent/KR20250035609A/ko
Priority to US18/574,657 priority patent/US12293238B2/en
Priority to KR1020237045014A priority patent/KR102776397B1/ko
Priority to PCT/CN2023/091876 priority patent/WO2024221468A1/zh
Application filed by Suzhou Metabrain Intelligent Technology Co Ltd filed Critical Suzhou Metabrain Intelligent Technology Co Ltd
Priority to CN202380009072.XA priority patent/CN116868170A/zh
Publication of WO2024221468A1 publication Critical patent/WO2024221468A1/zh
Priority to US19/169,568 priority patent/US20250278312A1/en
Priority to US19/169,499 priority patent/US20250278311A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • G06F9/5077Logical partitioning of resources; Management or configuration of virtualized resources
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4406Loading of operating system
    • G06F9/441Multiboot arrangements, i.e. selecting an operating system to be loaded
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4418Suspend and resume; Hibernate and awake
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5033Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering data affinity
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5055Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering software capabilities, i.e. software resources associated or available to the machine
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/81Threshold
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool

Definitions

  • the embodiments of the present application relate to the field of computers, and more specifically, to an operating method and device for an embedded system, an embedded system, and a chip.
  • multi-core processors have become important computing units in many fields.
  • the multi-core processor can be used to carry services that are not sensitive to response speed, while the acceleration hardware can carry services that are sensitive to response speed.
  • the above-mentioned service processing method has a low overall utilization rate of processing resources because most of the processing resources (for example, core resources) of the multi-core processor are idle.
  • the embodiments of the present application provide an embedded system operation method and device, an embedded system and a chip, so as to at least solve the problem in the related art that the overall utilization rate of processing resources is low due to the fact that most of the processing resources of a multi-core processor are in an idle state.
  • a method for operating an embedded system comprising: allocating a group of to-be-allocated services to corresponding operating systems in the embedded system according to a dynamic resource allocation rule, wherein the dynamic resource allocation rule comprises dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate, service coupling degree, and service importance, the embedded system comprises a first operating system and a second operating system, the first operating system and the second operating system running on a processor, and the response speed of the first operating system is higher than that of the second operating system; determining a resource allocation result corresponding to the group of to-be-allocated services, wherein the resource allocation result is used to indicate the processing resources of the processor corresponding to each to-be-allocated service in the group of to-be-allocated services, the processing resources of the processor comprising a processor core; allocating the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each to-be-
  • an embedded system including: a first operating system and a second operating system, the first operating system and the second operating system running on a processor, the response speed of the first operating system being higher than that of the second operating system; a service management module, used to allocate a group of to-be-allocated services to corresponding operating systems according to a resource dynamic allocation rule, wherein the resource dynamic allocation rule includes dynamic resource allocation according to at least one of the following: service response speed, service resource occupancy rate; a resource dynamic allocation module, used to determine a resource allocation result corresponding to the group of to-be-allocated services, wherein the resource allocation result is used to indicate the processing resources of the processor corresponding to each to-be-allocated service in the group of to-be-allocated services, and the processing resources of the processor include a processor core; a resource adaptive scheduling module, used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each to-be-alloc
  • an embedded system including: a chip and at least two operating systems, wherein the chip includes a processor, a hardware controller, a first bus and a second bus, wherein the bandwidth of the first bus is higher than the bandwidth of the second bus, and the first bus is configured as a multi-master and multi-slave mode, and the second bus is configured as a one-master and multi-slave mode; the at least two operating systems run based on the processor, wherein the processing resources of the processor are dynamically allocated to the at least two operating systems, and the processing resources of the processor include a processor core; the at least two operating systems communicate through the first bus; and the at least two operating systems control the hardware controller through the second bus.
  • an operating device for an embedded system comprising: a first allocation unit, configured to allocate a group of services to be allocated to a corresponding operating system in the embedded system according to a resource dynamic allocation rule, wherein the resource dynamic allocation rule comprises dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate, service coupling degree, service importance, the embedded
  • the embedded system includes a first operating system and a second operating system, wherein the first operating system and the second operating system run on a processor, and the response speed of the first operating system is higher than that of the second operating system; a first determining unit, used to determine a resource allocation result corresponding to the group of services to be allocated, wherein the resource allocation result is used to indicate the processing resources of the processor corresponding to each service to be allocated in the group of services to be allocated, and the processing resources of the processor include a processor core; a second allocating unit, used to allocate the processing resources of the processor to the first operating system and the second operating system
  • a chip is further provided, wherein the chip includes at least one of a programmable logic circuit and an executable instruction, and the chip runs in an electronic device to implement the steps in any of the above method embodiments.
  • a BMC chip is further provided, which includes: a storage unit and a processing unit connected to the storage unit, the storage unit is used to store a program, and the processing unit is used to run the program to execute the steps in any one of the above method embodiments.
  • a mainboard which includes: at least one processor; at least one memory for storing at least one program; when the at least one program is executed by the at least one processor, the at least one processor implements the steps in any one of the above method embodiments.
  • a server which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor is used to implement the steps of any one of the above method embodiments when executing the program stored in the memory.
  • a computer-readable storage medium in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
  • an electronic device including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
  • a method of running different operating systems of an embedded system on different processing resources of a processor is to allocate a group of to-be-allocated services to corresponding operating systems in the embedded system according to a resource dynamic allocation rule, wherein the resource dynamic allocation rule includes dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate, service coupling degree, and service importance.
  • the embedded system includes a first operating system and a second operating system, and the first operating system and the second operating system run on the processor, and the response speed of the first operating system is higher than that of the second operating system; determining a resource allocation result corresponding to a group of to-be-allocated services, wherein the resource allocation result is used to indicate the processing resources in the processing resources of the processor corresponding to each to-be-allocated service in the group of to-be-allocated services, and the processing resources of the processor include a processor core; allocating the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each to-be-allocated service and the resource allocation result, because in the processing At least two operating systems of the embedded system are run on the processor, and different operating systems have different response speeds, which can be used to run services with different response speed requirements.
  • the processor's to-be-executed services are allocated to different operating systems based on a dynamic resource allocation rule, and the to-be-executed services are allocated to different processing resources, so that the processor's processing resources can be dynamically allocated to different operating systems based on the correspondence between the to-be-executed services and the operating systems, and the correspondence between the to-be-executed services and the processing resources.
  • FIG1 is a schematic diagram of a hardware environment of an embedded system operation method according to an embodiment of the present application.
  • FIG2 is a flow chart of an optional embedded system operation method according to an embodiment of the present application.
  • FIG3 is a schematic diagram of an optional operating method of an embedded system according to an embodiment of the present application.
  • FIG4 is a schematic diagram of another optional operating method of an embedded system according to an embodiment of the present application.
  • FIG5 is a schematic diagram of another optional operating method of an embedded system according to an embodiment of the present application.
  • FIG6 is a schematic diagram of another optional operating method of an embedded system according to an embodiment of the present application.
  • FIG7 is a schematic diagram of another optional operating method of an embedded system according to an embodiment of the present application.
  • FIG8 is a flow chart of another optional embedded system operation method according to an embodiment of the present application.
  • FIG9 is a schematic flow chart of another optional embedded system operation method according to an embodiment of the present application.
  • FIG10 is a schematic diagram of an optional embedded system according to an embodiment of the present application.
  • FIG11 is a schematic diagram of another optional embedded system according to an embodiment of the present application.
  • FIG. 12 is a structural block diagram of an optional operating device of an embedded system according to an embodiment of the present application.
  • FIG. 1 is a schematic diagram of the hardware environment of an operation method of an embedded system according to an embodiment of the present application.
  • the server may include one or more (only one is shown in FIG. 1) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data.
  • the above-mentioned server may also include a transmission device 106 and an input-output device 108 for communication functions.
  • FIG. 1 is only for illustration, and it does not limit the structure of the above-mentioned server.
  • the server may also include more or fewer components than those shown in FIG. 1, or have different configurations with equivalent functions as shown in FIG. 1 or more functions than those shown in FIG. 1.
  • the memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the operation method of the embedded system in the embodiment of the present application.
  • the processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the above method is implemented.
  • the memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
  • the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
  • the transmission device 106 is used to receive or send data via a network.
  • the specific example of the above network may include a wireless network provided by a communication provider of the server.
  • the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet.
  • the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
  • RF Radio Frequency
  • FIG. 2 is a method for operating an embedded system according to an embodiment of the present application.
  • the schematic diagram of the operation method of the selected embedded system is shown in FIG2 , and the process includes the following steps:
  • Step S202 Allocate a group of services to be allocated to corresponding operating systems in the embedded system according to a resource dynamic allocation rule.
  • the operation method of the embedded system in this embodiment can be applied to the scenario of running services on the processing resources of the processor and dynamically balancing the processing resources.
  • the above-mentioned embedded system can be an embedded multi-system, which refers to running multiple operating systems (for example, a first operating system, a second operating system, etc.) in a multi-core processor of the embedded system, and these operating systems are simultaneously running in the same embedded system.
  • the multiple operating systems can be the same type of operating system, or different types of operating systems, for example, heterogeneous operating systems (different types of operating systems with different architectures).
  • the execution of the service on the processor can be executed in parallel by the processing resources on multiple cores of the processor.
  • the processor here can be a multi-core processor, for example, an 8-core processor, or a processor containing other numbers of cores. In this embodiment, the number of cores contained in the multi-core processor is not limited.
  • multi-core processors have become important computing units in cloud computing, AI (Artificial Intelligence), big data, industrial Internet, and 5G (5th Generation Mobile Communication Technology).
  • AI Artificial Intelligence
  • 5G 5th Generation Mobile Communication Technology
  • virtualization technology can be introduced to improve the utilization of multi-core processors, that is, multiple virtual machines are virtualized based on the processor hardware platform, and each virtual machine runs an independent operating system.
  • the acceleration hardware may include but is not limited to: FPGA (Field Programmable Gate Array), CPLD (Complex Programmable Logic Device) or dedicated ASIC (Application Specific Integrated Circuit) chips, etc.
  • a method of running different operating systems of the embedded system on different processing resources of the processor is adopted. Different operating systems have different response speeds and can be used to run services with different response speed requirements.
  • the processor's to-be-executed services are allocated to different operating systems based on dynamic resource allocation rules, and the to-be-executed services are allocated to different processing resources. Therefore, the processor's processing resources can be dynamically allocated to different operating systems based on the correspondence between the to-be-executed services and the operating systems, and the correspondence between the to-be-executed services and the processing resources.
  • the embedded system includes a first operating system and a second operating system.
  • the response speed of the first operating system is higher than that of the second operating system.
  • the first operating system and the second operating system run on a processor, that is, run on different processing resources of the processor.
  • the processing resources of the processor may include at least one of the following: processing resources of the first operating system (processing resources scheduled to the first operating system), processing resources of the second operating system (processing resources scheduled to the second operating system), and unallocated processing resources.
  • the processor may be a multi-core processor (for example, an octa-core processor).
  • the processing resources of the processor ie, processor resources
  • a group of services to be allocated can be obtained, that is, services to be allocated to the first operating system and the second operating system. Since different services to be allocated may differ in terms of response speed, service resource occupancy rate, service coupling degree with other services, service importance, etc., a resource dynamic allocation rule can be pre-configured, and the resource dynamic allocation rule can include a rule for performing service allocation, and the service is allocated to the corresponding operating system so that the processing resources of the corresponding operating system execute the service allocated to itself.
  • the resource dynamic allocation rule may include dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate, service coupling degree, service importance, and different allocation rules may have corresponding priorities, for example, the priorities are in descending order: service importance, service coupling degree, service response speed, and service resource occupancy rate.
  • a group of services to be allocated (or tasks to be allocated, and different services to be allocated may correspond to different processes) can be allocated to the corresponding operating system in the embedded system to obtain a service allocation result.
  • the first operating system can be an operating system with clear and fixed time constraints. All processing processes (task scheduling) need to be completed within the fixed time constraints, otherwise the system will fail. It can be a real-time operating system (RTOS), such as FreeRTOS, RTLinux, etc., and can also be a real-time operating system in other embedded systems.
  • RTOS real-time operating system
  • the second operating system does not have this feature.
  • the second operating system generally adopts a fair task scheduling algorithm. When the number of threads/processes increases, it is necessary to share CPU time. Task debugging is uncertain.
  • Non-real-time operating system such as contiki, HeliOS, Linux (full name GNU/Linux, a set of freely disseminable Unix-like operating systems), etc.
  • Linux full name GNU/Linux, a set of freely disseminable Unix-like operating systems
  • non-real-time operating system in other embedded systems.
  • the Linux system is a multi-user, multi-tasking, multi-threaded and multi-CPU operating system based on POSIX (Portable Operating System Interface).
  • the business assigned to the first operating system is usually a real-time business.
  • Real-time business refers to business that needs to be scheduled within a specified time. The business requires the processor to process it at a fast enough speed, and the processing result can control the production process or respond quickly to the processing system within the specified time.
  • the control of the robot arm in industrial control is a real-time business. The system needs to take timely measures before detecting the robot arm's misoperation, otherwise it may cause serious consequences.
  • the business assigned to the second operating system is usually a non-real-time business.
  • Non-real-time business refers to business that is not sensitive to scheduling time and has a certain tolerance for scheduling delays, for example, reading sensor data from a temperature sensor in a server.
  • a real-time operating system is an operating system that can accept and process external events or data at a fast enough speed when they occur, and its processing results can control the production process or respond quickly to the processing system within the specified time, dispatch all available resources to complete real-time business, and control all real-time business to run in a coordinated and consistent manner. It has the characteristics of timely response and high reliability.
  • allocating a group of services to be allocated to the corresponding operating system may be performed by a service management module, as shown in FIG3 , the service management module may be a software module running on the first operating system or the second operating system, and taking running on the second operating system as an example, the service management module may be implemented by software in a Linux system.
  • the service management module may allocate a group of services to be allocated to the corresponding operating system in the embedded system according to a resource dynamic allocation rule.
  • Step S204 determining a resource allocation result corresponding to a group of services to be allocated, wherein the resource allocation result is used to indicate a processing resource in the processing resources of the processor corresponding to each service to be allocated in the group of services to be allocated.
  • corresponding processing resources can be allocated to each to-be-allocated service according to the service allocation result, and a resource allocation result corresponding to a group of to-be-allocated services can be obtained.
  • the services allocated to the first operating system can be allocated processing resources of the first operating system
  • the services allocated to the second operating system can be allocated processing resources of the second operating system.
  • the unallocated processing resources can be allocated to some services.
  • the processing resources of the processor can be dynamically allocated in units of time slices. Considering the frequent switching of the operating systems to which the processing resources belong and the fact that the service processing time is not necessarily an integer multiple of the time slice, which leads to the extension of the response time of some services, the processing resources can be allocated to the first operating system and the second operating system in units of processor cores, that is, the processor cores of the processor are allocated to the corresponding operating systems in units of the entire processor core, the number of processor cores allocated to each operating system is an integer, and the processor cores allocated to different operating systems are mutually exclusive. Not the same.
  • the resource dynamic allocation module can be a software module running on the first operating system or the second operating system. Taking running on the second operating system as an example, the resource dynamic allocation module can be implemented by a software module in the second operating system, which can dynamically allocate processing resources for the service based on the output of the service management module.
  • the software module can be a program module with preset functions. For example, for the resource dynamic allocation module, it can be a program module with a resource dynamic allocation function.
  • the service management module it can be a program module with a service management function.
  • Each software module can be deployed and adjusted as a whole and can be applied in different application projects.
  • Step S206 Allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each service to be allocated and the resource allocation result.
  • the processing resources of the processor can be allocated to the first operating system and the second operating system.
  • the unallocated processing resources of the processor can be allocated to the operating system corresponding thereto, and the unallocated processing resources can be determined based on the correspondence between the unallocated processing resources and the to-be-allocated service and the correspondence between the to-be-allocated service and the operating system.
  • the allocation of the processing resources of the processor to the first operating system and the second operating system can be performed by a resource adaptive scheduling module (e.g., a core adaptive scheduling module), which can be a software module running on the first operating system or the second operating system.
  • the resource adaptive scheduling module can be implemented by software in the Linux system, which can complete the actual scheduling action of the processing resources of the processor (e.g., the processor hard core resources) according to the output of the business management module and the output of the resource dynamic allocation module.
  • M cores of the (M+N) cores are scheduled to the real-time operating system, and N cores are scheduled to the non-real-time operating system.
  • heterogeneous operating systems can be run on different hard cores of the same processor, so that the entire processor system has the ability to process real-time and non-real-time services in parallel.
  • processor hard core resources for example, processor cores
  • the processor resource utilization rate can be significantly improved.
  • heterogeneous means that the types of operating systems running on the same multi-core processor of the embedded system are different, and multi-system means that there are multiple operating systems running on the same multi-core processor of the embedded system, and these operating systems are running simultaneously in the time dimension.
  • servers must at least have the characteristics of high scalability and high stability.
  • the server since the enterprise network cannot remain unchanged for a long time, in today's network information age, if the server does not have a certain degree of scalability, it will affect the use of the server in the enterprise, and then affect the future development of the enterprise. Therefore, scalability has become the most basic feature required by the server. Only with high scalability can better utilization in the future be guaranteed.
  • scalability also includes software scalability. Since the functions of the server are still very complex compared to computers, not only the hardware configuration, but also the software configuration is also very important. If you want to achieve more functions, it is impossible to imagine it without comprehensive software support.
  • the server since the server needs to process a large amount of data to support the continuous operation of the business, the server also has a very important feature, such as high stability. If the data transmission of the server cannot run stably, it will undoubtedly have a great impact on the business development.
  • the solution of the present application utilizes the high scalability of the server, introduces a first operating system and a second operating system dual software system for generating hardware interface signals, and can also introduce hardware devices such as GPLD and BMC chips for adjusting the transmission voltage of the hardware interface signal and monitoring the operating status of other devices inside the server.
  • the present application adopts a method in which the hardware interface signal corresponding to the request command is generated by the first operating system. First, the request command is obtained through the first operating system, and then the multiple logical bit information corresponding to the request command is determined, and finally the hardware interface signal corresponding to the request command is generated according to the multiple logical bit information and the timer.
  • the present application generates the hardware interface signal corresponding to the request command through the first operating system, thereby realizing the technical effect of simulating the generation of the hardware interface signal using software, and then achieving the purpose of hardware logic design without the chip itself having the relevant hardware interface signal, which can not only reduce the chip design difficulty, but also reduce the chip design cost.
  • the present application achieves the purpose of using the software system to generate the hardware interface signal on the basis of not needing to perform hardware logic design of the hardware interface signal on the chip, thereby reducing the chip design difficulty, and then solving the technical problem of the high chip design cost caused by the hardware logic design of the controller required in the related technology.
  • the introduction of the first operating system and the second operating system dual software system can also ensure the stability of the server. Since the business response speed of the second operating system is lower than that of the first operating system, the first operating system with a faster business response speed is used to generate hardware interface signals, which can ensure that the generation of hardware interface signals will not be interrupted, thereby ensuring that the hardware interface signals can be output continuously and stably.
  • a group of to-be-allocated services are allocated to the corresponding operating systems in the embedded system according to the dynamic resource allocation rule, wherein the dynamic resource allocation rule includes dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate, service coupling degree, service importance, and the embedded system includes a first operating system and a second operating system, the first operating system and the second operating system are run on a processor, and the response speed of the first operating system is higher than that of the second operating system; a resource allocation result corresponding to a group of to-be-allocated services is determined, wherein the resource allocation result is used to indicate the processing resources of the processor corresponding to each to-be-allocated service in the group of to-be-allocated services, and the processing resources of the processor include a processor core; according to the operating system corresponding to each to-be-allocated service and the resource allocation result, the processing resources of the processor are allocated to the first operating system and the second operating system, thereby solving the problem of low overall
  • the method further comprises:
  • the resource dynamic allocation rules can be configured based on the rule configuration file.
  • a rule structure for recording the resource dynamic allocation rules can be generated.
  • the rule configuration file can be a load balancing policy file (payload_balance.config).
  • the load balancing policy file can be used to configure the classification method of various running services (or processes), the evaluation principle of the real-time level, etc. Different parameters can be used to configure the resource dynamic allocation rules in the load balancing policy file.
  • An example of a load balancing policy configuration file is as follows:
  • classification kinds 2 //A value of 1 means that the processes are classified according to attributes such as important and non-important. Otherwise, the processes are classified according to the preset classification method (such as real-time and non-real-time);
  • real-time grade evaluation 2//A value of 1 means that the average CPU usage in the past statistical minutes is used as the process real-time grade evaluation principle; otherwise, it means that the preset priority is used as the process real-time grade evaluation principle;
  • the resource dynamic allocation rules can be stored in a load balancing policy module, where the load balancing policy module can be a software module running under the first operating system or the second operating system (for example, a software module running under the Linux system), which can provide policy guidance for the service management module, including the classification method of various services (or processes) running in the system, the evaluation principle of the real-time level, etc.
  • the service management module can divide and manage the services in the system according to the real-time level, and further guide the resource adaptive scheduling module to reallocate processor resources. Exemplarily, it can perform actual classification of services based on the output of the load balancing policy module to generate a list containing real-time services and non-real-time services.
  • the rules based on which the business management module performs business management can be dynamically configured, and further rules can be set on the basis of existing rules. Multiple rules with the same function can be set in the business management module, but there is no contradiction between the rules, that is, the current rule in use can be determined among the rules with the same function based on the rule selection conditions such as the configuration time of the rule and the priority of the rule, so as to avoid contradictions between the rules.
  • the above configuration file load_balance.config describes a possible situation.
  • the classification_kinds variable indicates the specific classification standard (for example, according to the importance or real-time nature of the business) and the classification category (for example, important business and general business, real-time business and non-real-time business, etc.), and the real-time_grade_evaluation variable indicates the real-time evaluation standard (which can be the average CPU occupancy rate in the past statistic_minutes minutes or the preset business priority).
  • the real-time grade type is defined by the user and can be defined as high, normal, and low, or it can be subdivided into more types.
  • the output of the load balancing strategy module is the configured classification method, real-time level evaluation principle, etc. When implemented in software, it can be a specific configuration file (such as the load_balance.config file) or a structure variable. These files or structure variables can eventually be accessed by the business management module to obtain the specific load balancing strategy.
  • the method further comprises:
  • the rule structure can be in a fixed format, that is, it is not allowed to be modified during the operation of the embedded system, or it can be in a flexibly configurable format, that is, it can be configured and changed through a configuration file in a specific format.
  • a rule update configuration file can be obtained, and the rule update configuration file is used to update the configured resource dynamic allocation rules; using the rule update configuration file, the rule structure can be updated, thereby updating the resource dynamic allocation rules recorded in the rule structure.
  • the configuration file in a specific format can be read through the external interface of the first operating system or the second operating system.
  • the second operating system can be responsible for the dynamic resource scheduling of the embedded system.
  • the rule update configuration file can be obtained through the external interface of the second operating system.
  • the load balancing policy module may be in a fixed format, or may be configured through an external interface of the Linux system.
  • a configuration file (load_balance.config) in a specific format as described above may be defined, and configuration changes may be made through file reading and writing.
  • the external interface is the external interface of the multi-core processor, which can be a network interface, SPI (Serial Peripheral Interface) controller interface, UART (Universal Asynchronous Receiver/Transmitter) serial port, etc., as long as it can obtain data from the outside world.
  • SPI Serial Peripheral Interface
  • UART Universal Asynchronous Receiver/Transmitter
  • the configuration file can be loaded from the Web (World Wide Web) interface through the network interface; the configuration file can be read from the SPI Flash (flash memory) of the board through the SPI controller; the configuration file can be obtained from the serial port data receiving and sending software tool on another PC (Personal Computer) through the UART serial port.
  • allocating a group of services to be allocated to corresponding operating systems in an embedded system according to a resource dynamic allocation rule includes:
  • the pending services can be allocated to the corresponding operating system based on the service response speed requirements of the pending services.
  • the service response speed can be used to evaluate the real-time level of the service. The higher the service response speed requirement, the more sensitive it is to the scheduling time and response speed of the operating system. The higher the real-time level, the higher the service response speed requirement.
  • the service needs the operating system to process it at a sufficiently fast speed, and the processing results can control the production process or respond quickly to the processing system within the specified time.
  • the service with low service response speed requirements has a certain tolerance for scheduling delays.
  • the services to be allocated whose service response speed requirement is greater than or equal to the set response speed threshold they are sensitive to the scheduling time and response speed of the operating system. Therefore, such services to be allocated can be allocated to the first operating system (for example, real-time services are allocated to the real-time operating system). For the services to be allocated whose service response speed requirement is less than the set response speed threshold, they are not sensitive to the response speed and scheduling time. Therefore, such services to be allocated can be allocated to the second operating system (for example, non-real-time services are allocated to the non-real-time operating system).
  • the service response speed requirement can be indicated by an indication parameter of the service response speed
  • the set response speed threshold can be a millisecond-level response speed threshold or a second-level response speed threshold.
  • the response speed threshold for example, 100ms, 200ms, 1s, etc., is not limited in this embodiment.
  • a first service list corresponding to the first operating system and a second service list corresponding to the second operating system can be output, the first service list being used to record services allocated to the first operating system, and the second service list being used to record services allocated to the second operating system, that is, the service allocation result includes the first service list and the second service list, and the output first service list and the second service list can be used to perform a dynamic scheduling process of the processor's processing resources.
  • the real-time level of system services is classified to obtain a list of real-time services and non-real-time services. Assume that there are 20 services in total, of which real-time services are services 1 and 2, and non-real-time services are services 3 to 20.
  • the business management module can classify the current business to be executed.
  • the business management module classifies these businesses according to the output of the load balancing module.
  • different businesses will be assigned to different operating systems (RTOS system and Linux system) for execution.
  • RTOS system and Linux system operating systems
  • the business management module will continue to divide the business and divide and manage the existing businesses in real time according to the load balancing strategy.
  • the business management module can be a resident process in the Linux system. It is always running and manages and divides the currently running processes.
  • allocating a group of services to be allocated to corresponding operating systems in an embedded system according to a resource dynamic allocation rule includes:
  • the services to be allocated can be allocated to the corresponding operating system based on the service resource occupancy rate of the services to be allocated.
  • the service resource occupancy rate can be the average proportion of the services to the processing resources per unit time (for example, the CPU occupancy rate per minute).
  • the service resource occupancy rate affects the response speed of the service and the response speed of subsequent services. Therefore, the real-time level of the service can be evaluated based on the service resource occupancy rate. The higher the service resource occupancy rate, the greater the impact on the scheduling time and response speed of the operating system, and the lower the real-time level. For services with low service resource occupancy rate, the impact on the scheduling time and response speed of the operating system is not large, and the real-time level is higher.
  • the impact on the scheduling time and response speed of the operating system is not significant, and such services to be allocated can be allocated to the first operating system.
  • the impact on the scheduling time and response speed of the operating system is greater, and therefore, such services to be allocated can be allocated to the second operating system.
  • the first occupancy rate threshold can be configured as needed, and it can be 10%, 15%, 20% or other thresholds, and at the same time, the first occupancy rate threshold can be dynamically adjusted.
  • allocating a group of services to be allocated to corresponding operating systems in an embedded system according to a resource dynamic allocation rule includes at least one of the following:
  • S52 Allocate to-be-allocated services whose service coupling degree with the services allocated to the second operating system is greater than or equal to a second coupling degree threshold value among a group of to-be-allocated services to the second operating system.
  • the services to be allocated can be allocated to the corresponding operating systems based on the service coupling degree of the services to be allocated.
  • the service coupling degree can be used to indicate the degree of association between the services to be allocated and the allocated services in each operating system. If the service coupling degree of a service to be allocated is high with the allocated services of a certain operating system, it is not appropriate to allocate it to another operating system. Therefore, the services to be allocated can be allocated to the corresponding operating systems based on the service coupling degree between the services to be allocated and the allocated services in each operating system.
  • the business coupling can be evaluated by the association between the input and output of the business.
  • the business coupling can be represented by different coupling levels. If there is no relationship between the input and output of the business, the coupling level is low (or other coupling levels indicating no association between the businesses). If the execution of a business depends on the output of another application (the business cannot start without the output as input), the coupling level between the businesses is high. If the execution of a business uses the output of another application, but the output does not hinder the normal execution of the business (the output can be obtained when the business executes the corresponding operation, and the corresponding operation is not a core operation), the coupling level between the businesses is medium.
  • the business coupling can also be represented by a numerical value. The business coupling can be evaluated by one or more coupling conditions (for example, the association between input and output), and the numerical value corresponding to the satisfied coupling condition is determined as the numerical value of the business coupling.
  • to-be-allocated businesses in a group of to-be-allocated businesses whose business coupling degree with the allocated businesses of the first operating system is greater than or equal to a first coupling degree threshold then such to-be-allocated businesses can be allocated to the first operating system; and if there are to-be-allocated businesses in a group of to-be-allocated businesses whose business coupling degree with the allocated businesses of the second operating system is greater than or equal to the first coupling degree threshold, then such to-be-allocated businesses can be allocated to the second operating system.
  • the service management module is also responsible for service decoupling evaluation and management, that is, finding out from all real-time services the services that can be separated out and handed over to the real-time operating system for running, so that the hardware resource dynamic allocation module can reallocate processor resources. For services that cannot be separated out and handed over to the real-time operating system for running, if they have a high degree of service coupling with non-real-time services, they can be allocated to the non-real-time operating system.
  • the reallocation strategy is open.
  • One possible strategy is: when the system runs for the first time, processor cores are allocated according to the ratio of the number of services allocated to the real-time operating system and the non-real-time operating system by the business management module. During subsequent operations, resource allocation is adjusted according to the core resource occupancy rate of each system in the dual system. From this perspective, the reallocation process and the core preemption and release process are mutually coordinated processes.
  • the service running on the first operating system may include, but is not limited to, a service for generating a hardware interface signal.
  • a process for generating a hardware interface signal is provided, and the process includes the following steps:
  • Step 1 obtain a request command through the first operating system.
  • the request command can be a command to generate a hardware interface signal.
  • the hardware interface signal can be a PECI signal, and the request command is a PECI request command based on the PECI protocol.
  • the hardware interface signal can also be a hardware interface signal of other protocol types, for example, HDMI (high definition multimedia interface) signal, RGMII (reduced gigabit media independent interface, parallel bus) signal, SGMII (serial gigabit media independent interface, single-channel serial bus) signal, GPIO (general purpose input/output, general input and output port) signal, SPI (serial peripheral interface, serial peripheral interface) signal, etc.
  • the request command can also be a request command of other protocol types.
  • the hardware interface signal is a GPIO signal
  • the request command is a GPIO request command. This application does not specifically limit the specific types of request commands and hardware interface signals.
  • Step 2 determine multiple logical bit information corresponding to the request command.
  • the first operating system can analyze and obtain multiple logical bit information corresponding to the request command, wherein there is a sequence between the multiple logical bit information.
  • the first operating system can generate a waveform signal (i.e., a hardware interface signal) corresponding to the request command through the multiple logical bit information corresponding to the request command, thereby transmitting the information contained in the request command to other devices through the hardware interface signal.
  • the request command includes at least one field, each field can be represented by a logical bit 0 or 1, on this basis, the corresponding conversion relationship between each field and the logical bit 1 or 0 is the logical bit information corresponding to the field, and in the case where the request command corresponds to multiple fields, the request command corresponds to multiple logical bit information.
  • each logical bit can be represented by a combination of a high-level signal and a low-level signal. For example, for a logical bit 0, a high-level signal of a first preset duration and a low-level signal of a second preset duration can be used to represent it in combination.
  • a high-level signal of a second preset duration and a low-level signal of a first preset duration can be used to represent it in combination, wherein the first preset duration and the second preset duration are respectively a high-level signal and a low-level signal of a first preset duration.
  • the preset duration is different.
  • each logic bit contains both a high-level signal and a low-level signal, each logic bit is actually represented by a waveform signal (the transformation between the high-level and low-level signals is presented as a waveform).
  • the hardware interface signal corresponding to the request command is a waveform signal obtained by combining the waveform signals corresponding to each logic bit information.
  • Step 3 Generate a hardware interface signal corresponding to the request command according to the multiple logic bit information and the timer.
  • the timer in step 3 may be a timing program in the first operating system, or a register on the chip where the first operating system is located, wherein the timer may at least provide a timing function and a counting function.
  • the present application uses the timing function and the counting function of the timer, and combines multiple logic bit information to generate a hardware interface signal corresponding to the request command.
  • the related art in order to realize the PECI communication between the BMC chip and components such as the CPU, the related art requires the BMC chip itself to have the hardware logic design of the PECI controller, which leads to the problem of high design cost of the BMC chip.
  • the hardware logic design of the PECI controller in order to generate a PECI signal on the BMC chip, the hardware logic design of the PECI controller must be implemented on the BMC chip in advance, while in the present application, only the first operating system is required to generate a PECI signal on the BMC chip, and there is no need to implement the hardware logic design of the PECI controller on the BMC chip, thereby reducing the design difficulty and design cost of the BMC chip.
  • the method of generating a hardware interface signal corresponding to a request command by the first operating system is adopted.
  • the request command is obtained through the first operating system, and then multiple logical bit information corresponding to the request command is determined.
  • the hardware interface signal corresponding to the request command is generated based on the multiple logical bit information and the timer.
  • the hardware interface signal corresponding to the request command is generated by the first operating system, thereby realizing the technical effect of simulating the generation of the hardware interface signal by software, and then achieving the purpose of using the software system to generate the hardware interface signal without the need for hardware logic design of the hardware interface signal of the chip, which can not only reduce the difficulty of chip design, but also reduce the design cost of the chip.
  • request data is obtained, wherein the first operating system and the second operating system run on the same processor, the request data is generated by the second operating system, and the service response speed of the second operating system is lower than the service response speed of the first operating system.
  • the first operating system parses the request data to obtain a request command.
  • the requested data can be stored in the target memory (i.e., the storage space on the processor) through the second operating system, and after the requested data is stored, the first request is triggered through the second operating system, wherein the first request is used to notify the first operating system to read the requested data from the target memory, and the target memory is a memory that can be accessed by both the first operating system and the second operating system.
  • the target memory i.e., the storage space on the processor
  • the first operating system may also receive response data corresponding to the hardware interface signal, wherein the transmission form of the response data is the same as the transmission form of the hardware interface signal. Secondly, the first operating system also adjusts the data structure of the response data to a second data structure.
  • a second request is triggered through the first operating system, wherein the second request is used to notify the second operating system to read the response data.
  • PECI signal Take the first operating system as RTOS system, the second operating system as Linux system, and the hardware interface signal as PECI signal as an example.
  • the upper-layer application involved in PECI business in the Linux system (such as fault diagnosis, CPU temperature acquisition, etc.) firstly initiates PECI request commands according to the needs.
  • These request commands include but are not limited to the basic Ping() command, the command to obtain CPU temperature and the command to read MSR register information, etc.
  • the code implementation of different PECI request commands is completed by the corresponding interface function.
  • the Linux system writes the target address, read/write length, command code, para parameter and other request data of each request command into the target memory according to the PECI protocol specification, and after all the request data are written into the target memory, the Linux system generates a first request to notify the RTOS system.
  • the first request may be an SGI interrupt request (software generated interrupt, a communication interrupt request between processor cores).
  • the second operating system stores the request data in the target memory in the form of a first data structure, wherein the first data structure at least includes a device address, a write length, a read length, a command code, and a request parameter, the device address is used to characterize the address of the target device, the target device is a device that generates response data based on a hardware interface signal, the command code is used to distinguish different request commands, the write length is used to characterize the number of bytes from the command code to the end of the request data, and the read length is used to characterize the request.
  • the request data contains the number of bytes including the completion code and the read data.
  • the request parameters are used to represent the parameters of the request command.
  • the RTOS system receives the response data from the PECI bus, and then completes the data parsing to convert the signal form of the response data from the form of the hardware interface signal to the form of the software signal, for example, identifying the waveform changes between the high-level signal and the low-level signal in the hardware interface signal, thereby obtaining the corresponding logical bit information, and obtaining the software signal data based on the logical information.
  • the parsed response data is adjusted by the command parameter structuring module and written into the target memory.
  • the RTOS system triggers the second request to notify the Linux system.
  • the Linux system detects the second request, actively reads the parsed response data stored in the target memory, and returns the data to the upper application after processing.
  • the second request can be an SGI interrupt request.
  • the target memory can also be other memories, such as random access memory (RAM), flash memory, etc.
  • RAM random access memory
  • flash memory etc.
  • the first operating system may convert the voltage of the hardware interface signal to obtain a target hardware interface signal.
  • the first operating system can input the hardware interface signal into the voltage conversion device to obtain the target hardware interface signal output by the voltage conversion device.
  • the above-mentioned voltage conversion device can be a CPLD, and the CPLD can be connected to the target device, wherein the target device can be a CPU in a server. It should be noted that in addition to being applied to replacing the PECI interface to generate the PECI signal, the above-mentioned service can also be applied to other hardware interfaces.
  • the first operating system and the second operating system of the combined embedded system realize the interaction of data in the embedded system through inter-core interrupts and shared memory, build a waveform generation function module for request commands in the RTOS system, and realize the communication of hardware interface signals between the embedded system and external devices through software simulation.
  • the high real-time characteristics of the RTOS system are fully utilized to ensure the accuracy of the timing when simulating the request command waveform, which is flexible and efficient. It can significantly reduce the difficulty of chip design.
  • the hardware interface signal is generated by software simulation, it provides more possibilities for the optimized design between the communication function and other business functions in the embedded system.
  • the controller in the chip specifically used to realize the hardware interface signal communication is omitted, the design cost and manufacturing cost of the chip can be reduced.
  • the service running on the first operating system may include, but is not limited to, a serial port switching service.
  • a serial port switching process is provided, which includes the following steps:
  • Step 1 When it is detected that the second operating system receives a serial port switching instruction, the second operating system sends the serial port switching instruction to the first operating system.
  • the second operating system can detect whether the serial port switching instruction initiated by the user is received.
  • the serial port switching instruction needs to include information of the target serial port to be switched to, for example, the serial port switching instruction includes the serial port number of the target serial port to be switched to.
  • the format of the serial port switching command can be ⁇ switch_command_app-n number-t sleep_time>, where switch_command_app represents the switching command program, -n represents the target serial port number for switching, number can take the value of 1, 2, or 3, -t represents how long to sleep after the command is initiated before executing the switching action, and sleep_time is in seconds.
  • serial ports that can currently be switched can be numbered so that when switching serial ports is subsequently performed, the target serial port can be switched by the serial port number.
  • the serial ports that can currently be switched include: BMC Linux system serial port, server BIOS (Basic Input Output System) serial port and SMART NIC (network interface controller) serial port.
  • BMC Linux system serial port server BIOS (Basic Input Output System) serial port
  • SMART NIC network interface controller
  • 1 can represent the BMC Linux system serial port
  • 2 represents the server BIOS serial port
  • 3 represents the SMART NIC serial port.
  • Step 2 Execute serial port switching according to the serial port switching instruction through the first operating system.
  • the second operating system when detecting that the second operating system receives the serial port switching instruction, the second operating system will immediately send the serial port switching instruction to the first operating system.
  • the first operating system and the second operating system can be run in two processor cores respectively, and then the first operating system and the second operating system use inter-core communication, which can help improve the reliability of signal transmission.
  • the response speed of the first operating system to instructions is much faster than the response speed of the second operating system to instructions, so the first operating system can quickly respond to the serial port switching instruction and complete the switching work in a very short time.
  • the serial port switching software function is implemented by replacing CPLD or FPGA with the first operating system and the second operating system running in the same processor.
  • the second operating system receives a serial port switching instruction
  • the second operating system forwards the serial port switching instruction to the first operating system
  • the first operating system implements serial port switching according to the serial port switching instruction, thereby avoiding the need to connect various serial ports through CPLD or FPGA in the related technology, and then use the switch structure in CPLD or FPGA to implement serial port switching, reducing hardware costs
  • the technical method proposed in this solution can not only effectively reduce the serial port switching cost, but also effectively improve the efficiency of serial port switching.
  • the serial port switching instruction at least includes: the serial port number of the target serial port.
  • the following steps are included: obtaining the parsing rules of the serial port switching instruction from the target memory through the first operating system; parsing the serial port number of the target serial port in the serial port switching instruction according to the parsing rules, and determining the device corresponding to the serial port number, wherein the target serial port is the serial port of the device, and the target serial port is connected to the chip.
  • Executing serial port switching according to the serial port switching instruction through the first operating system includes: determining the serial port address of the device through the first operating system; and mapping the target serial port to the target output interface of the chip according to the serial port address.
  • the first operating system may parse the serial port switching instruction, and then obtain the device corresponding to the target serial port.
  • the parsing rules for the serial port switching instructions can be customized according to the different chips or server motherboards, and the parsing rules can be stored in the target memory, which can be a storage medium such as an electrically erasable programmable read-only memory (EEPROM) or a non-volatile memory (Flash). It should be noted that the target memory can be deployed in the chip or not. By storing the parsing rules in the target memory, the security of the data is improved, and the parsing rules can be customized according to the different chips or server motherboards, so that the programmability and scalability are better.
  • EEPROM electrically erasable programmable read-only memory
  • Flash non-volatile memory
  • the first operating system After the first operating system receives the serial port switching instruction, it reads the parsing rule of the serial port switching instruction from the target memory, and then uses the parsing rule to parse the serial port number of the target serial port in the serial port switching instruction to obtain the device corresponding to the serial port number.
  • the first operating system can map the target serial port to the target output interface of the chip through the serial port address of the device. After mapping the serial port address of the device to the target output interface, the device can be accessed through the target output interface. It should be noted that the serial port switching instruction and parsing rules can be set according to the model of the chip used and the type of the first operating system and the second operating system.
  • the chip includes: a serial data bus. Before determining the serial port address of the device through the first operating system, the method also includes: determining multiple devices connected to the serial port of the serial data bus; mapping the serial port of each device to the memory of the chip through the serial data bus to obtain the serial port address of each device.
  • the above chip also includes a serial data bus, and the TX and RX of the serial ports of multiple devices are currently connected to the serial data bus.
  • the current serial ports include the BMC Linux system serial port (UART1), the server BIOS serial port (UART2), and the SMART NIC serial port (UART3).
  • UART Universal Asynchronous Receiver/Transmitter.
  • the serial port data bus will map the TX and RX data of different serial ports of UART1, UART2 and UART3 to different address spaces of the BMC memory, that is, the above-mentioned mapping of the serial port of each device to the memory of the chip through the serial data bus.
  • UART1 TX and RX buffer are the serial port address of serial port UART1
  • UART2 TX and RX buffer are the serial port address of serial port UART2
  • UART3 TX and RX buffer are the serial port address of serial port UART3.
  • the first operating system selects three different memory segments mapped by UART (one out of three), and exchanges the data of one of the memory segments to the customer, so as to achieve the purpose of simulating the CPLD hardware serial port switching circuit. It should be noted that if the serial ports of different devices cannot be distinguished, the developer cannot accurately locate which device's serial port has a problem during maintenance. Therefore, it is necessary to locate the abnormal problem through serial port switching.
  • the smart network card connection includes: detecting, by means of the smart network card, whether an access request to a target serial port is received; and if an access request to the target serial port is received, forwarding the access request to the target serial port by means of the smart network card.
  • the target output interface of the chip can also be connected to a target smart network card, and then the smart network card detects whether a user's access request to the target serial port is received. If an access request to the target serial port is received, the serial port of the device can be directly accessed through the target smart network card to realize the SOL (Serial over LAN, a specification of a data packet format and protocol) function. Through the above steps, the efficiency of serial port access to the device is improved.
  • SOL Serial over LAN, a specification of a data packet format and protocol
  • the following steps are also included: obtaining the execution result of the serial port switching instruction through the first operating system, wherein the execution result is one of the following: switching success and switching failure; sending the execution result to the second operating system through the first operating system.
  • the execution result of the serial port switching instruction is received through the second operating system, wherein the execution result is sent from the first operating system to the second operating system, and the execution result is one of the following: serial port switching success and serial port switching failure.
  • the first operating system switches the serial port, it will obtain the execution result of the serial port switching instruction, and then feed back the execution result of the serial port switching instruction to the second operating system, informing the second operating system of the serial port success or failure.
  • the second operating system after receiving the execution result of the serial port switching instruction through the second operating system, it also includes: if the execution result is execution failure, repeatedly executing the step of sending the serial port switching instruction to the first operating system through the second operating system until the execution result is successful, or the number of serial port switching executions exceeds the preset number. If the number of serial port switching executions exceeds the preset number, a prompt signal is triggered through the second operating system, wherein the prompt signal is used to prompt that the serial port switching fails.
  • the execution result of the serial port switching instruction is execution failure, then it is necessary to repeat the step of sending the serial port switching instruction to the first operating system through the second operating system until the execution result is successful, or the number of serial port switching executions exceeds the preset number of times, which can be set to 3 times. If the number of serial port switching executions exceeds the preset number of times, the corresponding second operating system triggers a prompt signal to prompt that the serial port switching has failed, so that this situation can be handled in a timely manner.
  • the method Before detecting that the first operating system has received a serial port switching instruction, the method also includes: after the second operating system is started, the second processor core triggers a first interrupt and sends a first signal to the first operating system; the first operating system detects the operating status of multiple serial ports in the chip according to the first signal to obtain a detection result; the first processor core triggers a second interrupt and sends the detection result to the second operating system through a second signal; and the second operating system receives the detection result to determine the number of serial ports in the chip that are operating normally.
  • the second processor core After the second processor core triggers the first interrupt and sends the first signal to the first operating system, it detects whether the first operating system receives the first signal; if the first operating system receives the first signal, the first operating system detects the operating status of multiple serial ports in the chip to obtain a detection result.
  • the second processor core triggers the first interrupt (IPI interrupt, IPI, inter processor interrupts) to send a first signal to the first operating system.
  • the first operating system can know from the first signal that the second operating system has been started normally and can interact normally with the second operating system.
  • the first operating system will detect the operating status of multiple serial ports in the chip according to the first signal to determine whether all serial ports are operating normally.
  • the first processor core triggers a second interrupt to send the detection result to the second operating system through a second signal.
  • the second operating system determines the number of switchable serial ports (i.e., the number of serial ports that are operating normally) through the detection result, so as to subsequently switch the serial ports.
  • the first operating system starts to block and wait for the serial port switching instruction issued by the second operating system.
  • the first operating system is RTOS
  • the second operating system is Linux
  • the first operating system runs on CPU0
  • the second operating system runs on CPU1.
  • the preparation steps before serial port switching include: when the Linux system on CPU1 is started to a specific stage, CPU1 will trigger an IPI interrupt to notify the RTOS system on CPU0 that Linux has been started normally and can interact normally with Linux on CPU1. After the RTOS system receives the IPI interrupt from CPU1, it will start the serial port switching controller program to check whether UART1, UART2, and UART3 are normal.
  • CPU0 triggers another IPI interrupt to notify the Linux operating system on CPU1 that the RTOS system has been started and reports
  • the information includes the number of switchable serial ports that the RTOS operating system on CPU0 has, and then the RTOS operating system on CPU0 starts to block and wait for the switching instruction issued by the operating system on CPU1.
  • a serial port switching instruction is sent to the first operating system through the service terminal; and the first operating system executes the serial port switching according to the serial port switching instruction.
  • the second operating system Since the second operating system has many functions and a large business volume, it may run abnormally or need to be restarted.
  • the serial port switching instruction can be directly sent to the first operating system through the service terminal to ensure that the first operating system performs the serial port switching normally.
  • the service terminal can be a terminal on the server where the chip is located.
  • the first operating system and the second operating system running in the same processor are used to replace the CPLD or FPGA to implement the serial port switching software function.
  • the second operating system receives the serial port switching instruction
  • the second operating system forwards the serial port switching instruction to the first operating system.
  • the first operating system implements the serial port switching according to the serial port switching instruction, thereby avoiding the use of hardware to implement serial port switching and reducing hardware costs.
  • the serial port switching can be completed quickly in a very short time. Therefore, the above process can not only effectively reduce the serial port switching cost, but also effectively improve the efficiency of serial port switching.
  • allocating a group of services to be allocated to corresponding operating systems in an embedded system according to a resource dynamic allocation rule includes:
  • the to-be-allocated business containing sensitive data for example, sensitive information such as passwords
  • sensitive data for example, sensitive information such as passwords
  • the target operating system is the operating system between the first operating system and the second operating system that has a low frequency of interaction with the user object, or an operating system with a fast response speed, for example, the first operating system.
  • the business processing module is responsible for further isolating the system business at the hard-core level of security protection, that is, dividing important sensitive businesses (not wanting to be exposed to users) into real-time businesses, and ultimately achieving the unloading of these businesses from non-real-time operating systems to real-time operating systems, thereby achieving the effect of security protection.
  • the different businesses divided by the business processing module can be organized in the form of structures during software implementation.
  • sensitive businesses refer to: security-related businesses, such as user passwords, identity information, and other businesses involving user personal privacy.
  • the hard-core level means that the business is isolated at the processor core level, that is, sensitive business is allocated to the real-time operating system (the core occupied by the real-time operating system is different from that of the non-real-time operating system, so it belongs to the core level isolation).
  • the frequency and degree of interaction between the real-time operating system and the user are relatively weak, so it is difficult for users as users to "detect" the sensitive data generated by the business running on it.
  • user identity authentication management, security encryption and other businesses belong to the above-mentioned important sensitive businesses.
  • the above-mentioned businesses are forcibly divided into real-time businesses. When the hardware resources are dynamically allocated later, the above-mentioned businesses can be realized in the real-time operating system, which has a safe isolation effect.
  • determining a resource allocation result corresponding to a group of services to be allocated includes:
  • the allocation result of a group of services to be allocated is used to indicate the corresponding relationship between the services to be allocated and the operating system.
  • the services to be executed allocated to an operating system are usually executed using the processing resources of the operating system. If the amount of services allocated to a certain operating system is too large and there are currently unallocated processing resources, the unallocated processing resources can also be allocated to the services to be allocated to the certain operating system. Therefore, according to the allocation result of a group of services to be allocated, combined with the resource utilization of the processing resources of the first operating system and the resource utilization of the processing resources of the second operating system, a resource mapping table of a group of services to be allocated and the processing resources of the processor can be generated to indicate the processing resources allocated to each service to be allocated.
  • each service to be allocated has a mapping relationship with only one processor core, while the same processor core can have a mapping relationship with multiple services to be allocated, and different services can have a mapping relationship with the same processor core by occupying different time slices of the same processor core.
  • the same processor core is occupied by only one service, that is, it is only used to execute one service.
  • Different services allocated to an operating system can determine the time slices that occupy the same processor resource according to the allocation time, service response speed requirements or other methods.
  • the resource dynamic allocation module dynamically adjusts the processor resources according to the output results of the business management module, forms a resource mapping table between different businesses and actual hardware resources, and optimizes the deployment structure of different hardware resources under heterogeneous operating systems to achieve the purpose of improving the utilization rate of hardware resources in the whole system.
  • the above resource dynamic allocation process is managed and configured by the software in the second operating system.
  • the processor cores that have been scheduled to the first operating system include: core 1
  • the processor cores that have been scheduled to the second operating system include: core 2, core 3 and core 4, there are 6 services to be allocated, the real-time services are service 1 and service 2, and the non-real-time services are service 3 to service 6.
  • the corresponding processor cores are allocated to the 6 services, core 1 is allocated to service 1, core 5 is allocated to service 2, core 2 is allocated to service 3, core 3 is allocated to service 4, core 4 is allocated to service 5, and core 6 is allocated to service 6.
  • allocating processing resources of a processor to a first operating system and a second operating system according to an operating system corresponding to each service to be allocated and a resource allocation result includes:
  • the unallocated processing resources are allocated to the operating system to which the to-be-allocated business corresponding to the unallocated processing resources is allocated.
  • the unallocated processing resources can be allocated to the operating system to which the unallocated business corresponding to the unallocated processing resources is allocated.
  • the resource adaptive scheduling module can complete the actual scheduling action of the processing resources of the processor according to the result of the dynamic allocation of hardware resources.
  • the resource adaptive scheduling module schedules a part of the processor cores to execute the services assigned to the first operating system, such as the M cores of the core group 1 shown in FIG4, and schedules the remaining processor cores to run the services assigned to the second operating system, such as the N cores of the core group 2 shown in FIG4.
  • the unallocated core 4 can be allocated to the first operating system, and the unallocated cores 5 and 6 can be allocated to the Linux system.
  • the entire scheduling process can be dominated by the second operating system.
  • unallocated processor resources are scheduled to the corresponding operating system based on the resource allocation result, so that the utilization rate of the processor resources can be improved.
  • the method further comprises:
  • the first operating system and the second operating system may preempt and release processing resources based on the usage status (load status) of the processing resources of the operating system.
  • the dynamic allocation of processing resources may be based on a resource scheduling method executed by other control logic modules other than the first operating system and the second operating system, and the preemption and release of processing resources is a resource scheduling method actively initiated by the first operating system and the second operating system.
  • the preemption and release of processing resources may be performed by a core preemption and release module, which may be A software module running on the first operating system and/or the second operating system.
  • the core preemption and release module mainly completes the dynamic preemption and release of the processor core by the heterogeneous operating system during the real-time operation of the system to achieve the goal of maximizing the processor resource utilization.
  • the successful resource preemption of one operating system means the successful resource release of another operating system.
  • the failure of resource preemption of one operating system means the failure of resource release of another operating system.
  • P cores out of (M+N) cores are scheduled to the real-time operating system, and (M+NP) cores are scheduled to the non-real-time operating system.
  • the core preemption and release module can be used to complete the real-time operation of the heterogeneous operating system.
  • the heterogeneous operating system dynamically preempts and releases processing resources such as processor cores to achieve the goal of maximizing processor resource utilization.
  • processing resources can be dynamically adjusted based on the load conditions of the operating systems during their operation, thereby improving the rationality of resource utilization and, at the same time, improving the efficiency of business processing.
  • preempting and releasing processing resources between a first operating system and a second operating system includes:
  • the communication bus rate between the processor and the acceleration hardware (for example, CPU and FPGA/CPLD) is low, and the overall performance is not high.
  • the preemption and release of processing resources are performed between the first operating system and the second operating system through the inter-core communication interface, that is, one operating system can send a request for preempting processing resources or a request for requesting the release of processing resources to another operating system through the inter-core communication interface to realize the preemption or release of processing resources.
  • interacting through the inter-core communication interface inside the processor has a higher communication rate, which improves the overall performance of communication.
  • the inter-core communication interface module can be used to complete the communication and interaction functions between the first operating system and the second operating system.
  • the preempting party and the releasing party can inform each other of their respective states (such as busy and idle states) through the inter-core communication interface, and specific signal events are also required to characterize the behavior of the heterogeneous operating system (such as preemption behavior). Therefore, by performing core preemption and release through the inter-core communication interface module, the hard core resource balance of the heterogeneous operating system can be maintained, ensuring that the processor has a high occupancy rate.
  • inter-core interrupts for example, SGI (Software Generated Interrupt, software-triggered interrupt, inter-core interrupt in Linux system)
  • one operating system can send a resource preemption request (for example, core preemption request) or a resource release request (for example, core release request) to another operating system through IPI (Inter Processor Interrupt, inter-processor interrupt) to request the preemption or release of processing resources.
  • IPI Inter Processor Interrupt, inter-processor interrupt
  • IPI is an interrupt triggered between multiple cores in a SOC (System on Chip, also known as a system on chip), which is different from common peripheral interrupts, so the core can reserve some interrupt numbers specifically for IPI, which are 16 interrupt numbers 0-15 on the ARM 64 architecture (a CPU architecture).
  • the preemption and release process depends on the real-time load conditions of the heterogeneous operating systems. For example, when the load of the second operating system increases rapidly and more processor cores are needed to support it, it can send a core preemption request to the first operating system via IPI to preempt the processor core of the first operating system. If the first operating system is idle at this time (for example, no task scheduling) or at least some of the core resources are idle, it will release the core resources to the second operating system. At this time, the second operating system core preemption is successful, which also means that the first operating system core is successfully released.
  • the core preemption and release process is a dynamic and cyclic process. Each core preemption and release is accompanied by the adjustment of the processor hard core resources. As shown in Figure 5, after one preemption and release, the number of cores in core group 1 becomes P, and the number of cores in the core group becomes M+N-P.
  • the core preemption and release process can coordinate with load balancing strategy, business management, resource adaptive scheduling (for example, core adaptive scheduling) and other modules to jointly determine the final core adjustment result.
  • different modules jointly determine the core adjustment result means that when a system needs to seize more core resources, the final success of the seizure needs to be jointly determined by modules such as load balancing strategy, business management, and core adaptive adjustment.
  • modules such as load balancing strategy, business management, and core adaptive adjustment.
  • the first operating system will soon wake up and run an important business thread, and the thread also needs a lot of resources when running.
  • the first operating system cannot release core resources to the second operating system.
  • the criteria for judging the importance of services and the final resource allocation to the second operating system will involve the participation of modules such as load balancing strategy, service management, and core adaptive adjustment.
  • the strategies of each of these modules also contain the characteristics of openness, which determines that the final core adjustment result determined by them together is also the result of the joint action of these strategies.
  • the processing resources between different operating systems are preempted and released through the inter-core communication interface, which can increase the communication rate and improve the overall performance of communication.
  • preempting and releasing processing resources between a first operating system and a second operating system through an inter-core communication interface includes:
  • S112 Obtain, through the inter-core communication interface, a first interaction response returned by the second operating system in response to the first interaction request, wherein the first interaction response is used to instruct the first operating system to perform resource interaction with the second operating system according to the first interaction response.
  • the service volume of the services processed by the first operating system is usually small, so the first operating system can request to seize the processing resources of the second operating system through the inter-core communication interface or actively release the processing resources occupied by it to the second operating system.
  • the seizure and release of processing resources can be performed in a request-response interaction manner.
  • the first operating system can transmit the first interaction request of the first operating system to the second operating system through the inter-core communication interface to request a resource interaction of resource seizure and resource release with the second operating system.
  • the second operating system can determine whether to allow the first operating system to occupy at least part of its processing resources or whether to accept the processing resources released by the first operating system based on its own load conditions, and return the first interaction response to the first operating system through the inter-core communication interface, so that the first operating system can interact with the second operating system for resources according to the first interaction response.
  • preemption and release of processing resources is the scheduling of processing resources at the operating system level (that is, the negotiation of processing resource scheduling is completed between the first operating system and the second operating system), and is not the actual scheduling of processing resources.
  • the actual scheduling of processing resources is performed, the actual scheduling of processing resources is completed by the resource adaptive scheduling module.
  • resource interaction between different operating systems is performed in a request-response manner, and an operating system with a fast response speed is allowed to actively release processing resources to an operating system with a slow response speed, thereby improving the utilization rate of processing resources.
  • the method further comprises:
  • S122 When it is determined, based on the resource utilization of the processing resources of the first operating system, that the first operating system is to perform resource interaction with the second operating system, trigger transmission of a first interaction request to the second operating system through an inter-core communication interface.
  • the process of preempting and releasing processing resources may depend on the real-time load of heterogeneous operating systems.
  • a load detection module for detecting the load of the system may be run, which may belong to the system control module in the system.
  • a first system control module may be run thereon.
  • the load detection module in the system control module may detect the resource utilization of the processing resources of the first operating system.
  • the resource utilization of the processing resources of the first operating system may be used to indicate the load of the first operating system. The higher the resource utilization of the processing resources, the heavier the system load. Conversely, the lower the resource utilization of the processing resources, the lighter the system load.
  • the first operating system Based on the resource utilization of the processing resources of the first operating system, it can be determined whether the first operating system needs to interact with the second operating system for resources. For example, if the current resource utilization of an operating system (e.g., the first operating system) is too high (reaches a specified utilization threshold), or based on a pending business of an operating system, it is determined that the future resource utilization of the operating system is too high (reaches a specified utilization threshold), it can be determined that the operating system needs to seize the processing resources of another operating system (e.g., the second operating system). If the resource utilization is too low (lower than another specified utilization threshold), it can be determined that the operating system needs to release processing resources to the other operating system. Optionally, if it is determined that the first operating system is to interact with the second operating system for resources, the execution of transmitting the first interaction request to the second operating system through the inter-core communication interface can be triggered. System steps.
  • resource interaction between different operating systems is performed in a request-response manner, and an operating system with a fast response speed is allowed to actively release processing resources to an operating system with a slow response speed, thereby improving the utilization rate of processing resources.
  • the method further includes at least one of the following:
  • S132 When the processing resources of the first operating system are in an idle state and there is no business to be executed by the first operating system, determine that the processing resources of the first operating system are to be released to the second operating system.
  • a threshold value of the resource utilization of the processing resources of the first operating system can be set in advance. If the resource utilization of the processing resources of the first operating system is greater than or equal to the first utilization threshold value, it can be determined that the current load of the first operating system is too heavy and needs to seize the processing resources of the second operating system to meet its own business needs.
  • the response speed of the first operating system is higher than that of the second operating system, it is usually used in some specific services, but the triggering of the specific services is random and the service frequency is usually low, so the processing resources of the first operating system are likely to be idle and there is no service to be executed by the first operating system. In this case, it can be determined that the first operating system is to release at least part of the processing resources to the second operating system.
  • the queue of pending services corresponding to the first operating system can be searched. If the queue of pending services is empty (i.e., there is no pending service), it is determined that there is no pending service in the first operating system within a certain time range. If the queue of pending services is not empty (i.e., it contains pending services), even if the first operating system is not currently executing any service, it will not release processing resources to the second operating system.
  • the method further comprises:
  • the first operating system may run periodically based on the processor; or, the first operating system runs based on the processor in response to a received wake-up request; or, the first operating system runs based on the processor according to the matching degree between the current operating business generated on the processor and the first operating system.
  • the first operating system may go into hibernation after the operation ends; the second operating system adds the processor resources (e.g., processor cores) used by the first operating system to the scheduling resource pool (i.e., available resource pool) of the second operating system during the hibernation period of the first operating system.
  • the active hibernation of the first operating system can be triggered, that is, the first operating system actively enters the hibernation state.
  • the core resources of the first operating system can be first released to the second operating system (resource release can be performed by way of an interrupt request); the system field data of the first operating system can also be saved, for example, the above data can be pushed into the stack, so that after the first operating system is awakened, it can be restored to the previous operating state based on the saved system field data.
  • the first operating system when the first operating system has no task scheduling (ie, is in an idle state), the first operating system sends a core release request to the second operating system. At this time, the core resources of the first operating system will be taken over by the second operating system, and the first operating system enters a dormant state.
  • a first operating system e.g., RTOS
  • the first operating system and the second operating system alternately occupy and schedule the same processing resource (which may be a processor core, for example, CPU core 0).
  • the same processor resource may be the first processing resource, and correspondingly, the processing resource of the second operating system may be the second processing resource.
  • the second operating system generates an interrupt at a first moment to take over the first processing resource, causing the first operating system to have to sleep.
  • the first operating system saves the scene in the stack, sleeps, and then releases the first processing resource to the second operating system to take over.
  • an interrupt will be generated at a second moment for the first operating system to preempt the first processing resource to wake up the first operating system.
  • the first operating system will be awakened from that moment. It starts to enter the round-robin mode again and occupies the first processing resource of the scheduling.
  • the first operating system is in a dormant state.
  • the first operating system may be awakened due to an interrupt event reported by the hardware.
  • the second operating system will retain the process running on the first processing resource on site.
  • the first operating system occupies the first processing resource, and after processing the interrupt event reported by the hardware, it enters a dormant state again at the fourth moment.
  • the first operating system reports the interrupt of releasing the first processing resource to the second operating system, and the second operating system continues to schedule the first processing resource according to the set period and resumes the on-site running process.
  • the duration of a single operation cycle and the interval duration between two operation cycles may be the same or different.
  • the first operating system may be, but is not limited to, in a dormant state, and the processing resources allocated to the first operating system are used by the second operating system. If the duration of a single operation cycle is the same as the interval duration between two operation cycles, the first operating system and the second operating system alternately occupy the same duration of the processing resources allocated to the first operating system. If the duration of a single operation cycle is different from the interval duration between two operation cycles, the first operating system and the second operating system alternately occupy different durations of the processing resources allocated to the first operating system.
  • the duration occupied by the first operating system may be greater than the duration occupied by the second operating system, or the duration occupied by the second operating system may be greater than the duration occupied by the first operating system.
  • a wake-up strategy for the first operating system (such as RTOS) in a trigger mode.
  • the trigger mode can be started by an interrupt initiated by a device in the first operating system bus domain.
  • the first operating system bus domain connects device 0 to device N.
  • device 0 triggers an interrupt to the first operating system at a certain moment, and the first operating system is immediately awakened.
  • the first operating system first triggers an interrupt to seize the first processing resource to the second operating system.
  • the second operating system first releases the first processing resource and saves the scene (pushes the running data into the stack). Then the first operating system schedules the first processing resource to process the operation business indicated by the interrupt triggered by device 0. If it is currently in polling mode, the subsequent processing process is the same as the above polling mode, which will not be repeated here.
  • the operating system when all processing resources (for example, core resources) of one operating system have been released to another operating system and the occupied processing resources are zero, the operating system is controlled to enter a sleep state. Since the operating system is allowed to release all processing resources to another operating system, the utilization rate of the processing resources is improved.
  • processing resources for example, core resources
  • transmitting the first interaction request of the first operating system to the second operating system through the inter-core communication interface includes at least one of the following:
  • S152 Transmitting a resource release request with the second interrupt number as the interrupt number to the second operating system through the inter-core communication interface, wherein the resource release request is used to request to release the processing resources occupied by the resource release system to the second operating system.
  • the preemption and release of processing resources between different operating systems can be completed through inter-core interrupts.
  • Different interrupt events can be defined for different resource interaction types, and different interrupt events can correspond to different interrupt numbers, wherein the interrupt number assigned to the first interrupt event in which the first operating system applies to the second operating system for preempting processing resources is the first interrupt number, and the interrupt number assigned to the second interrupt event in which the first operating system actively releases processing resources to the second operating system is the second interrupt number.
  • the first interaction request may be a first preemption request, i.e., a request for preempting the processing resources of the second operating system.
  • the first operating system may transmit the first preemption request with the interrupt number being the first interrupt number to the second operating system through the inter-core communication interface, i.e., the trigger source of the inter-core communication interrupt with the interrupt number being the first interrupt number is the first operating system, and the response source is the second operating system.
  • the inter-core communication interrupt is that the first operating system preempts the processing resources of the second operating system.
  • the first interaction request may be a resource release request, i.e., a request for releasing the processing resources occupied by the first operating system to the second operating system.
  • the first operating system may transmit the resource release request with the interrupt number being the second interrupt number to the second operating system through the inter-core communication interface, i.e., the trigger source of the inter-core communication interrupt with the interrupt number being the second interrupt number is the first operating system, and the response source is the second operating system.
  • the inter-core communication interrupt is that the first operating system actively releases the processing resources to the second operating system.
  • preempting and releasing processing resources between a first operating system and a second operating system through an inter-core communication interface includes:
  • S162 Obtain, through the inter-core communication interface, a second interaction response returned by the first operating system in response to the second interaction request, wherein the second interaction response is used to indicate whether the first operating system allows the second operating system to preempt processing resources of the first operating system.
  • the second operating system considering that most of the services processed by the processor are services that do not require high service response speed, correspondingly, the service volume of the services processed by the second operating system is usually large, so the second operating system can request to seize the processing resources of the first operating system through the inter-core communication interface.
  • the preemption of processing resources can be performed in a request-response interaction manner.
  • the second operating system can transmit the second interaction request of the second operating system to the first operating system through the inter-core communication interface to request to interact with the first operating system for resource seizure.
  • the first operating system can determine whether to allow the second operating system to occupy at least part of its processing resources based on its own load conditions, and return the second interaction response to the second operating system through the inter-core communication interface, so that the second operating system can interact with the first operating system for resources according to the second interaction response.
  • preemption of processing resources is the scheduling of processing resources at the operating system level (that is, the negotiation of processing resource scheduling is completed between the first operating system and the second operating system), and is not the actual scheduling of processing resources.
  • the actual scheduling of processing resources is performed, the actual scheduling of processing resources is completed by the resource adaptive scheduling module.
  • the utilization rate of processing resources can be improved, and at the same time, the response speed of business processing can also be improved.
  • the method further comprises:
  • S172 When it is determined, based on the resource utilization of the processing resources of the second operating system, that the second operating system is to preempt the processing resources of the first operating system, trigger transmission of a second interaction request to the first operating system through the inter-core communication interface.
  • the preemption process of processing resources may depend on the real-time load of the heterogeneous operating system.
  • a load detection module for detecting the load of the system may be run, which may belong to the system control module in the system.
  • a second system control module may be run thereon.
  • the load detection module in the system control module may detect the resource utilization rate of the processing resources of the second operating system.
  • the resource utilization rate of the processing resources of the second operating system may be used to indicate the load of the second operating system. The higher the resource utilization rate of the processing resources, the heavier the system load. Conversely, the lower the resource utilization rate of the processing resources, the lighter the system load.
  • the second operating system it can be determined whether the second operating system needs to interact with the first operating system for resources. For example, if the current resource utilization is too high (reaches a specified utilization threshold) or the future resource utilization is determined to be too high (reaches a specified utilization threshold) according to the business to be executed, it can be determined that the second operating system needs to seize the processing resources of the first operating system. If it is determined that the second operating system is to interact with the first operating system for resources, the step of transmitting the second interaction request to the first operating system through the inter-core communication interface can be triggered.
  • resource interaction between different operating systems is performed in a request-response manner, and an operating system with a slow response speed is allowed to actively seize processing resources of an operating system with a fast response speed, thereby improving the utilization rate of processing resources.
  • the method further includes at least one of the following:
  • the second operating system can comprehensively consider its own resource utilization, its to-be-allocated businesses, to-be-executed businesses and other factors to determine whether it needs to preempt the processing resources of the first operating system.
  • a threshold for the resource utilization of the processing resources of the second operating system i.e., a second utilization threshold, can be pre-set. If the resource utilization of the processing resources of the second operating system is greater than or equal to the second utilization threshold, it can be determined that the second operating system is currently overloaded and needs to seize the processing resources of the first operating system to meet its own business needs.
  • a threshold for the resource utilization of the processing resources of the second operating system can be pre-set, that is, a third utilization threshold. If it is determined that the resource utilization of the processing resources of the second operating system is greater than or equal to the third utilization threshold based on the executing business of the second operating system and the pending business of the second operating system, it can be determined that the second operating system is about to preempt the processing resources of the first operating system. It can be determined that the second operating system is about to be in an overloaded state and needs to preempt the processing resources of the first operating system to meet its own business needs.
  • the second operating system may also process the business currently to be allocated (i.e., the newly added business to be allocated) that has a high business coupling degree with its allocated business. Therefore, the threshold of the resource utilization rate of the processing resources of the second operating system, i.e., the fourth utilization threshold, and the threshold of the business coupling degree between the newly added business to be allocated and the allocated business, i.e., the third coupling threshold, can be set in advance.
  • the second operating system is about to be in an overloaded state and needs to seize the processing resources of the first operating system to meet its own business needs.
  • the second utilization threshold and the third utilization threshold may be the same or different, for example, both may be 50%, 60% or other values, and the fourth utilization threshold may be a value smaller than the second utilization threshold and the third utilization threshold, for example, 40%, or other utilization thresholds.
  • no limitation is imposed on the various utilization thresholds.
  • the resource scheduling requirements of the operating system are determined based on the currently executing business of the operating system, the currently executing business and the allocated business, or the currently executing business and the allocated business and the newly added business to be allocated, which can improve the flexibility of resource scheduling and at the same time, improve the utilization rate of processing resources.
  • the method further comprises:
  • S192 When the service priority of the service being executed by the first operating system is lower than the service priority of the service to be executed by the second operating system, determine whether the first operating system allows the second operating system to preempt processing resources of the first operating system.
  • the first operating system For the first operating system, if it is currently in an idle state and there is no assigned business to be executed, or there is no to-be-assigned business that must be assigned to the first operating system, the first operating system can directly determine to allow the second operating system to occupy its own processing resources. If the first operating system is currently processing a business, there is an assigned business to be executed, or there is an to-be-assigned business that must be assigned to the first operating system, it is necessary to comprehensively consider factors such as the business priority of the above-mentioned business to determine whether to allow the second operating system to occupy the processing resources of the first operating system.
  • the service priority of the business being executed by the first operating system is not lower than the service priority of the business to be executed by the second operating system, it means that the urgency of the business being executed by the first operating system is not lower than the urgency of the business to be executed by the second operating system, and the first operating system refuses the second operating system to preempt the processing resources of the first operating system. If the service priority of the business being executed by the first operating system is lower than the service priority of the business to be executed, it means that the urgency of the business being executed by the first operating system is lower than the urgency of the business to be executed by the second operating system, and it is determined that the first operating system allows the second operating system to preempt the processing resources of the first operating system.
  • resource preemption can be determined based on service priority. It can also be considered that preemption of processing resources is allowed only when the service priorities of the executing services and pending services of the first operating system are not lower than the service priorities of the pending services of the second operating system.
  • transmitting the second interaction request of the second operating system to the first operating system through the inter-core communication interface includes:
  • the preemption and release of processing resources between different operating systems can be accomplished through inter-core interrupts, and different interrupt events can be defined for different resource interaction types, and different interrupt events can correspond to different interrupt numbers, wherein the interrupt number assigned to the third interrupt event in which the second operating system applies to the first operating system for preempting processing resources is the third interrupt number.
  • the second interaction request may be a second preemption request, that is, in a request to preempt the processing resources of the first operating system
  • the second operating system may transmit the second preemption request with the interrupt number being a third interrupt number to the first operating system through the inter-core communication interface, that is, the trigger source of the inter-core communication interrupt with the interrupt number being the third interrupt number is the second operating system, and the response source is the first operating system, and the meaning of this inter-core communication interrupt is that the second operating system preempts the processing resources of the first operating system.
  • obtaining, through the inter-core communication interface, a second interactive response returned by the first operating system in response to the second interactive request includes at least one of the following:
  • the preemption and release of processing resources between different operating systems can be accomplished through inter-core interrupts, and different interrupt events can be defined for different resource interaction types, and different interrupt events can correspond to different interrupt numbers, wherein the interrupt number assigned to the fourth interrupt event and the fifth interrupt time for the second operating system to apply to the second operating system to return a resource preemption response is the fifth interrupt number, wherein the fourth interrupt event is an interrupt event that allows resource preemption, and the fifth interrupt event is an interrupt event that rejects resource preemption.
  • the first operating system may transmit a resource release allowing response with interrupt number being the fourth interrupt number to the second operating system through the inter-core communication interface, that is, the trigger source of the inter-core communication interrupt with interrupt number being the fourth interrupt number is the first operating system, and the response source is the second operating system.
  • the inter-core communication interrupt is that the first operating system passively releases processing resources to the second operating system.
  • the first operating system may transmit a resource release refusal response with the interrupt number being the fifth interrupt number to the second operating system through the inter-core communication interface, that is, the trigger source of the inter-core communication interrupt with the interrupt number being the fifth interrupt number is the first operating system, and the response source is the second operating system.
  • the inter-core communication interrupt is that the first operating system refuses to release processing resources to the second operating system.
  • resource scheduling between operating systems is performed through inter-core communication interrupts, thereby improving the accuracy of resource scheduling.
  • inter-core communication can be achieved based on a custom interrupt vector table and interrupt events between heterogeneous operating systems.
  • the Linux operating system makes full use of the undefined bit numbers of SGI to customize terminal signals and reduce the cost of inter-core communication.
  • the undefined bit numbers can be 8-15.
  • 8-15 (a total of 8 interrupts) are used to represent the inter-core interrupt vector table.
  • Table 1 A feasible allocation scheme for the vector table is shown in Table 1:
  • the aforementioned first interrupt number corresponds to interrupt number 12
  • the aforementioned second interrupt number corresponds to interrupt number 8
  • the aforementioned third interrupt number corresponds to interrupt number 9
  • the aforementioned fourth interrupt number corresponds to interrupt number 10
  • the aforementioned fifth interrupt number corresponds to interrupt number 11.
  • active release means when the RTOS system has no business scheduling (i.e., it is in an idle state), an SGI interrupt with an interrupt number of 8 is sent to the Linux system. At this time, the core resources of the RTOS will be taken over by the Linux system, and the RTOS system enters a dormant state.
  • Passive release means when the business load of the Linux system increases sharply, an SGI interrupt with an interrupt number of 9 is sent to the RTOS system. If the process being executed by the RTOS system at this time allows interruption (the processes on the RTOS system have priorities, which can be configured according to actual conditions.
  • the RTOS system will send an SGI interrupt with an interrupt number of 10 to the Linux system and passively release its occupied CPU core resources for Linux system scheduling. After that, the RTOS system enters a dormant state. If the RTOS system does not allow interruption at this time, it will send an SGI interrupt with an interrupt number of 11 to the Linux system to inform the Linux system that the core resources of the RTOS cannot be released at this time. At this time, the Linux system will continue to execute according to the current operation strategy without change.
  • inter-core communication vector table is not unique and is not limited to the inter-core communication vector table defined in Table 1 above.
  • a method for inter-core communication comprises the following steps:
  • Step 1 The first operating system sends target data (which may be business data) to a target virtual channel (which may be storage space) in the processor memory.
  • target data which may be business data
  • target virtual channel which may be storage space
  • the target data is data to be sent
  • the target virtual channel is a free storage space in the memory
  • the first operating system sending the target data to the target virtual channel in the processor memory means that the CPU core of the first operating system writes the data to be sent into the target virtual channel.
  • Step 2 The first operating system sends an interrupt notification message (which may be the aforementioned inter-core interrupt request) to the second operating system.
  • the CPU core of the first operating system sends an interrupt notification message to the CPU core of the second operating system.
  • the interrupt notification message may carry the address of the target virtual channel to notify the second operating system to obtain the target data from the target virtual channel.
  • the interrupt notification message may be triggered by software or hardware.
  • Step 3 The second operating system responds to the interrupt notification message and obtains the target data from the target virtual channel in the memory.
  • the CPU core of the second operating system responds to the interrupt notification message, parses the address of the target virtual channel from the interrupt notification message, and then locates the target virtual channel in the memory according to the parsed address, and obtains the target data from the target virtual channel, thereby realizing data interaction between the first operating system and the second operating system.
  • the first operating system sending data sends the target data to the target virtual channel in the processor memory, and sends an interrupt notification message to the second operating system.
  • the second operating system receiving the data responds to the interrupt notification message to obtain the target data from the target virtual channel, thereby solving the problem of waste of resources and strong dependence on the operating system in the inter-core communication process, and achieving the effect of reducing the waste of resources and dependence on the operating system in the inter-core communication process.
  • the memory includes a data storage area and a metadata storage area.
  • the data storage area is divided into multiple storage units, each storage unit is used to store business data, and the metadata storage area is used to store the size and occupancy status of each storage unit in the data storage area.
  • the target virtual channel is composed of one or more storage units in the data storage area
  • the metadata storage area can be divided into storage slices with the same number as the storage units, each storage slice is used to record the size and occupied status of a storage unit
  • the size of the storage unit can be represented by the first address and the last address of the storage unit, or by the first address and the length of the storage unit
  • the occupied status includes the occupied state and the unoccupied state, and can be represented by the value of the free flag.
  • the first operating system sends the target data to the target virtual channel in the processor memory, including: the first operating system The system reads records in the metadata storage area, determines at least one storage unit in the data storage area that is in an idle state and has a total space greater than or equal to the length of the target data according to the read records, and obtains a target virtual channel; sets the state of at least one storage unit corresponding to the target virtual channel in the metadata storage area to an occupied state, and stores the target data in the target virtual channel.
  • the target virtual channel to be written needs to be free and have storage space that is greater than or equal to the length of the target data. Since the memory is divided into a metadata storage area and a data storage area, the occupancy status of each storage unit recorded in the metadata storage area can be read to find out the storage unit that is free and can meet the data storage requirements.
  • each storage unit is equal. If the length of the target data is greater than the length of a storage space, the number of storage units required is determined based on the length of the target data, and multiple storage units that are idle, continuous, and meet the data storage requirements are found to form a target virtual channel.
  • each storage unit is equal, and the data storage area has pre-combined the storage units to obtain multiple virtual channels of different sizes.
  • Each virtual channel is composed of one or more storage units.
  • the occupancy status of each virtual channel recorded in the metadata storage area can be read to find the virtual channel that is in an idle state and has a length greater than the length of the target data, that is, the target virtual channel.
  • the system software needs to apply for shared memory space, it will determine whether the length of the data to be applied is greater than the maximum length of the virtual channel to store data. If it is greater than the maximum length of the virtual channel to store data, the system software can send the data to be sent in multiple times to ensure that the length of each sent data is less than or equal to the maximum length of the virtual channel to store data, thereby ensuring smooth communication.
  • the second operating system responds to an interrupt notification message and obtains target data from a target virtual channel in the memory, including: the second operating system reads a record in a metadata storage area and determines the target virtual channel based on the read record; obtains the target data from at least one storage unit corresponding to the target virtual channel, and sets the state of the at least one storage unit to an idle state.
  • the state of the storage unit corresponding to the target virtual channel is set to an idle state.
  • the first operating system sends target data to a target virtual channel in a processor memory, including: a driver layer of the first operating system receives the target data, determines a virtual channel in an idle state in the memory, and obtains the target virtual channel; sets the state of the target virtual channel to an occupied state, and stores the target data in the target virtual channel.
  • both the real-time operating system and the non-real-time operating system have a driver layer.
  • the driver layer After the driver layer receives the target data to be sent, it calls an interface to search for a target virtual channel in the memory.
  • the state of the target virtual channel is set to an occupied state, and then the target data is written to the target virtual channel.
  • the application layer when the first operating system includes an application layer, the application layer is provided with a human-computer interaction interface. Before the driver layer of the first operating system determines a virtual channel in an idle state in the memory, the application layer of the first operating system can receive the data to be sent input by the user through the human-computer exchange interface, encapsulate the data to be sent in a preset format, obtain the target data, and call the data write function to pass the target data to the driver layer through the preset communication interface, wherein the preset communication interface is provided on the driver layer.
  • the application layer fills the data to be sent according to a preset format to obtain the target data, and then generates a device file ipidev in the system's /dev path.
  • the application layer needs to read and write data from the driver layer, it can first use the system's built-in open function to open the device file /dev/ipidev, and then use the system's built-in write function to send the target data from the application layer to the driver layer.
  • the driver layer then puts the data in the target virtual channel in the shared memory, and then triggers an interrupt to notify the second operating system to fetch the data.
  • the second operating system responds to the interrupt notification message and obtains target data from the target virtual channel in the memory, including: the second operating system triggers an interrupt processing function based on the interrupt notification message, determines the target virtual channel from the memory through the interrupt processing function, and obtains the target data from the target virtual channel.
  • determining the target virtual channel from the memory through the interrupt processing function and obtaining target data from the target virtual channel includes: calling the target task through the interrupt processing function, and the target task determining the target virtual channel from the memory and obtaining target data from the target virtual channel.
  • the interrupt handler sends a task notification to wake up the target task responsible for data extraction.
  • the target task first calls the interface in the shared memory. Find the target virtual channel, then read the target data from the target virtual channel and perform data analysis.
  • a function identifier is stored in the memory, the function identifier indicates a target function, and a target virtual channel is determined from the memory through an interrupt processing function, and target data is obtained from the target virtual channel, including: determining the function identifier and the target virtual channel from the memory through an interrupt processing function, and sending the address information of the target virtual channel to a target application matched by the function identifier, wherein the target application is a target application in the application layer; the target application calls a data reading function to pass the address information to the driver layer through a preset communication interface, the driver layer obtains the target data from the target virtual channel, and passes the target data to the target application layer program, wherein the preset communication interface is set at the driver layer, and the target application processes the target data according to the processing function matched by the function identifier to execute the target function.
  • the application layer calls the corresponding interrupt processing function to search the target virtual channel from the memory, obtains the address information of the target virtual channel, and then generates a device file ipidev in the system's /dev path.
  • the application layer needs to read and write data from the driver layer, it can first use the system's built-in open function to open the device file /dev/ipidev, and then use the system's built-in read function to read the target data in the target virtual channel. That is, the driver layer finds the corresponding target data in the shared memory according to the address information of the target virtual channel, and returns the target data and the length of the target data to the application layer.
  • the state of the target virtual channel is set to idle.
  • Function identifiers are stored in the memory, indicating the target functions implemented by the application through the target data.
  • the function identifier can be Net or Cmd.
  • the driver layer can find the PID of the application based on the received NetFn and Cmd, and send the data to the corresponding application based on the PID.
  • an array will be initialized.
  • the array has three columns, the first column is NetFn, the second column is Cmd, and the third column corresponds to the processing function of NetFn and Cmd is recorded as xxCmdHandler.
  • a data storage area includes multiple memory channels, each memory channel is composed of one or more storage units, a metadata storage area stores multiple records, each record is used to record metadata of a memory channel, and the metadata of each memory channel at least includes a channel ID of the memory channel, a size of the memory channel, and an occupied state of the memory channel.
  • a first operating system reads the records in the metadata storage area, and determines at least one storage unit in the data storage area that is in an idle state and has a total space greater than or equal to the length of target data based on the read records.
  • Obtaining the target virtual channel includes: traversing the records stored in the metadata storage area, and determining whether there is a first target record indicating that the memory channel is in an idle state and the size of the memory channel is greater than or equal to the length of the target data; if the first target record exists, determining the memory channel indicated by the channel ID recorded in the first target record as the target virtual channel.
  • the data storage area can be divided into n virtual memory channels, and the size of each memory channel can be different, that is, the sizes of the n virtual channels are 20*m, 21*m, 22*m, 23*m...2n-1*m, where m is the size of a storage unit, and the following structure is set as metadata to manage the memory channel:
  • uint32_t Flag represents the status of the memory channel. For example, 0xA5A5A5A5 means that this channel is not empty, otherwise it is empty; uint16_t ChannelId represents the channel ID; uint8_t SrcId represents the source CPU ID, and the source CPU is the CPU that writes data to the memory channel; uint8_t NetFn and uint8_t Cmd are function parameters; uint32_t Len is the length of the data stored in the memory channel; uint32_t ChannelSize represents the size of the memory channel; uint8_t*pData refers to the first address of the memory channel; uint8_t CheckSum refers to the checksum.
  • Each virtual memory channel corresponds to a structure record, which will be stored at the beginning of the shared memory in ascending order of channel ID. These structure records will be initialized after the system is powered on.
  • the initialization Flag is 0 to indicate that the channel is empty.
  • the initialization ChannelId is 0, 1, 2...n-1 in sequence.
  • the initialization ChannelSize is the size of the corresponding virtual memory channel.
  • the initialization pData points to the first address of the corresponding virtual memory channel.
  • the first operating system uses the interface GetEmptyChannel to search for a virtual channel that meets the following two conditions in all memory channels according to the size of the target data to be sent: the idle flag Flag in the channel structure IpiHeader is not equal to 0xA5A5A5A5 (that is, the channel is in an idle state), and the channel size ChannelSize in the channel structure IpiHeader is greater than or equal to the size of the target data (that is, the memory size can meet the storage requirements of the target data).
  • the metadata of the memory channel when a memory channel is occupied, the metadata of the memory channel also includes the ID of the source CPU core of the target data and the ID of the destination CPU core of the target data, and the second operating system reads the records in the metadata storage area, and determines the target virtual channel according to the read records, including: traversing the records stored in the metadata storage area, and determining whether there is a second target record, wherein the second target record indicates that the memory channel is in an occupied state, and the ID of the destination CPU core is the ID of the CUP core of the second operating system, and the ID of the source CPU core is not the ID of the CUP core of the second operating system; when the second target record exists, the memory channel indicated by the channel ID recorded in the second target record is determined as the target virtual channel.
  • the target virtual channel is the virtual channel among all channels that meets the following three conditions: first, the idle flag Flag in the channel structure IpiHeader is equal to 0xA5A5A5A5 (that is, indicating that the channel is occupied); second, the TargetId in the channel structure is equal to the ID of the current CPU (that is, indicating that the destination CUP of the target data is the CPU of the second operating system); third, the TargetId in the channel structure is not equal to SrcId (that is, indicating that the target data is not sent by the CPU of the second operating system).
  • the idle flag Flag is set to a multi-bit special character, for example, 0xA5A5A5A5. Since the probability of multiple bits mutating to special characters at the same time is much smaller than the probability of a single bit mutation, it can prevent the storage medium bit mutation from affecting the Flag value, thereby improving the security of communication.
  • a metadata storage area stores a state mapping table, wherein the state mapping table contains a plurality of records, each record being used to record the occupied state of a storage unit, and a first operating system reads the records in the metadata storage area, and determines at least one storage unit in the data storage area that is in an idle state and whose total space is greater than or equal to the length of the target data based on the read records, and obtaining the target virtual channel comprises: determining a preset number of storage units to be occupied by the target data; scanning each record in sequence from an initial position in the state mapping table; when a preset number of consecutive target records are scanned, determining the consecutive storage units indicated by the preset number of target records, wherein the target records indicate that the storage unit is in an idle state; and determining the consecutive storage units as the target virtual channel.
  • the first operating system traverses the records from an index position in the state mapping table, where the index position may be the starting position of the state mapping table.
  • the index position may be the starting position of the state mapping table.
  • each record of the state mapping table is queried in turn to determine whether there are continuous records of free memory pages greater than or equal to numb. If there are records that meet the above conditions, the continuous storage unit in the processor is determined through the correspondence between the record and the memory page, and the continuous storage unit is determined as the target virtual channel to write data to the target virtual channel.
  • the interrupt notification message includes the starting address and a preset number of continuous storage units
  • the second operating system reads the records in the metadata storage area, and determines the target virtual channel based on the read records, including: scanning each record in sequence from the initial position of the status mapping table; when the starting address of the continuous storage unit is scanned, the storage unit indicated by the scanned address and the preset number minus one of the continuous storage units are determined as the target virtual channel.
  • a continuous storage unit refers to a continuous storage unit whose number is equal to numb, and each record in the status mapping table also records the first address of the corresponding storage unit.
  • the second operating system scans a record of the first address of a continuous storage unit whose number is equal to numb in the mapping table, it indicates that the first address of the target virtual channel has been scanned, and the storage unit indicated by the first address and numb-1 continuous storage units after the storage unit constitute the target virtual channel.
  • the second operating system obtains data from the target virtual channel to complete data interaction with the first operating system.
  • the scanned continuous target records are recorded by a counter.
  • the control counter is increased by one, and when the non-target record is currently scanned, the control counter is cleared.
  • the relationship between the value of the counter and the number of required storage units is used to determine whether there are a preset number of continuous target records, that is, whether there are a preset number of continuous storage units.
  • the count of the counter is recorded as cntr. If a scanned storage unit is empty, cntr is incremented by 1.
  • cntr If the scanned storage unit is not empty, the accumulated number of continuous and idle storage units cntr is cleared, and the search for continuous and idle storage units continues from the address after the storage unit; until cntr is equal to numb, it means that continuous and idle storage units that meet the memory requirements have been found; if after scanning the entire state mapping table, cntr does not exist that is greater than or equal to numb, it indicates that this dynamic memory application has failed and the preset number of continuous storage units does not exist.
  • the method before the first operating system reads records in the metadata storage area and determines at least one storage unit in the data storage area that is in an idle state and has a total space greater than or equal to the length of the target data based on the read records, and obtains the target virtual channel, the method also includes: the first operating system sends a memory request instruction and performs a locking operation on the processor's memory, wherein the memory request instruction is used to apply for the use of the processor's memory; when the memory is locked successfully, read the records in the status mapping table.
  • the memory request instruction is an instruction issued by the operating system running on the processor to request the use of the processor's memory.
  • a locking operation is first performed on the processor's memory. Only when the locking is successful can an application be made to use the memory.
  • the locking operation refers to an exclusive operation on memory application. After the current operating system successfully locks, if the lock is not released, other servers do not have the right to apply to use the processor's memory.
  • performing a locking operation on the memory of a processor includes: determining whether the memory is currently in a locked state, wherein the locked state indicates that the memory is in a state where it is requested for use; if the memory is not currently in a locked state, performing a locking operation on the memory; if the memory is currently in a locked state, determining that locking of the memory has failed, and applying to lock the memory of the processor again after a preset time, until the memory is successfully locked, or until the number of lock applications is greater than a preset number.
  • the processor Before the processor runs, it is necessary to initialize the metadata storage area and the data storage area in the processor.
  • the records stored in the state mapping table in the metadata storage area are initialized, and the memory management information is initialized.
  • the member variable MemLock of the structure MallocMemInfo_T indicates whether the shared memory has been initialized, and the variable MemReady is 0xA5A5A5A5 indicates that the initialization operation has been completed and memory can be dynamically allocated and released normally; the member variable MemReady of the structure MallocMemInfo_T indicates whether it is locked.
  • variable MemLock if the variable MemLock is read as 0, it means that no system or task is applying for memory at this time, that is, the memory is not currently locked. If the variable MemLock is read as 0xA5A5A5A5, it means that a system or task is applying for memory and needs to wait until the current application is completed before applying again. The current application for locking fails.
  • the memory lock if the memory lock fails, the memory lock is applied again after waiting for a preset time until the lock is successful.
  • the preset time may be 100 microseconds.
  • the lock application fails and the number of repeated applications exceeds a preset number, indicating that the memory in the processor is in an unallocated state during the current time period, the application operation is stopped.
  • the preset number of times may be 3 times, and if the number of lock applications is greater than 3 times, a message indicating that the current memory is unavailable may be returned to the operating system that sent the application.
  • the first operating system stores the target data to be transmitted in the corresponding target virtual channel.
  • the occupancy status of the processor's memory space is updated according to the data writing status of the first operating system, that is, the target continuous memory space is changed from an unoccupied state to an occupied state.
  • the lock on the memory is released.
  • the method further includes: releasing the lock on the memory when a preset number of consecutive target records are not scanned.
  • an interrupt notification message is sent to the second operating system by means of a software interrupt.
  • sending an interrupt notification message to the second operating system by means of a software interrupt includes: writing an interrupt number and an ID of a CPU core of the second operating system into a preset register of a processor, and generating an interrupt notification message based on the interrupt number and the ID of the CPU core of the second operating system.
  • a soft interrupt is an interrupt generated by software.
  • Software can send an interrupt to the CPU core executing itself or to other CPU cores.
  • the preset register can be the GICD_SGIR register.
  • Software can write the SGI (Software Generated Interrupts) interrupt number and the destination CPU ID to the GICD_SGIR register to generate a software interrupt.
  • the SGI interrupt number is a soft interrupt number reserved for inter-core communication.
  • a hardware interrupt refers to an interrupt generated by a hardware device, which may be a private peripheral interrupt or a shared peripheral interrupt.
  • a hard interrupt is an interrupt introduced by hardware outside the CPU and is random.
  • a soft interrupt is an interrupt introduced by software running in the CPU executing an interrupt instruction and is pre-set. This embodiment does not limit the method of generating an interrupt notification message.
  • a method for sharing memory comprises the following steps:
  • Step 1 Receive a memory application instruction and perform a locking operation on the memory of the processor, wherein the memory application instruction is used to apply for the use of the memory of the processor.
  • the memory application instruction is an instruction issued by the operating system running on the processor to apply for the use of the processor's memory, which may be sent by the first operating system.
  • the operating system sends the memory application instruction, it first performs a locking operation on the processor's memory. Only when the locking is successful can the memory be applied for.
  • the locking operation refers to an exclusive operation of the memory application. After the current operating system successfully locks, if the lock is not released, other servers do not have the right to apply for the use of the processor's memory.
  • the method before performing a locking operation on the memory of the processor, the method also includes: determining whether the memory is currently in a locked state, wherein the locked state represents that the memory is in a state where it is requested for use; and if the memory is not currently in a locked state, performing a locking operation on the memory.
  • the processor's memory is used in the same time period. It can only be locked by one system or task. Therefore, the current operating system can only lock the memory when it detects that the current memory is not in a locked state.
  • whether the memory is in a locked state is determined by determining whether a preset variable stored in the memory is a preset value. If the preset variable is not a preset parameter value, it indicates that the memory is not in a locked state, and no other system or task is applying for memory space, and the locking is successful; otherwise, if the preset variable is a preset parameter, it indicates that the memory is in a locked state at the current moment, and there are other systems or tasks other than the operating system applying for memory space, and the locking fails.
  • the shared memory method after determining whether the memory is currently in a locked state, it also includes: if the memory is currently in a locked state, determining that locking the memory has failed; if locking the memory has failed, applying to lock the processor's memory again after a preset time period until the memory is successfully locked, or until the number of lock applications is greater than a preset number.
  • the memory locking is applied for again after waiting for a preset time until the locking is successful.
  • the preset time may be 100 microseconds.
  • the lock application fails and the number of repeated applications exceeds a preset number, indicating that the memory in the processor is in an unallocated state during the current time period, the application operation is stopped.
  • the preset number of times may be 3 times. If the number of lock applications is greater than 3 times, a message indicating that the current memory is unavailable may be returned to the operating system that sent the application.
  • Step 2 when the memory is locked successfully, read the memory occupied state, and determine whether there is free target memory space in the memory according to the memory occupied state, wherein the size of the target memory space is greater than or equal to the size of the memory requested by the memory request instruction.
  • the operating system applies for the memory in the processor.
  • the information used to record the memory occupied state is scanned to determine whether there is a target memory space, that is, to determine whether there is an unoccupied, continuous memory space in the processor that can meet the memory usage requirements.
  • Meeting the memory usage requirements means that the size of the memory space is greater than or equal to the memory size applied by the operating system.
  • discontinuous memory space can also be used when applying for memory, and a pointer can be added after a non-minimum memory block to point to the next minimum memory block obtained by the application.
  • a pointer can be added after a non-minimum memory block to point to the next minimum memory block obtained by the application.
  • data reading and writing across data blocks can be realized according to the storage address and the pointer. This embodiment does not limit the form of the target memory space.
  • Step 3 when the target memory space exists in the memory, the address information of the target memory space is fed back to the sender of the memory application instruction, the occupied state of the memory is updated, and the lock on the memory is released.
  • the sender refers to the operating system (for example, the first operating system) that sends the memory application instruction. It should be noted that, since the operating system sends and receives data by using shared memory during inter-core communication, and uses the address returned by the applied memory to access data during the process of sending and receiving data, it is necessary to determine the address information of the applied memory space.
  • the address information of the target continuous space is sent to the operating system, and the operating system stores the data to be transmitted in the corresponding memory space according to the address information.
  • the occupancy status of the processor's memory space is updated according to the data writing status of the operating system, that is, the target memory space is changed from an unoccupied state to an occupied state, and the locking operation before the dynamic memory application is released so that other operating systems can apply to use the processor's memory space.
  • the memory includes a metadata storage area and a data storage area
  • the data storage area is used to store business data
  • the metadata storage area stores a state mapping table
  • the state mapping table is used to record the occupied state of the data storage area, reading the occupied state of the memory, and judging whether there is free target memory space in the memory according to the occupied state of the memory includes: reading records in the state mapping table from the metadata storage area, and judging whether there is target memory space in the data storage area according to the records in the state mapping table.
  • the memory usage status is queried by querying the records in the status mapping table, and optionally, the metadata storage stored in the processor is obtained.
  • the data storage area is used to store data in a continuous and idle state, and the state mapping table in the metadata storage area is identified. By traversing the records in the state mapping table, the occupied state of the data storage area is read to determine whether there is a continuous and idle memory space in the data storage area that meets the memory usage requirements.
  • a data storage area is composed of multiple memory pages
  • a status mapping table contains multiple records
  • each record is used to record the occupied status of a memory page
  • the records in the status mapping table are read from the metadata storage area, and it is judged whether there is a target memory space in the data storage area according to the records in the status mapping table, including: determining a preset number of memory pages applied for by a memory application instruction; scanning each record in turn from an initial position of the status mapping table; when a continuous preset number of target records are scanned, determining that there is a target memory space in the memory, wherein the target record indicates that the memory page is in an idle state.
  • the data storage area is divided into multiple allocation units according to the same memory size, and each allocation unit is recorded as a memory page.
  • the memory space of the data storage area is A bytes
  • the divided allocation unit is B bytes
  • the data storage area contains a total of A/B memory pages
  • the records in the status mapping table are also memory page records.
  • Each memory page record is used to record the occupied status of a memory page.
  • the number of memory page records in the status mapping table is the same as the number of memory pages in the data storage area.
  • Figure 6 is a schematic diagram of the relationship between the state mapping table and the memory page in the shared memory method according to an embodiment of the present application.
  • the data storage area is a dynamically allocated memory block area
  • the metadata storage area includes a dynamically allocated memory mapping table area, wherein the mapping table area is divided into the same number of records according to the number of memory pages divided into the data storage area, and the record is recorded as a memory page record, and all memory page records are combined into a state mapping table, and all memory page records in the state mapping table have a one-to-one correspondence with all memory pages in the data storage area, and each memory page record indicates the allocation status of the corresponding memory page, that is, whether the memory page is occupied.
  • the business data for collaboration with the operating system needs to occupy consecutive memory pages in the processor, it is necessary to first determine the preset number of memory pages in the memory request instruction. Since the memory space of each memory page is the same, the preset number of consecutive memory pages required can be calculated based on the required memory space size, which is recorded as numb.
  • the memory page records are traversed from the index position in the state mapping table, and the index position may be the starting position of the state mapping table.
  • the index position may be the starting position of the state mapping table.
  • each memory page record in the state mapping table is queried in turn to determine whether there are continuous memory page records that record free memory pages greater than or equal to numb. When there are memory page records that meet the above conditions, it is determined that there is a target memory space in the processor through the correspondence between the memory page records and the memory pages.
  • the method after scanning each record in sequence from the initial position of the state mapping table, the method also includes: after scanning all records in the state mapping table and there are no continuous preset number of target records, determining that there is no target memory space in the memory.
  • the memory page record of the state mapping table starting from the starting position of the state mapping table, query the memory page record of the state mapping table to determine whether there is continuous space with a number of memory pages greater than or equal to numb. If no continuous, preset number of free memory pages are found after scanning the entire state mapping table, it indicates that the target memory space does not exist.
  • the number of scanned target records is recorded by a counter.
  • the control counter is increased by one.
  • the control counter is cleared, wherein the non-target record indicates that the memory page is in an occupied state.
  • cntr the count of the counter is recorded as cntr. If a scanned memory page is empty, cntr is incremented by 1.
  • cntr the accumulated number of continuous and idle memory pages cntr is cleared, and the search for continuous empty memory pages continues from the address after the memory page; until cntr is equal to numb, it indicates that continuous and idle memory pages that meet the memory requirements have been found; if cntr is less than numb during the process of scanning the entire state mapping table, it indicates that this dynamic memory application has failed and the target memory space does not exist.
  • the address information of the target memory space is fed back to the sender of the memory application instruction, including: determining the last scanned target record among a continuous preset number of target records, and feeding back the first address of the memory page indicated by the last scanned target record to the sender.
  • the scanning method can be selected to scan from the first position of the state mapping table or from the last position of the state mapping table.
  • the scanning method is to scan from the last position of the state mapping table, when the value cntr displayed by the counter is greater than or equal to the preset number numb, the first address of the memory page corresponding to the last memory page scanned is recorded, and the status of these memory pages is set to non-empty in the memory page record, and the first address is used as the first address of the entire continuous memory page of this memory application instruction.
  • the address is fed back to an operating system that issues a memory request instruction, and the operating system performs a data write operation on the memory according to the address information.
  • the initial position is the first position in the state mapping table
  • the address information of the target memory space is fed back to the sender of the memory application instruction, including: determining the first scanned target record among a continuous preset number of target records, and feeding back the first address of the memory page indicated by the first scanned target record to the sender.
  • the scanning method is to scan from the first position of the state mapping table
  • the value cntr displayed by the counter is greater than or equal to the preset number numb
  • the address of the first memory page record scanned is used as the first address and sent to the operating system that issues the memory request instruction.
  • the operating system writes data to the memory according to the address information.
  • the first target record in the scanned continuous target records is stored through a preset variable.
  • the preset variable refers to a variable in the state mapping table used to store the address information of the initial position, and it is recorded as offset.
  • the value cntr displayed by the counter is increased by 1.
  • the address information currently stored in offset is used as the address of the first target record.
  • the method further includes: releasing the lock on the memory if there is no free target memory space in the memory.
  • the state mapping table After scanning the memory page records in the state mapping table, if it is detected that the preset number of continuous and free memory pages is not included, that is, the target memory space is not included, it indicates that there is not enough space memory pages in the processor's memory for the operating system to use, and this dynamic memory application fails, and the lock on the memory is released.
  • the memory includes a metadata storage area and a data storage area, the data storage area is used to store business data, and the metadata storage area stores memory management information.
  • Determining whether the memory is currently in a locked state includes: reading the memory management information stored in the metadata storage area, and determining whether the memory management information includes preset information, wherein the preset information indicates that the memory is in a locked state; if the memory management information includes the preset information, determining that the memory is not currently in a locked state; if the memory management information does not include the preset information, determining that the memory is currently in a locked state.
  • the memory management information of the metadata storage area it is used to determine whether the memory management information contains preset information, wherein the preset information is used to characterize whether the memory is in a locked state; if the memory management information does not contain the preset information, it indicates that the current memory is in an unlocked state, otherwise it is in a locked state.
  • memory management information includes first field information and second field information, the first field information is used to describe whether the memory is in a locked state, and the second field is used to describe whether the memory is initialized.
  • the method Before receiving the memory application instruction, the method also includes: initializing the first field information and the second field information stored in the data storage area.
  • the metadata storage area and the data storage area in the processor need to be initialized.
  • the memory page records stored in the state mapping table in the metadata storage area are initialized, and the memory management information is initialized.
  • the memory management information consists of first field information and second field information, the first field information indicates whether it is locked, and the second field information is used to indicate whether initialization is completed.
  • updating the occupied state of the memory includes: changing the state of the memory page corresponding to the target memory space recorded in the state mapping table to an occupied state.
  • the memory page record of the state mapping table area of the metadata storage area is updated according to the correspondence between the memory page and the memory page record, so that it changes from an unoccupied state to an occupied state.
  • the occupation state of the processor's memory space is updated according to the data writing status of the operating system, that is, the target memory space is changed from an unoccupied state to an occupied state, and the locking operation before the dynamic memory application is released.
  • the target data is stored in a target memory space, and address information of the continuous memory space is sent to a second operating system; an acquisition instruction sent by the second operating system based on the address information is received, and the target data stored in the target memory space is sent to the second operating system.
  • the first operating system will apply for the target memory space for the target data storage value to be transferred, and send the address information of the target memory space to the second operating system cooperating with the first operating system, informing the second operating system to obtain the data.
  • the second operating system receives the address information of the target memory space, it issues a data acquisition instruction, and the embedded system receives the instruction and sends the target data stored in the target memory space to the second operating system.
  • a memory application instruction of the first operating system is received, and a locking operation is performed on the memory of the processor, wherein the memory application instruction is used to apply for the use of the processor's memory; when the memory is locked successfully, the occupied state of the memory is read, and it is determined whether there is a free target memory space in the memory according to the occupied state of the memory, wherein the size of the target memory space is greater than or equal to the size of the memory applied for by the memory application instruction; when the target memory space exists in the memory, the address information of the target memory space is fed back to the sending end of the memory application instruction, the occupied state of the memory is updated, and the lock on the memory is released; in response to the storage operation of the first operating system, the target data is stored in the target memory space, and the address information of the continuous memory space is sent to the second operating system; the acquisition instruction sent by the second operating system based on the address information is received, and the target data stored in the target memory space is sent to the second operating system, so as to solve the problems
  • the second operating system when the first operating system uses physical addresses to perform data read and write operations and the second operating system uses virtual addresses to perform data read and write operations, the second operating system converts the address information of the target memory space into a virtual address, and uses the virtual address to access the memory to read the target data from the target memory space.
  • the address returned by the dynamic memory application When using shared memory to send and receive data in inter-core communication, the address returned by the dynamic memory application will be used.
  • different systems may use different address systems.
  • the real-time operating system is the first operating system and the non-real-time operating system is the second operating system.
  • the physical address can be directly used to access the shared memory.
  • the non-real-time operating system the physical address cannot be directly used to access the shared memory. In this case, the mapped virtual address needs to be used.
  • the second operating system After the second operating system receives the address information of the target memory space, it is converted through the address information offset, mapped to a virtual address, and operated according to the virtual address.
  • the shared memory virtual base address vBase under the non-real-time operating system (the real physical address of the shared memory is assumed to be 0x96000000); the shared memory physical base address pBase under the real-time operating system (i.e., 0x96000000).
  • the address returned by the dynamically requested memory in the non-real-time operating system is also the virtual address vData.
  • the memory includes a metadata storage area and a data storage area, and the metadata storage area and the data storage area are similar to those in the aforementioned embodiment and are not described in detail here.
  • the metadata storage area stored in the processor is obtained, and the state mapping table in the metadata storage area is identified, each memory page record is traversed from the index position in the state mapping table, and each memory page record in the state mapping table is queried in turn to determine whether there are continuous memory page records that record free memory pages greater than or equal to a preset number.
  • the corresponding relationship between the memory page record and the memory page is used to determine whether there is a target memory space in the processor, and the corresponding relationship between the memory page record and the memory page is used to determine whether there is a target memory space in the processor.
  • a method for sharing memory includes: before the operating system issues a memory application instruction, in order to prevent multiple operating systems from applying for the memory space of the processor at the same time and causing application conflicts, it is necessary to apply for a locking operation and determine whether the locking is successful;
  • the dynamic application for memory lock is successful, the number of consecutive memory pages that need to be allocated is calculated based on the memory size in the issued memory application instruction, and recorded as nmemb; if the judgment result indicates that the application for lock fails, the application is reissued after waiting for a period of time (which can be 100 microseconds) until the application is successful. If the number of failed lock applications is greater than the preset number (the preset number can be three times), the memory application is exited.
  • the metadata storage area of the processor is initialized, and the last position of the state mapping table is recorded as offset, and the number of required continuous memory pages is calculated according to the space size of the required memory in the memory application instruction, and the number of memory pages is recorded as nmemb, and a counter for recording the number of memory pages is set, recorded as cmemb, and then the state mapping table of the metadata storage area in the processor is obtained, and the entire state mapping table is scanned from the offset position of the state mapping table, and the continuous memory pages are found through the correspondence between the memory page records stored in the state mapping table and the memory pages in the data storage area.
  • memory pages that meet the requirements are marked as occupied in the corresponding status mapping table, the first address of the last memory page found is used as the first address of the entire continuous memory page dynamically applied for, the lock of the dynamically applied memory is released, and this dynamic memory application is successful.
  • the size can be dynamically adjusted.
  • the updated memory application instruction can be issued again, and the memory can be locked. If the locking is successful, if the updated memory application instruction requires an increase in the memory space applied for, it is determined whether the required memory space exists after the applied target continuous memory. If so, the application is successful. If the updated memory application instruction requires a decrease in the memory space applied for, part of the memory space is released.
  • This embodiment divides the storage area into multiple storage areas, uses the index position to dynamically apply for the space according to the actual required size, releases it after use, and can dynamically adjust the size when it is found that the space is insufficient after the dynamic application, so as to improve the flexibility and efficiency of shared memory.
  • the method further includes at least one of the following:
  • S222 Merge the processing resources of the first operating system that are preempted by the second operating system or the processing resources that the first operating system actively releases to the second operating system into an available resource pool of the second operating system.
  • the scheduling of processing resources can be achieved by merging the corresponding processing resources into the available resource pool of the corresponding operating system.
  • the processing resources of the second operating system preempted by the first operating system can be merged into the available resource pool of the first operating system.
  • the processing resources of the first operating system preempted by the second operating system or the processing resources actively released by the first operating system can be merged into the available resource pool of the first operating system.
  • the resource adaptive scheduling module can cooperate with the processor framework of the first operating system and the processor framework of the second operating system to configure and implement the processor hard-core resource pool, such as the SMP (Symmetrical Multi-Processing) framework of the Linux system.
  • SMP Symmetrical Multi-Processing
  • a group of processors are gathered on a computer, and each CPU shares a memory subsystem and a bus structure.
  • SMP scheduling is the process of arranging/migrating processes to the appropriate CPU to maintain load balance on each CPU.
  • the Linux system for an operating system, its CPU scheduling method is as follows: tasks (i.e., services) in the Linux system are generally maintained by task queues, and the process scheduler determines which processes (corresponding to tasks) in the queue can be executed by the CPU.
  • the dispatching program module in the system gives the control of the CPU to the process selected by the process scheduler.
  • the selected CPU comes from the CPU resource pool in the Linux system (that is, the aforementioned available resource pool), which means that the Linux system can schedule these CPUs in the resource pool to participate in the actual operation of the process.
  • the process scheduler can pause a running process and transfer it to the running queue to start executing another process. It determines which process in the ready queue and in the main memory can be executed by the CPU (giving CPU control to this process) after a clock interrupt, I/O (Input/Output) interrupt, system call or other types of signals.
  • the method further comprises:
  • the first operating system is booted and run on the first initial processing resource through the boot loader
  • the second operating system is booted and run on the second initial processing resource through the boot loader
  • the first initial processing resource is the initial processing resource in the processing resources of the processor corresponding to the first operating system
  • the second initial processing resource is the initial processing resource in the processing resources of the processor corresponding to the second operating system
  • the entire system can be divided into two stages according to the working period, namely, the initial startup stage and the real-time operation stage.
  • the aforementioned dynamic scheduling of processing resources and other processes are performed in the real-time operation stage.
  • the initial startup stage starts when the system is powered on, that is, the chip where the processor is located is powered on.
  • a core will be awakened to execute the boot action of the operating system, and the remaining cores are temporarily in a dormant state.
  • the system will first execute a preset core scheduling strategy (boot boot strategy), that is, a core of the processor executes the core scheduling strategy.
  • boot boot strategy a preset core scheduling strategy
  • the core scheduling strategy is stored in the RAM or Norflash (non-volatile flash memory) on the SOC chip.
  • the scheduling strategy can be flexibly configured according to different design requirements. Its main functions include: specifying the initial processing resources that different operating systems need to run (for example, specifying the initial cores that the first operating system and the second operating system need to run), and determining the boot process of heterogeneous operating systems.
  • the initial processing resources corresponding to the first operating system are the first initial processing resources
  • the initial processing resources corresponding to the second operating system are the second initial processing resources.
  • the first operating system can be booted and run on the first initial processing resources through the boot loader
  • the second operating system can be booted and run on the second initial processing resources through the boot loader.
  • the boot loader is located on a computer or other computer application and refers to a program that boots the operating system to load.
  • the chip can be a BMC (Baseboard Management Controller, baseboard management controller, management control chip in the server platform) chip, which refers to a SOC chip based on the ARM multi-core architecture, integrating a variety of peripheral hardware IPs (Intelligent Peripheral, intelligent peripherals).
  • the BMC chip is placed on the motherboard (server motherboard), and chip power-on refers to power-on at the SOC chip level.
  • the boot loader is a program used to guide the loading of the operating system, for example, the inherent program in the Bootrom (ROM on the CPU chip).
  • the inherent program refers to the code that guides the startup of the operating system and belongs to the BootLoader program.
  • each operating system is guided to start up on the initial processing resources corresponding to each operating system through the boot loader, which can improve the success rate of operating system startup and prepare for the real-time operation phase.
  • the first initial processing resource is a designated processor core among processor cores of the processor
  • the second initial processing resource is other processor cores among processor cores of the processor except the designated processor core.
  • the initial processing resource may include an initial processor core
  • the first initial processing resource may be at least one processor core among the processor cores of the processor
  • the second initial processing resource may be at least some processor cores of other processor cores except the first initial processing resource.
  • the first initial processing resource may be a designated processor core among the processor cores of the processor
  • the second initial processing resource may be other processor cores among the processor cores of the processor except the designated processor core.
  • the designated processor core may be CPU0 (or another processor core), that is, the initial processing resource of the first operating system is CPU0, and the initial processing resource of the second operating system is CPU1-CPU7.
  • booting and running a first operating system on a first initial processing resource through a boot loader includes:
  • the operating system can be started and guided by the Second Program Loader (SPL).
  • SPL belongs to the code executed in the first stage of uboot, which can move the second stage code of uboot to the memory for execution and is mainly responsible for loading the operating system into the program code in RAM.
  • uboot is a boot loader for embedded systems, mainly used for embedded systems, and can support a variety of different computer system structures, such as PPC, ARM, AVR32, MIPS, x86, 68k, Nios and MicroBlaze.
  • the corresponding operating system is guided to run on the initial processing resources through the secondary program loader, which can be compatible with the existing system startup process and improve the efficiency of system startup.
  • the method further comprises:
  • a preset program in the boot chip embedded in the device motherboard can be used to perform a security boot check on the code of the secondary program loader to determine whether the secondary program loader is normal. If the result of the secondary program loader security boot check is normal, the operating system can be booted through the secondary program loader. If the result of the secondary program loader security boot check is abnormal, an abnormal prompt will be given and the boot process of the operating system will be terminated.
  • the SPL code is checked for security startup through the Bootrom program (a set of programs solidified in the ROM chip on the device motherboard). If the check result is normal, the SPL code is executed.
  • Bootrom program a set of programs solidified in the ROM chip on the device motherboard.
  • booting and running a second operating system on a second initial processing resource by a boot loader includes:
  • the second initial processing resource can be first awakened by the secondary program loader, and then the universal loader can be guided to run the second operating system.
  • SPL boots and runs the first operating system on some cores (for example, core 1, CPU0), and on the other hand, wakes up other cores (for example, core 2 to core M+N, CPU1 to CPU M+N-1) to guide and execute uboot code (a boot loader mainly used for embedded systems) to boot and run the second operating system.
  • uboot code a boot loader mainly used for embedded systems
  • the first operating system is an RTOS system
  • the second operating system is a Linux system (it can also be other non-real-time operating systems)
  • the processing resource is a processor core.
  • this optional example provides a method for dynamic balanced scheduling of processor resources among embedded heterogeneous multi-systems.
  • a core adaptive scheduling i.e., resource adaptive scheduling
  • system architecture designs such as business management, load balancing, dynamic resource allocation, and inter-core communication interfaces are integrated to achieve the effect of real-time and non-real-time embedded heterogeneous operating systems running in parallel on multiple cores of the same processor, which can improve the overall utilization of the processor core and greatly reduce the investment in hardware acceleration resources introduced to cope with real-time services.
  • the processor multi-core adopts a high-speed internal bus, and the communication performance is greatly improved, which can significantly reduce the design cost and improve the computing performance.
  • the operation method of the embedded system in this optional example can be divided into two stages, namely, the initial startup stage and the real-time operation stage. See the implementation architecture of dynamic balanced scheduling of processor resources among embedded heterogeneous multi-systems shown in FIG7 , wherein the CPU balanced scheduling process in the initial startup phase may be as shown in FIG8 , and the above process may include the following steps:
  • Step S802 configuring a part of the core to boot the inherent program in Bootrom
  • Step S804 a secure boot check is performed on the SPL (stored in Norflash) through the Bootrom program (i.e., the aforementioned inherent program) (the secure boot check mainly performs hash verification on the uboot, Linux, and RTOS images to be booted, and the obtained results are compared with the stored results. If the comparison is consistent, the boot is normal, and if it is inconsistent, the boot fails; the SPL configures some CPU registers to select which cores to wake up and from which address to load the system image);
  • the Bootrom program i.e., the aforementioned inherent program
  • Step S806 determine whether the security check is passed, if the security check is passed, execute step S808, if the security check is not passed, execute step S810;
  • Step S808 executing the SPL code.
  • the SPL boots and runs the RTOS system on some cores, and wakes up other cores to boot and execute the uboot code, thereby booting and running the Linux system.
  • Step S810 end.
  • the system enters the real-time operation stage.
  • the real-time operation stage is completed by the collaboration of functional modules such as load balancing strategy, service management, dynamic resource allocation, core adaptive scheduling (i.e., resource adaptive scheduling), core preemption and release, and inter-core communication.
  • the process of the operation method of the embedded system in this optional example may include the following steps:
  • Step S902 The service management module performs actual classification of services to be allocated according to the output of the load balancing strategy module, and generates a list including real-time services and a list including non-real-time services.
  • the load balancing strategy module provides policy guidance for the service management module, including the classification method of various services (or processes) running in the system, the real-time level evaluation principle, etc.
  • the service management module After the RTOS system and the Linux system are booted, the service management module performs the actual classification of the services to be allocated according to the output of the load balancing strategy module, and generates a list containing real-time services and a list containing non-real-time services.
  • the two lists output by the load balancing strategy module are used to represent the correspondence between the services and the operating system.
  • a feasible classification method is to classify services such as server health status monitoring, IPMI (Intelligent Platform Management Interface) interaction, component monitoring, serial port redirection, asset information management, and Web access as non-real-time services; and fan control, PECI (Platform Environment Control Interface) communication and other services as real-time services.
  • IPMI Intelligent Platform Management Interface
  • component monitoring component monitoring
  • serial port redirection asset information management
  • Web access non-real-time services
  • PECI Platinum Environment Control Interface
  • Step S904 The dynamic resource allocation module dynamically adjusts the processor resources (including processor hard cores and controller logic units, etc.) according to the output results of the service management module to form a resource mapping table between different services and actual hardware resources.
  • processor resources including processor hard cores and controller logic units, etc.
  • the mapping table formed by the resource dynamic allocation module is a resource mapping table of services and processor resources, that is, it includes processor resources that have been allocated to various operating systems, as well as processor resources that have not been allocated to any operating system.
  • mapping services to actual hardware resources real-time services are given priority in being allocated to processor cores of the RTOS system. If the processor cores of the RTOS system have been allocated to one or more services, then consider allocating unallocated processor cores to real-time services; non-real-time services are allocated to processor cores of the Linux system. If the processor cores of the Linux system have been allocated to one or more services, then consider allocating unallocated processor cores to real-time services. Therefore, there is a situation where unallocated processor cores are allocated to real-time services or non-real-time services.
  • hardware resources such as the BMC processor core and peripheral controllers are dynamically mapped to the actual BMC services.
  • core 1 in the BMC runs the RTOS system to control PWM (Pulse Width Modulation) and PECI peripheral controllers to implement fan speed regulation and fault diagnosis services
  • cores 2 to N run the Linux system to control I2C (Inter-Integrated Circuit) and other controllers to implement component monitoring services.
  • I2C Inter-Integrated Circuit
  • the output resource mapping table can be: real-time service X cores and xxx controllers (certain types of controllers), non-real-time service Y Cores and xxxx controllers (certain types of controllers).
  • Some services not only rely on computing resources (corresponding to processor cores), but also rely on specific hardware interfaces (corresponding to controllers on SOC). For example, services that require network ports need to be divided into the same operating system (RTOS system or Linux system) with the corresponding network controller.
  • Step S906 the core adaptive scheduling module completes the actual scheduling action of the processor hard core resources according to the result of the dynamic allocation of hardware resources.
  • the core adaptive scheduling module performs actual scheduling of processor hard core resources according to the output results of the service management module and the output results of the resource dynamic allocation module. For example, it schedules a part of the processor hard cores to execute real-time services, such as the M cores of core group 1 in Figure 6; and schedules the remaining processor hard cores to run non-real-time services, such as the N cores of core group 2 in Figure 6.
  • the entire scheduling process is dominated by the Linux system, and the processor hard core resource pool can be configured and implemented in conjunction with the Linux SMP framework.
  • the total number of available cores of the processor is M+N, where M ⁇ 1 and N ⁇ 1.
  • Step S908 During the real-time operation of the system, the core preemption and release module dynamically preempts and releases the processor cores between the heterogeneous operating systems.
  • the preemption and release process depends on the real-time load of the heterogeneous operating system to achieve the goal of maximizing the utilization of processor resources. For example, when the number of users accessing the BMC remotely increases from 1 to 20, the Web access business volume of the BMC increases sharply, which will cause the Linux system to require more processor hard cores to support it. In this case, the Linux system will send a core preemption request to the RTOS system through IPI. If the RTOS system is idle at this time (that is, no task scheduling), it will release core resources to the Linux system. At this time, the Linux system core preemption is successful, that is, Linux obtains more processor resources to cope with the new business needs. Through the core preemption and release mechanism, the user experience of remote server management is significantly improved.
  • the core preemption and release process is a dynamic and cyclic process. Each core preemption and release is accompanied by the adjustment of the processor hard core resources. As shown in Figure 6, after one preemption and release, the number of cores in core group X becomes P, and the number of cores in core group Y becomes M+N-P. In addition, the core preemption and release process needs to coordinate load balancing strategy, business management, core adaptive adjustment and other modules to jointly determine the final core adjustment result.
  • the above cycle means that during the normal operation of the system, there will be constant resource grabbing and releasing behaviors in the RTOS system and the Linux system due to insufficient resources on one side.
  • This cycle operation process will involve the coordinated operation of modules such as "business management (business management is a dynamic division process) - dynamic allocation of hardware resources - core adaptive scheduling”.
  • the above modules are all under the non-real-time system (Linux system). Considering that most of the main businesses are under the Linux system, it is more convenient to obtain and perceive more information and status.
  • the above-mentioned multiple modules jointly determine the core adjustment result, which means that when a system needs to seize more core resources, the final success of the seizure needs to be jointly determined by modules such as load balancing strategy, business management, and core adaptive adjustment.
  • modules such as load balancing strategy, business management, and core adaptive adjustment.
  • load balancing strategy for example, in one possible situation, when the Linux system needs more resources, although the RTOS system is in a dormant idle state at this time, the RTOS system will soon wake up and run an important business thread, and the thread also requires a lot of resources when running. At this time, the RTOS system cannot release core resources to the Linux system.
  • the above-mentioned resource scheduling process involves the criteria for judging the importance of the business, and the operation that the final resources are not allocated to the Linux system, which will involve the participation of modules such as load balancing strategy, business management, and core adaptive adjustment.
  • the strategies of each of these modules also contain the characteristics of openness, which determines that the final core adjustment result determined by them is also the result of the joint action of these strategies.
  • the RTOS system does not occupy any CPU core resources after sleeping.
  • it When it is awakened (for example, an interrupt is generated by a peripheral or wake-up timer to trigger a wake-up action), it will regain control of the specified core resources (for example, core 0) through an inter-core interrupt.
  • the RTOS system does not require the participation of the core.
  • the following uses an eight-core processor (core 1 to core 8) as an example to explain the dynamic balanced scheduling of processor resources among embedded heterogeneous multi-systems.
  • the dynamic balanced scheduling process of processor resources may include the following steps:
  • Step 1 the system is powered on, and the preset boot strategy is run, the RTOS system is booted based on core 1 (CPU0), and the Linux system is booted based on core 8 (CPU7).
  • Step 2 The service management module of the Linux system implements the real-time level classification of the system services based on the load balancing strategy module, and obtains a list of real-time services and non-real-time services. Assume that there are 20 services in total, of which real-time services are services 1 and 2, and non-real-time services are services 3 to 20.
  • Step 3 start the resource dynamic allocation module and the core adaptive scheduling module according to the service list output by the service management module, and divide the 8 processor cores into processor core group 1 (assuming it includes cores 1 and 2) and core group 2 (assuming it includes cores 3 to 8) through the SMP framework of the Linux system.
  • the system allocates the resources of core group 1 to the RTOS operating system and executes services 1 and 2, and allocates the resources of core group 2 to the Linux system and executes services 3 to 20.
  • Step 4 During system operation, both the RTOS operating system and the Linux operating system will monitor their respective load conditions. When the business load of one party is too heavy, it will initiate a core preemption action through the inter-core communication interface; when the other party receives the core preemption request, it will determine whether to release hard core resources to the other party based on its own load conditions.
  • the Linux system monitors that its own load has increased dramatically, and before its own computing resources are exhausted, it initiates a core preemption interrupt request to the RTOS system through the inter-core communication interface (corresponding to the SGI interrupt with interrupt number 9 in Table 1). After receiving the core preemption interrupt request, the RTOS system checks the busy and idle status of the core it occupies. If it finds that there is an idle core at this time (for example, core 2 is idle), it releases core 2 and sends a core release interrupt response signal (corresponding to the SGI interrupt with interrupt number 10 in Table 1) to the Linux system through the inter-core communication interface. After receiving the interrupt response signal, the Linux system merges core 2 into the available resource pool through the SMP framework. At this time, the processor hard core implements a new adjustment, that is, the RTOS system occupies core 1, and the remaining 7 cores are occupied by the Linux system.
  • Step 5 Update the system load and return to step 2.
  • the method provided in this optional example dynamically allocates different hardware processor cores to real-time operating systems and non-real-time operating systems according to actual business needs, and realizes the dynamic scheduling design of processor resources between embedded heterogeneous multi-systems based on processor hard cores from the hardware and software system architecture level.
  • the heterogeneous operating systems coexisting in the system can obtain reasonable processor computing resources according to their own business load conditions, which enhances the processor's processing ability for real-time business on the one hand, and comprehensively improves the utilization rate of the processor core, improves computing performance, and achieves the purpose of saving hardware costs.
  • the operation method of the embedded system in this embodiment is explained below in conjunction with an application scenario in which two operating systems alternately control the operation status of the same device (i.e., the target device), wherein the processing system of the first operating system includes a first processor core of a processor, and the processing resources of the second operating system include a second processor core of the processor.
  • a startup control process of an operating system is provided, which includes the following steps:
  • Step A Controlling the hardware controller of the target device via the second bus through the first operating system running on the first processor core of the processor to control the operating state of the target device.
  • some specific devices can be equipped to perform operations related to the operation of the devices.
  • these specific devices usually start working after the system is powered on. However, after the system is powered on, it will take some time for the operating system running on the processor to normally take over the specific device and control the operation status of the specific device. During the startup of the operating system, the specific device is uncontrollable.
  • the fan starts working after the system is powered on. Since it takes some time for the operating system running on the CPU to take over the fan normally and set the fan speed after the system is powered on, the fan is uncontrollable during the operating system startup process.
  • the server adopts the control method of BMC combined with CPLD
  • the personal computer adopts the control method of EC chip (the EC chip has the function of adjusting the fan speed according to the temperature)
  • the industrial computer adopts the control method of customized chip.
  • a multi-core multi-system for example, a multi-core dual system
  • startup control method can be adopted to run different operating systems of the embedded system on different processor cores of the processor.
  • Different operating systems have different response speeds.
  • the first operating system with a higher response speed than the second operating system can control the operating status of the specific device, which can reduce the situation where the operating status of the specific device is uncontrollable.
  • no additional cost since no additional cost is required, it also has good scalability.
  • the hardware controller of the target device can be controlled by the first operating system via the second bus to control the operating state of the target device.
  • the target device here can be a fan, or other device that needs to be running when the system starts.
  • the corresponding hardware controller is a fan controller, such as a PWM (Pulse Width Modulation) controller or a FanTach (fan speed) controller.
  • the first operating system for example, an RTOS system
  • RTOS system is used instead of traditional CPLD, EC chips, and custom chips.
  • RTOS system For example, dual systems, RTOS system and Linux system are implemented based on BMC dual-core, and fans are implemented based on multi-core dual systems.
  • the RTOS system can replace the CPLD, EC chip, and customized chip to control the fan, that is, take over the control of the fan and control the operating status of the fan at a fast enough speed.
  • Step B booting a second operating system on a second processor core of the processor.
  • the second operating system can be guided to start on the second processor core of the processor so that the second operating system runs on the second processor core.
  • starting the second operating system on the second processor core means scheduling the second processor core to the second operating system, and the system file or image file of the operating system can be stored in a memory on the chip where the processor is located or outside the chip, for example, in an external RAM.
  • Step C after the second operating system is started, the second operating system takes over the hardware controller via the second bus to take over the control of the target device.
  • the first operating system can always control the running state of the target device.
  • the second operating system can also take over the control of the target device.
  • the hardware controller can be taken over by the second operating system via the second bus.
  • the way in which the second operating system takes over the control of the target device can be: after the second operating system is started, the second operating system sends a device takeover request to the first operating system, for example, sending an interrupt request through the first bus to request to take over the hardware controller of the target device.
  • the first operating system can receive the device takeover request sent by the second operating system, transfer the control of the target device to the second operating system, and can also perform operations related to the handover of the control of the target device, for example, stop running the service (process) used to control the running state of the target device.
  • the RTOS system transfers the control right of the fan to the Linux system, and the Linux system controls the fan.
  • the above process can be executed after the system is powered on, that is, the multi-core dual system startup mode is adopted, and the RTOS system is started first, which is conducive to earlier intervention in fan control, and after the Linux system is fully started, the RTOS system transfers the control right of the fan to the Linux system for control.
  • the first operating system running on the first processor core of the processor controls the hardware controller of the target device via the second bus, it also includes: after the chip where the processor is located is powered on, waking up the first processor core through the processor; running the boot loader of the first operating system through the first processor core to guide the first operating system to start on the first processor core.
  • the entire system can be divided into two stages according to the working period, the initial startup stage and the real-time operation stage.
  • the startup control method in this embodiment can be executed in the initial startup stage or the real-time operation stage.
  • the initial startup stage starts when the system is powered on, that is, the chip where the processor is located is powered on.
  • a core will be awakened to execute the boot action of the operating system, and the remaining cores are temporarily in a dormant state.
  • the awakened core can be the first processor core.
  • the system will first execute a preset core scheduling strategy (boot strategy), that is, a processor core of the processor executes the core scheduling strategy.
  • the core scheduling strategy can be stored in the RAM or Norflash (non-volatile flash memory) on the SOC chip.
  • the scheduling strategy can be flexibly configured according to different design requirements. Its main functions include: specifying the initial processing resources (processor cores) required to run different operating systems, and determining the boot process of heterogeneous operating systems.
  • Chip power-on can refer to power-on at the SOC chip level.
  • the first operating system can be booted and run on the first processor core through the boot loader: Yes, the first operating system can be booted and started on the first processor core by the first processor core through the boot loader.
  • the boot loader (BootLoader) program can be located on a computer or other computer application, which refers to a program used to boot the operating system to load, for example, the inherent program in BootRom, the inherent program refers to the code for booting the operating system to start, and belongs to the BootLoader program.
  • BootRom is a small mask ROM (Read-Only Memory) or write-protected flash memory embedded in the processor chip on the CPU chip.
  • the boot loader is used to guide the operating system to start on the processor core corresponding to the operating system, which can improve the success rate of the operating system startup and prepare for the real-time operation phase.
  • a hardware controller of a target device is controlled via a second bus by a first operating system running on a first processor core of a processor, including: executing a first control task of the first operating system on the first processor core, wherein the first control task is used to control the hardware controller; reading sensor data of a designated sensor corresponding to the target device via the first processor core; and sending a device control instruction to the hardware controller via the second bus according to the sensor data of the designated sensor by the first control task, so that the hardware controller controls the operating state of the target device according to the device control instruction.
  • the operating system controls the hardware controller of the target device by a control task (business) on the processor core on which the operating system runs.
  • the control task here may refer to a corresponding control task.
  • a first control task (first control process) of a first operating system may be executed on a first processor core, and the hardware controller is controlled by the first control task.
  • the control of the hardware controller can be based on the sensor data of the sensor.
  • the parameters that affect their operation may be different, and correspondingly, the sensor data required to be obtained may also be different.
  • the target device it can be a device that runs after the chip is powered on, and the sensor corresponding to it is a designated sensor.
  • designated sensors There can be many types of designated sensors, which may include but are not limited to at least one of the following: temperature sensor, humidity sensor, noise sensor, etc. Since the first control task runs on the first processor core, the sensor data of the designated sensor can be read by the first processor core.
  • the sensor data of the designated sensor can be stored in the storage space within the designated sensor, and can be transmitted from the designated sensor to the designated storage space. In this embodiment, the reading position of the sensor data of the designated sensor is not limited.
  • the sensor data of the designated sensor read may be sensor data within a time period, or may be all sensor data since the target device was started, or may be sensor data that meets other time constraints.
  • the first control task may control the operating state of the target device according to the sensor data of the designated sensor. Controlling the operating state of the target device may be achieved in the following manner: sending a device control instruction to a hardware controller of the target device through the first control task, so that the hardware controller controls the operating state of the target device according to the device control instruction.
  • the first control task can determine the expected operating state of the target device based on the sensor data of the designated sensor; when the current operating state of the target device is different from the expected operating state, the above-mentioned device control instruction can be generated, and the device control instruction can control the operating state of the target device to be adjusted to the expected operating state.
  • the above-mentioned device control instruction can be sent to the hardware controller of the target device via the second bus.
  • the second bus is similar to the above-mentioned embodiment and will not be described in detail here.
  • the operating state of the target device is controlled, thereby improving the utilization of resources.
  • a device control instruction is sent to a hardware controller via a second bus according to sensor data of a designated sensor by a first control task, including: determining a target parameter value of a device operating parameter of a target device according to sensor data of a designated sensor by the first control task, wherein the device operating parameter is a parameter for controlling the operating state of the target device; and sending the device control instruction carrying the target parameter value to the hardware controller via the second bus by the first control task.
  • the first control task may determine the expected operating state of the target device based on the sensor data of the designated sensor.
  • the expected operating state may be represented by the parameter value of the device operating parameter.
  • the device operating parameter may be a parameter for controlling the operating state of the target device.
  • the corresponding device operating parameters may be different.
  • the corresponding device operating parameter may be the speed, and for For other types of devices, the device operating parameters may be other operating parameters.
  • the expected operating state may correspond to a target parameter value of the device operating parameter of the target device.
  • the target parameter value can be carried in the above-mentioned device control instruction, that is, the device control instruction carrying the target parameter value is sent to the hardware controller through the first control task.
  • the method of sending the device control instruction to the hardware controller can be similar to that in the aforementioned embodiment, and will not be repeated here.
  • the accuracy of device control can be improved.
  • a target parameter value of a device operating parameter of a target device is determined according to sensor data of a designated sensor through a first control task, including: when the target device is a fan, a target parameter value of a fan operating parameter of the fan is determined according to sensor data of the designated sensor through the first control task.
  • the target device may be a fan, which may be a fan for cooling the server or other device, that is, a cooling fan.
  • the device operating parameter may be a fan operating parameter
  • the fan operating parameter may include one or more, including but not limited to at least one of the following: rotation speed, rotation cycle, cycle switching time, and other operating parameters. This is not limited in this embodiment.
  • determining the target parameter value of the device operating parameter of the target device according to the sensor data of the designated sensor by the first control task may be: determining the target parameter value of the fan operating parameter of the fan according to the sensor data of the designated sensor by the first control task.
  • the first control task sends the device control instruction carrying the target parameter value to the hardware controller of the fan via the second bus, thereby controlling the operating state of the fan.
  • the running status of the fan can be quickly controlled in scenarios such as system power-on, system restart or other scenarios, thereby improving the timeliness of fan control.
  • a target parameter value of a fan operating parameter of the fan is determined according to sensor data of a designated sensor through a first control task, including: when the target device is a fan and the designated sensor is a temperature sensor, a target speed value of the fan speed is determined according to sensor data of the temperature sensor through a first control task, wherein the speed of the fan is positively correlated with the temperature detected by the temperature sensor.
  • the designated sensor may be a temperature sensor, the number of which may be one or more, and the location of the temperature sensor may be configured as required, and different temperature sensors may be located at different locations.
  • the sensor data of the temperature sensor is used to represent the temperature detected by the temperature sensor, and in this regard, the first control task may determine a target speed value of the fan's speed based on the sensor data of the temperature sensor, where the fan's speed is positively correlated with the temperature detected by the temperature sensor.
  • the highest temperature detected by the multiple temperature sensors can be determined based on the sensor data of each temperature sensor, and the fan speed can be determined based on the highest temperature detected by the multiple temperature sensors. Compared with determining the fan speed based on the average temperature detected by the multiple temperature sensors, the safety of device operation can be ensured.
  • the speed of each fan can also be determined based on the highest temperature or average temperature detected by the temperature sensor matching each fan.
  • the first operating system (for example, RTOS system) can be used to replace the processing units such as CPLD, EC chip, custom chip to control the fan speed (BMC fan control can be performed in real time).
  • the first processor core for example, CPU0, the first processor core can be awakened by hardware
  • the first processor core runs the boot loader (for example, the specified program in BootRom), loads the first operating system to start, and the first processor core will read various temperature-related sensor (Sensor) data to perform fan control (for example, fan speed control), completely simulating the above-mentioned processing unit to complete the fan regulation function.
  • the first operating system can calculate the PWM value according to the temperature sensor, and then adjust the fan speed. In the above manner, the fan speed can be controlled by the first operating system during the startup of the second operating system.
  • booting a second operating system on a second processor core of a processor includes: executing a secondary program loader through a first processor core to wake up the second processor core by the secondary program loader; and running a universal boot loader of the second operating system through the second processor core to boot the second operating system on the first processor core.
  • the secondary program loader when the operating system is started, can be loaded into the internal memory, for example, the static random access memory (Static RAM, SRAM) inside the SOC, and the SPL can be responsible for loading the universal boot loader (Universal Boot Loader, referred to as U-Boot) into the random access memory.
  • the secondary program loader can boot load the second operating system and can also boot load the first operating system.
  • the secondary program loader can be executed by the first processor core to wake up the second processor core by the secondary program loader; the universal boot loader (universal boot loader) of the second operating system can be run by the second processor core, thereby guiding the second operating system to start on the first processor core.
  • the boot program of the second operating system is loaded by the secondary program loader, and the boot program of the second operating system may include the universal boot loader.
  • the secondary program loader is the code executed in the first stage of the universal boot loader, which is responsible for moving the second stage code of the universal boot loader to the system memory (System RAM, also called off-chip memory) for execution.
  • the universal boot loader is an open source software that complies with the GPL (General Public License) agreement and can be regarded as a bare metal integrated routine.
  • the processor will first wake up the CPU0 core so that the RTOS system can run as quickly as possible; then use the program in BootRom to boot the RTOS system; during the startup of the RTOS system, it will continue to load U-Boot through SPL, and U-Boot will boot the second operating system on CPU1 until the Linux system starts normally.
  • Boot Rom is the internal ROM solidification program of the chip (for example, SOC chip), which is the boot code of uboot.
  • Boot Rom reads the startup information of the hardware (for example, the setting of the dip switch), and reads the uboot-spl code (that is, SPL) from the specified startup medium (for example, SD, MMC, etc.).
  • SPL is mainly responsible for initializing the external RAM and environment, and loading the real uboot image into the external RAM for execution.
  • the external RAM can be DDR (Double Data Rate Synchronous Dynamic RAM, double-rate synchronous dynamic random access memory) or other RAM.
  • the second processor core is awakened by the secondary program loader, and then the second processor core runs the universal boot loader to boot the second operating system on the corresponding processor core, which can improve the convenience and success rate of operating system startup.
  • the startup process of a multi-core dual system is explained below by taking an RTOS system and a Linux system as examples.
  • the startup process of the multi-core dual system can include the following steps:
  • Step 1 wake up CPU0 when the system is just powered on
  • Step 2 CPU0 runs the specified program in BootRom and loads the RTOS system to start;
  • Step 3 during the startup of the RTOS system, wake up CPU1 to boot u-boot and start the fan control program (FanCtrl_RTOS_APP) in the first operating system;
  • Step 4 CPU1 boots u-boot, which may include the SPL stage and the Uboot stage, and enters the SPL stage by calling SPL;
  • Step 5 In the SPL stage, SPL guides Uboot to start;
  • Step 6 In the Uboot stage, the Linux kernel (CPU1-CPUN) is loaded, and the BMC service program and the fan control program (FanCtrl_Linux_APP) in the second operating system are started.
  • the Linux kernel CPU1-CPUN
  • the BMC service program and the fan control program FeanCtrl_Linux_APP
  • the fan is controlled by first starting the RTOS system, and after the Linux system is started, the second operating system takes over the control of the fan. This ensures that the fan can be quickly controlled when the system is powered on, thereby improving the efficiency of fan control.
  • the second operating system after the second operating system takes over the hardware controller via the second bus, it also includes: when the second operating system is to be restarted, the first operating system is awakened by the second operating system via the first bus, and the first operating system takes over the hardware controller via the second bus to take over control of the target device; and the second operating system is controlled to restart the system.
  • the second operating system may first wake up the first operating system, and the first operating system takes over the hardware controller to take over the control of the target device. Waking up the first operating system may be performed via the first bus, and the first operating system taking over the hardware controller may be performed via the second bus.
  • the reliability of device control can be improved by waking up the first operating system to take over the control of the target device.
  • waking up the first operating system through the second operating system via the first bus includes: when the second operating system is to be restarted, initiating a system wake-up interrupt to the first operating system through the second operating system via the first bus, wherein the system wake-up interrupt is used to wake up the first operating system.
  • Waking up the first operating system may be achieved through an inter-core interrupt. If the second operating system is to be restarted (for example, the system crashes, a reboot command is received), the second operating system may initiate a system wake-up interrupt to the first operating system to wake up the first operating system.
  • the system wake-up interrupt may be an active wake-up interrupt.
  • the second operating system may be controlled to restart the system, and after the second operating system restarts, the hardware controller may be taken over again. The process of taking over the hardware controller is similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.
  • the technical solution of the present application, or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
  • a storage medium such as ROM/RAM, magnetic disk, optical disk
  • a terminal device which can be a mobile phone, computer, server, or network device, etc.
  • an embedded system for implementing the operating method of the above-mentioned embedded system is also provided, and the above-mentioned embedded system can be run on the above-mentioned BMC chip, wherein the above-mentioned embedded system may include:
  • a first operating system and a second operating system are run on the processor, and the response speed of the first operating system is higher than that of the second operating system;
  • a service management module configured to allocate a group of services to be allocated to corresponding operating systems according to a resource dynamic allocation rule, wherein the resource dynamic allocation rule includes dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate;
  • a resource dynamic allocation module used to determine a resource allocation result corresponding to a group of services to be allocated, wherein the resource allocation result is used to indicate a processing resource corresponding to each service to be allocated in the group of services to be allocated in the processing resources of the processor, and the processing resources of the processor include a processor core;
  • the resource adaptive scheduling module is used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each service to be allocated and the resource allocation result.
  • the first operating system and the second operating system may be similar to those in the aforementioned embodiment and will not be elaborated here.
  • the business management module, the resource dynamic allocation module and the resource adaptive scheduling module may be software modules running under the first operating system or the second operating system.
  • the embedded system includes: a first operating system and a second operating system, the first operating system and the second operating system run on a processor, and the response speed of the first operating system is higher than that of the second operating system; a business management module, which is used to allocate a group of to-be-allocated businesses to corresponding operating systems according to a resource dynamic allocation rule, wherein the resource dynamic allocation rule includes dynamic resource allocation according to at least one of the following: business response speed, business resource occupancy rate; a resource dynamic allocation module, which is used to determine a resource allocation result corresponding to a group of to-be-allocated businesses, wherein the resource allocation result is used to indicate the processing resources of the processor corresponding to each to-be-allocated business in the group of to-be-allocated businesses, and the processing resources of the processor include processor cores; a resource adaptive scheduling module, which is used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each to-be-
  • the embedded system further comprises:
  • the load balancing strategy module is used to generate a rule structure by reading a rule configuration file, wherein the rule structure is used to record dynamic resource allocation rules.
  • the load balancing strategy module in this embodiment is similar to that in the previous embodiment, and will not be described in detail here.
  • the software module under the first operating system or the second operating system can conveniently and flexibly adjust the load balancing policy by configuring the load balancing policy to be stored by a separate software module.
  • the load balancing strategy module is also used to
  • a rule update configuration file is obtained through an external interface of the second operating system, wherein the rule update configuration file is used to update the configured dynamic resource allocation rules; and a rule structure is updated using the rule update configuration file to update the dynamic resource allocation rules recorded in the rule structure.
  • the resource dynamic allocation rules stored in the load balancing policy module can be flexibly configured through the external interface of the second operating system.
  • the configuration method is similar to that in the above-mentioned embodiment and will not be described in detail here.
  • the service management module is used to allocate a group of services to be allocated to the corresponding operating system according to the allocation rule corresponding to the service response speed in the dynamic resource allocation rule by executing the following steps:
  • a group of services to be allocated whose service response speed requirements are greater than or equal to a set response speed threshold are allocated to the first operating system, and a group of services to be allocated whose service response speed requirements are less than the set response speed threshold are allocated to the second operating system.
  • the manner in which the service management module allocates the services to be allocated according to the service response speed is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the service management module is used to allocate a group of services to be allocated to the corresponding operating system according to the allocation rule corresponding to the service resource occupancy rate in the dynamic resource allocation rule by executing the following steps:
  • a group of services to be allocated whose service resource occupancy rate is less than a first occupancy rate threshold is allocated to the first operating system, and a group of services to be allocated whose service resource occupancy rate is greater than or equal to the first occupancy rate threshold is allocated to the second operating system.
  • the manner in which the service management module allocates the services to be allocated according to the service resource occupancy rate is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the service management module is further configured to allocate a group of services to be allocated to the corresponding operating system by performing at least one of the following steps:
  • the services to be allocated which have a service coupling degree with the allocated services of the second operating system greater than or equal to a second coupling degree threshold, in a group of services to be allocated, are allocated to the second operating system.
  • the manner in which the service management module allocates the services to be allocated according to the service coupling degree is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the service management module is further configured to allocate a group of services to be allocated to the corresponding operating system by executing the following steps:
  • the manner in which the service management module allocates the to-be-allocated service containing sensitive information to the first operating system is similar to that in the aforementioned embodiment, and is not described in detail here.
  • the allocation of services to be allocated by the business management module based on the business response speed and the business resource occupancy rate is executed based on the dynamic resource allocation rules stored in the load balancing strategy module, while the allocation of services to be allocated based on the business coupling degree and the business importance (for example, whether sensitive information is contained) can be executed by the business management module based on the configuration information preset thereon.
  • the dynamic resource allocation rules for dynamically allocating resources according to at least one of the business response speed and the business resource occupancy rate are stored in a separate software module, which can take into account the flexibility and simplicity of the rule configuration.
  • the resource dynamic allocation module is used to determine the resource allocation result corresponding to a group of services to be allocated by executing the following steps:
  • a resource mapping table of a group of services to be allocated and the processing resources of the processor is generated in combination with the resource utilization of the processing resources of the first operating system and the resource utilization of the processing resources of the second operating system.
  • the way in which the resource dynamic allocation module generates a resource mapping table of a group of services to be allocated and processing resources of the processor is similar to that in the above-mentioned embodiment, and is not described in detail here.
  • the resource dynamic allocation module allocates the processing resources of the processor to the first operating system and the second operating system in units of processor cores.
  • the resource adaptive scheduling module is used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each service to be allocated and the resource allocation result by executing the following steps:
  • the unallocated processing resources are allocated to the operating system to which the to-be-allocated business corresponding to the unallocated processing resources is allocated.
  • the resource adaptive scheduling module allocates the unallocated processing resources to the operating system in a manner similar to that in the aforementioned embodiment, which will not be described in detail here.
  • the embedded system further comprises:
  • the resource preemption and release module is used to preempt and release processing resources between the first operating system and the second operating system.
  • the resource preemption and release module performs preemption and release of processing resources between different operating systems in a similar manner as in the above-mentioned embodiment, and will not be described in detail here.
  • the resource preemption and release module preempts and releases processing resources between the first operating system and the second operating system through an inter-core communication interface.
  • the resource preemption and release module is used to implement the preemption and release of processing resources between the first operating system and the second operating system through the inter-core communication interface by executing the following steps:
  • a first interaction response returned by the second operating system in response to the first interaction request is obtained through the inter-core communication interface, wherein the first interaction response is used to instruct the first operating system to perform resource interaction with the second operating system according to the first interaction response.
  • the resource preemption and release module performs resource interaction between the first operating system and the second operating system through the inter-core communication interface in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the embedded system further comprises:
  • the first system control module is used to detect the resource utilization of the processing resources of the first operating system, and when it is determined based on the resource utilization of the processing resources of the first operating system that the first operating system is to interact with the second operating system for resources, the resource preemption and release module is triggered to transmit the first interaction request to the second operating system through the inter-core communication interface.
  • the manner in which the first system control module triggers resource interaction based on the resource utilization of the processing resources of the first operating system is similar to that in the aforementioned embodiment, and is not described in detail herein.
  • the first system control module is also used to perform at least one of the following steps: when the resource utilization of the processing resources of the first operating system is greater than or equal to the first utilization threshold, determine that the first operating system is to preempt the processing resources of the second operating system; when the processing resources of the first operating system are in an idle state and there is no business to be executed by the first operating system, determine that the first operating system is to release the processing resources to the second operating system.
  • the manner in which the first system control module determines the type of resource interaction to be performed by the first operating system is similar to that in the aforementioned embodiment, and is not described in detail herein.
  • the first system control module is further configured to control the first operating system to enter a dormant state when there is no service scheduled by the first operating system and no service to be allocated to the first operating system.
  • the way in which the first system control module controls the first operating system to enter the dormant state is similar to that in the above-mentioned embodiment, and will not be described here. Elaborate.
  • the resource preemption and release module is used to transmit the first interaction request of the first operating system to the second operating system through the inter-core communication interface by performing at least one of the following steps:
  • a resource release request with the second interrupt number is transmitted to the second operating system through the inter-core communication interface, wherein the resource release request is used to request to release the processing resources occupied by the first operating system to the second operating system.
  • the resource preemption and release module performs resource interaction through inter-core interrupts in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the resource preemption and release module is used to implement the preemption and release of processing resources between the first operating system and the second operating system through the inter-core communication interface by executing the following steps:
  • a second interaction response returned by the first operating system in response to the second interaction request is obtained through the inter-core communication interface, wherein the second interaction response is used to indicate whether the first operating system allows the second operating system to preempt processing resources of the first operating system.
  • the resource preemption and release module performs resource interaction between the first operating system and the second operating system through the inter-core communication interface in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the embedded system further comprises:
  • the second system control module is used to detect the resource utilization of the processing resources of the second operating system. When it is determined that the second operating system is to preempt the processing resources of the first operating system based on the resource utilization of the processing resources of the second operating system, the resource preemption and release module is triggered to transmit the second interaction request to the first operating system through the inter-core communication interface.
  • the manner in which the second system control module triggers resource interaction based on the resource utilization of the processing resources of the second operating system is similar to that in the above-mentioned embodiment, and is not described in detail here.
  • the second system control module is further configured to perform at least one of the following steps:
  • the manner in which the second system control module determines the resource interaction to be performed by the second operating system is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the first operating system is also used to determine that the first operating system refuses the second operating system to preempt the processing resources of the first operating system when the business priority of the business being executed by the first operating system is not lower than the business priority of the business to be executed by the second operating system; and to determine that the first operating system allows the second operating system to preempt the processing resources of the first operating system when the business priority of the business being executed by the first operating system is lower than the business priority of the business to be executed by the second operating system.
  • the embedded system determines whether the first operating system allows the second operating system to occupy the processing resources in a manner similar to that in the above-mentioned embodiment, which will not be described in detail here.
  • the resource preemption and release module is used to transmit the second interaction request of the second operating system to the first operating system through the inter-core communication interface by executing the following steps:
  • a second preemption request whose interrupt number is the third interrupt number is transmitted to the first operating system through the inter-core communication interface, wherein the second preemption request is used to request to preempt the processing resources of the first operating system.
  • the resource grabbing and releasing module performs resource interaction through inter-core interrupts in a similar manner to that in the above-mentioned embodiment, and will not be repeated here. State.
  • the resource preemption and release module is used to obtain the second interactive response returned by the first operating system in response to the second interactive request through the inter-core communication interface by performing at least one of the following steps:
  • the resource release rejection response with the interrupt number of the fifth interrupt number is transmitted to the second operating system through the inter-core communication interface, wherein the resource release rejection response is used to instruct the first operating system to reject the second operating system from preempting the processing resources of the first operating system.
  • the resource preemption and release module performs resource interaction through inter-core interrupts in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the resource adaptive scheduling module is also used to perform at least one of the following steps: merging the processing resources of the second operating system preempted by the first operating system into the available resource pool of the first operating system; merging the processing resources of the first operating system preempted by the second operating system or the processing resources actively released by the first operating system to the second operating system into the available resource pool of the second operating system.
  • the resource adaptive scheduling module processes resource scheduling between different operating systems in a manner similar to that in the aforementioned embodiment, which will not be described in detail here.
  • the embedded system further comprises:
  • a system startup module is used to boot and run a first operating system on a first initial processing resource through a boot loader after the chip where the processor is located is powered on, and to boot and run a second operating system on a second initial processing resource through a boot loader, wherein the first initial processing resource is an initial processing resource in the processing resources of the processor corresponding to the first operating system, and the second initial processing resource is an initial processing resource in the processing resources of the processor corresponding to the second operating system.
  • the way in which the system startup module boots and runs each operating system on the corresponding initial processing resource through the boot loader is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the first initial processing resource is a designated processor core among processor cores of the processor
  • the second initial processing resource is other processor cores among processor cores of the processor except the designated processor core.
  • system startup module is used to boot and run the first operating system on the first initial processing resource through the boot loader by executing the following steps:
  • the first operating system is booted and executed on the first initial processing resource through the secondary program loader.
  • system startup module boots and runs the operating system on the initial processing resources through the secondary program loader is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • system startup module is also used to perform a security startup check on the code of the secondary program loader through a preset program in the startup chip solidified on the device motherboard, wherein the secondary program loader is executed after the check result of the security startup check is normal.
  • system startup module performs a security startup check on the code of the secondary program loader.
  • system startup module is used to boot and run the second operating system on the second initial processing resource through the boot loader by executing the following steps:
  • the second initial processing resource is awakened by the secondary program loader, and the universal boot loader is guided to execute so as to guide and run the second operating system.
  • the way in which the system startup module boots the second operating system through the secondary program loader is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • an embedded system for implementing the operating method of the above-mentioned embedded system is also provided, and the above-mentioned embedded system can be run on the above-mentioned BMC chip, wherein the above-mentioned embedded system may include:
  • a first operating system and a second operating system are run on the processor, and the response speed of the first operating system is higher than that of the second operating system;
  • a service management module configured to allocate a group of services to be allocated to corresponding operating systems according to a resource dynamic allocation rule, wherein the resource dynamic allocation rule includes dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate;
  • a resource dynamic allocation module used to determine a resource allocation result corresponding to a group of services to be allocated, wherein the resource allocation result is used to indicate a processing resource corresponding to each service to be allocated in the group of services to be allocated in the processing resources of the processor, and the processing resources of the processor include a processor core;
  • the resource adaptive scheduling module is used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each service to be allocated and the resource allocation result.
  • the first operating system and the second operating system may be similar to those in the aforementioned embodiment and will not be elaborated here.
  • the business management module, the resource dynamic allocation module and the resource adaptive scheduling module may be software modules running under the first operating system or the second operating system.
  • the embedded system includes: a first operating system and a second operating system, the first operating system and the second operating system run on a processor, and the response speed of the first operating system is higher than that of the second operating system; a business management module, which is used to allocate a group of to-be-allocated businesses to corresponding operating systems according to a resource dynamic allocation rule, wherein the resource dynamic allocation rule includes dynamic resource allocation according to at least one of the following: business response speed, business resource occupancy rate; a resource dynamic allocation module, which is used to determine a resource allocation result corresponding to a group of to-be-allocated businesses, wherein the resource allocation result is used to indicate the processing resources of the processor corresponding to each to-be-allocated business in the group of to-be-allocated businesses, and the processing resources of the processor include processor cores; a resource adaptive scheduling module, which is used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each to-be-
  • the embedded system further comprises:
  • the load balancing strategy module is used to generate a rule structure by reading a rule configuration file, wherein the rule structure is used to record dynamic resource allocation rules.
  • the load balancing strategy module in this embodiment is similar to that in the above embodiment and will not be described in detail here.
  • the load balancing strategy module can be a software module under the first operating system or the second operating system. By configuring the load balancing strategy to be stored by a separate software module, the load balancing strategy can be flexibly adjusted.
  • the load balancing strategy module is also used to
  • a rule update configuration file is obtained through an external interface of the second operating system, wherein the rule update configuration file is used to update the configured dynamic resource allocation rules; and a rule structure is updated using the rule update configuration file to update the dynamic resource allocation rules recorded in the rule structure.
  • the resource dynamic allocation rules stored in the load balancing policy module can be flexibly configured through the external interface of the second operating system.
  • the configuration method is similar to that in the above-mentioned embodiment and will not be described in detail here.
  • the service management module is used to allocate a group of services to be allocated to the corresponding operating system according to the allocation rule corresponding to the service response speed in the dynamic resource allocation rule by executing the following steps:
  • a group of services to be allocated whose service response speed requirements are greater than or equal to a set response speed threshold are allocated to the first operating system, and a group of services to be allocated whose service response speed requirements are less than the set response speed threshold are allocated to the second operating system.
  • the manner in which the service management module allocates the services to be allocated according to the service response speed is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the service management module is used to allocate a group of services to be allocated to the corresponding operating system according to the allocation rule corresponding to the service resource occupancy rate in the dynamic resource allocation rule by executing the following steps:
  • a group of services to be allocated whose service resource occupancy rate is less than a first occupancy rate threshold is allocated to the first operating system, and a group of services to be allocated whose service resource occupancy rate is greater than or equal to the first occupancy rate threshold is allocated to the second operating system.
  • the manner in which the service management module allocates the services to be allocated according to the service resource occupancy rate is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the service management module is further configured to allocate a group of services to be allocated to the corresponding operating system by performing at least one of the following steps:
  • the services to be allocated which have a service coupling degree with the allocated services of the second operating system greater than or equal to a second coupling degree threshold, in a group of services to be allocated, are allocated to the second operating system.
  • the manner in which the service management module allocates the services to be allocated according to the service coupling degree is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the service management module is further configured to allocate a group of services to be allocated to the corresponding operating system by executing the following steps:
  • the manner in which the service management module allocates the to-be-allocated service containing sensitive information to the first operating system is similar to that in the aforementioned embodiment, and is not described in detail here.
  • the allocation of services to be allocated by the business management module based on the business response speed and the business resource occupancy rate is executed based on the dynamic resource allocation rules stored in the load balancing strategy module, while the allocation of services to be allocated based on the business coupling degree and the business importance (for example, whether sensitive information is contained) can be executed by the business management module based on the configuration information preset thereon.
  • the dynamic resource allocation rules for dynamically allocating resources according to at least one of the business response speed and the business resource occupancy rate are stored in a separate software module, which can take into account the flexibility and simplicity of the rule configuration.
  • the resource dynamic allocation module is used to determine the resource allocation result corresponding to a group of services to be allocated by executing the following steps:
  • a resource mapping table of a group of services to be allocated and the processing resources of the processor is generated in combination with the resource utilization of the processing resources of the first operating system and the resource utilization of the processing resources of the second operating system.
  • the way in which the resource dynamic allocation module generates a resource mapping table of a group of services to be allocated and processing resources of the processor is similar to that in the above-mentioned embodiment, and is not described in detail here.
  • the resource dynamic allocation module allocates the processing resources of the processor to the first operating system and the second operating system in units of processor cores.
  • the resource adaptive scheduling module is used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each service to be allocated and the resource allocation result by executing the following steps:
  • the unallocated processing resources are allocated to the operating system to which the to-be-allocated business corresponding to the unallocated processing resources is allocated.
  • the resource adaptive scheduling module allocates the unallocated processing resources to the operating system in a manner similar to that in the aforementioned embodiment, which will not be described in detail here.
  • the embedded system further comprises:
  • the resource preemption and release module is used to preempt and release processing resources between the first operating system and the second operating system.
  • the resource preemption and release module performs preemption and release of processing resources between different operating systems in a similar manner as in the above-mentioned embodiment, and will not be described in detail here.
  • the resource preemption and release module preempts and releases processing resources between the first operating system and the second operating system through an inter-core communication interface.
  • the resource preemption and release module is used to implement the following steps through the inter-core communication interface in the first operating system:
  • the system and the second operating system preempt and release processing resources:
  • a first interaction response returned by the second operating system in response to the first interaction request is obtained through the inter-core communication interface, wherein the first interaction response is used to instruct the first operating system to perform resource interaction with the second operating system according to the first interaction response.
  • the resource preemption and release module performs resource interaction between the first operating system and the second operating system through the inter-core communication interface in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the embedded system further comprises:
  • the first system control module is used to detect the resource utilization of the processing resources of the first operating system, and when it is determined based on the resource utilization of the processing resources of the first operating system that the first operating system is to interact with the second operating system for resources, the resource preemption and release module is triggered to transmit the first interaction request to the second operating system through the inter-core communication interface.
  • the manner in which the first system control module triggers resource interaction based on the resource utilization of the processing resources of the first operating system is similar to that in the aforementioned embodiment, and is not described in detail herein.
  • the first system control module is also used to perform at least one of the following steps: when the resource utilization of the processing resources of the first operating system is greater than or equal to the first utilization threshold, determine that the first operating system is to preempt the processing resources of the second operating system; when the processing resources of the first operating system are in an idle state and there is no business to be executed by the first operating system, determine that the first operating system is to release the processing resources to the second operating system.
  • the manner in which the first system control module determines the type of resource interaction to be performed by the first operating system is similar to that in the aforementioned embodiment, and is not described in detail herein.
  • the first system control module is further configured to control the first operating system to enter a dormant state when there is no service scheduled by the first operating system and no service to be allocated to the first operating system.
  • the manner in which the first system control module controls the first operating system to enter the sleep state is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the resource preemption and release module is used to transmit the first interaction request of the first operating system to the second operating system through the inter-core communication interface by performing at least one of the following steps:
  • a resource release request with the second interrupt number is transmitted to the second operating system through the inter-core communication interface, wherein the resource release request is used to request to release the processing resources occupied by the first operating system to the second operating system.
  • the resource preemption and release module performs resource interaction through inter-core interrupts in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the resource preemption and release module is used to implement the preemption and release of processing resources between the first operating system and the second operating system through the inter-core communication interface by executing the following steps:
  • a second interaction response returned by the first operating system in response to the second interaction request is obtained through the inter-core communication interface, wherein the second interaction response is used to indicate whether the first operating system allows the second operating system to preempt processing resources of the first operating system.
  • the resource preemption and release module performs resource interaction between the first operating system and the second operating system through the inter-core communication interface in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the embedded system further comprises:
  • the second system control module is used to detect the resource utilization rate of the processing resources of the second operating system, and Resource utilization, when determining that the second operating system is about to preempt the processing resources of the first operating system, triggering the resource preemption and release module to transmit the second interaction request to the first operating system through the inter-core communication interface.
  • the manner in which the second system control module triggers resource interaction based on the resource utilization of the processing resources of the second operating system is similar to that in the above-mentioned embodiment, and is not described in detail here.
  • the second system control module is further configured to perform at least one of the following steps:
  • the manner in which the second system control module determines the resource interaction to be performed by the second operating system is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the embedded system is also used to determine that the first operating system refuses the second operating system to preempt the processing resources of the first operating system when the business priority of the business being executed by the first operating system is not lower than the business priority of the business to be executed by the second operating system; and determine that the first operating system allows the second operating system to preempt the processing resources of the first operating system when the business priority of the business being executed by the first operating system is lower than the business priority of the business to be executed by the second operating system.
  • the embedded system determines whether the first operating system allows the second operating system to occupy the processing resources in a manner similar to that in the above-mentioned embodiment, which will not be described in detail here.
  • the resource preemption and release module is used to transmit the second interaction request of the second operating system to the first operating system through the inter-core communication interface by executing the following steps:
  • a second preemption request whose interrupt number is the third interrupt number is transmitted to the first operating system through the inter-core communication interface, wherein the second preemption request is used to request to preempt the processing resources of the first operating system.
  • the resource preemption and release module performs resource interaction through inter-core interrupts in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the resource preemption and release module is used to obtain the second interactive response returned by the first operating system in response to the second interactive request through the inter-core communication interface by performing at least one of the following steps:
  • the resource release rejection response with the interrupt number of the fifth interrupt number is transmitted to the second operating system through the inter-core communication interface, wherein the resource release rejection response is used to instruct the first operating system to reject the second operating system from preempting the processing resources of the first operating system.
  • the resource preemption and release module performs resource interaction through inter-core interrupts in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the resource adaptive scheduling module is also used to perform at least one of the following steps: merging the processing resources of the second operating system preempted by the first operating system into the available resource pool of the first operating system; merging the processing resources of the first operating system preempted by the second operating system or the processing resources actively released by the first operating system to the second operating system into the available resource pool of the second operating system.
  • the resource adaptive scheduling module processes resource scheduling between different operating systems in a manner similar to that in the aforementioned embodiment, which will not be described in detail here.
  • the embedded system further comprises:
  • a system startup module is used to boot and run a first operating system on a first initial processing resource through a boot loader after the chip where the processor is located is powered on, and to boot and run a second operating system on a second initial processing resource through a boot loader, wherein the first initial processing resource is an initial processing resource in the processing resources of the processor corresponding to the first operating system, and the second initial processing resource is an initial processing resource in the processing resources of the processor corresponding to the second operating system.
  • the way in which the system startup module boots and runs each operating system on the corresponding initial processing resource through the boot loader is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the first initial processing resource is a designated processor core among processor cores of the processor
  • the second initial processing resource is other processor cores among processor cores of the processor except the designated processor core.
  • system startup module is used to boot and run the first operating system on the first initial processing resource through the boot loader by executing the following steps:
  • the first operating system is booted and executed on the first initial processing resource through the secondary program loader.
  • system startup module boots and runs the operating system on the initial processing resources through the secondary program loader is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • system startup module is also used to perform a security startup check on the code of the secondary program loader through a preset program in the startup chip solidified on the device motherboard, wherein the secondary program loader is executed after the check result of the security startup check is normal.
  • system startup module performs a security startup check on the code of the secondary program loader.
  • system startup module is used to boot and run the second operating system on the second initial processing resource through the boot loader by executing the following steps:
  • the second initial processing resource is awakened by the secondary program loader, and the universal boot loader is guided to execute so as to guide and run the second operating system.
  • the way in which the system startup module boots the second operating system through the secondary program loader is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • FIG. 10 is a schematic diagram of an optional embedded system according to the embodiment of the present application.
  • the above embedded system may include:
  • the chip includes a processor 1002, a hardware controller 1004, a first bus 1006 and a second bus 1008, wherein:
  • the bandwidth of the first bus 1006 is higher than that of the second bus 1008 , and the first bus 1006 is configured in a multi-master and multi-slave mode, and the second bus 1008 is configured in a one-master and multi-slave mode;
  • At least two operating systems are run based on the processor 1002, wherein processing resources of the processor are dynamically allocated to the at least two operating systems, and the processing resources of the processor include a processor core;
  • At least two operating systems communicate via the first bus 1006;
  • At least two operating systems control the hardware controller via the second bus 1008 .
  • the above-mentioned chip can be the above-mentioned BMC chip;
  • the above-mentioned processor can be the above-mentioned multi-core processor, and the above-mentioned hardware controller can be used to control external devices connected to the corresponding external interface;
  • the above-mentioned first bus is configured as a multi-master and multi-slave mode, which can be a bus used for communication between multiple processor cores of the processor, for example, AHB (Advanced High Performance Bus), and the above-mentioned second bus is configured as a one-master and multiple-slave mode, which can be a bus used by the processor to control the hardware controllers, for example, APB (Advanced Peripheral Bus), and the bandwidth of the first bus is higher than the bandwidth of the second bus.
  • APB Advanced Peripheral Bus
  • the first bus is configured as a multi-master multi-slave mode, which means that the first bus can be used for data communication between multiple master devices (Master) and multiple slave devices (Slave), that is, the first bus can be connected to multiple master devices and multiple slave devices, and the first bus can be used for data communication between master devices and between master devices and slave devices.
  • the data transmission on the entire first bus is sent by the master device, and the slave device is responsible for responding.
  • the second bus is configured as a master multi-slave mode, which means that the second bus can be used for data communication between a master device and multiple slave devices, that is, the second bus can be connected to a master device and multiple slave devices, and the master device and the slave device can use the second bus for data communication.
  • Data requests can only be sent from the master device to the slave device. After receiving the request, the slave device returns the corresponding response data to the master device. This process can achieve one-to-many access.
  • a multi-master and multi-slave mode bus for data communication between operating systems, it is convenient for each operating system to actively initiate data requests based on demand, and the hardware controller mainly controls the corresponding hardware based on the control of the operating system. Therefore, a master-multiple-slave mode bus is used for communication between the operating system and the hardware controller, and data requests are all sent by the operating system to the hardware controller, which can improve the control efficiency of the hardware controller.
  • the aforementioned AHB bus has been defined in AMBA (Advanced Microcontroller Bus Architecture) 2.
  • the AHB bus is mainly used as a system high-speed bus and is suitable for high-performance, low-power system design. It can be used to connect high-performance modules.
  • the high-performance modules can be CPU, DMA (Direct Memory Access) and DSP (Digital Signal Processing), etc.
  • AHB is mainly designed for system-level high-bandwidth and high-performance system interconnection.
  • the AHB system consists of the following three parts: the master module (i.e., the master device), the slave module (i.e., the slave device) and the infrastructure.
  • the transmission on the entire AHB bus is initiated by the master module and responded by the slave module.
  • the infrastructure includes an arbiter, a multiplexer from the master module to the slave module, a multiplexer from the slave module to the master module, a decoder, a dummy Slave module and a dummy Master module.
  • APB is mainly used for connecting low-bandwidth peripherals, such as UART, 1284, etc. Its bus architecture does not support multiple master modules like AHB. The only master module in APB is the APB bridge. Its features include:
  • 3Synchronous bus All transactions (read and write operations) on the bus depend on the rising edge of the clock;
  • APB is connected to the AHB bus system, and the transactions are converted between AHB bus systems through the AHB-APB Bridge.
  • the Bridge is the master of APB, and other peripheral devices are slaves;
  • peripheral devices can be connected, for example, peripheral devices that can be controlled by the aforementioned hardware controller.
  • the AHB bus For the APB bus, data requests can only be sent from the Master to the Slave. After receiving the request, the Slave returns the corresponding response data to the Master. This process can achieve one-to-many access, and the access does not involve arbitration and Decoder parsing operations in the AHB bus.
  • the AHB bus has high bandwidth characteristics and is used for interconnection between high-performance modules (CPU, DMA, etc.) in the system.
  • the APB bus has a lower bandwidth and is used for connection between peripherals (UART, I2C, etc.) in the system.
  • the AHB bus logic circuit and bus protocol are complex, while the APB bus interface circuit and bus protocol are relatively simple.
  • the embedded system may include at least two operating systems, at least two operating systems run based on a processor, and the processing resources of the processor are dynamically allocated to the at least two operating systems.
  • the processing resources of the processor include a processor core.
  • the at least two operating systems communicate through a first bus, and at least two operating systems control a hardware controller through a second bus.
  • the hardware controller may include one or more controllers corresponding to chip peripherals, including but not limited to at least one of the following: I2C, USB (Universal Serial Bus), UART, ADC (Analog to Digital Converter), JTAG (Joint Test Action Group), RTC (Real_Time Clock), GPIO (General Purpose Input/Output), WDT (Watch
  • the external interface may include one or more external interfaces, including but not limited to external interfaces corresponding to any of the above controllers.
  • a BMC chip can be shown in FIG11
  • the hardware of the BMC chip can include, but is not limited to, a SOC submodule and a BMC out-of-band submodule, wherein the SOC submodule mainly includes an ARM core (ARM Core 1, ARM Core 2, ..., ARM Core X), and it can also include, but is not limited to, Including DDR (Double Data Rate) 4 controller (memory controller), MAC (Media Access Control Address) controller (network controller), SD (Secure Digital) Card/eMMC (Embedded Multi Media Card) controller (storage controller), PCIe RC (Root Complex) controller, SRAM (Static Random-Access Memory) and SPI controller.
  • DDR Double Data Rate
  • MAC Media Access Control Address
  • SD Secure Digital
  • Card/eMMC Embedded Multi Media Card
  • PCIe RC Root Complex
  • SRAM Static Random-Access Memory
  • SPI controller Static Random-Access Memory
  • the cores and controllers are interconnected through the first bus to achieve interaction between the cores and controllers.
  • the ARM cores are connected to the first bus (for example, they can be connected through an AXI (Advanced eXtensible Interface) bridge), and the communication between the cores is achieved through the first bus.
  • the SOC submodule also implements the interconnection and intercommunication between the first bus and the second bus (for example, through the conversion of the APB bridge), which provides a physical path for the SOC submodule to access the peripherals on the second bus.
  • the DDR4 controller can be connected to other components or devices through the DDR4PHY (Physical Layer) interface, the MAC controller is connected to other components or devices through the RGMII (Reduced Gigabit Media Independent Interface), the SD card/eMMC controller is connected to other components or devices through the SD interface, and the PCIe RC controller is connected to other components or devices through the PCIe PHY interface.
  • DDR4PHY Physical Layer
  • RGMII Reduced Gigabit Media Independent Interface
  • the SD card/eMMC controller is connected to other components or devices through the SD interface
  • the PCIe RC controller is connected to other components or devices through the PCIe PHY interface.
  • the BMC out-of-band submodule mainly includes controllers corresponding to chip peripherals such as PWM, GPIO, FanTech (fan speed control), mailbox, etc., through which PECI communication with BMC (such as using GPIO to simulate PECI), fan control and other out-of-band management functions can be realized.
  • the BMC out-of-band submodule can, but is not limited to, interact with the SOC submodule through the second bus.
  • the BMC chip realizes the interconnection between the ARM core, storage unit and controller hardware resources on the chip through the first and second buses.
  • the dynamic balanced scheduling of processor resources mainly involves the scheduling of the ARM core resources of the BMC chip, and inter-core communication refers to the communication between ARM cores.
  • the Linux system first sends an inter-core interrupt (interrupt number 9) to core 1 through the first on-chip bus on a core from cores 2 to N. If the RTOS system is in an idle state and allows preemption at this time, core 1 replies to the inter-core interrupt (interrupt number 10) through the first bus and releases the peripheral controller resources (such as PWM/PECI) currently mapped by core 1.
  • the Linux system receives the inter-core interrupt 10, initiates the preemption process, adds core 1 to the Linux SMP scheduling, and obtains control of the PWM/PECI peripherals, which can be controlled through the second bus.
  • At least two operating systems include a first operating system and a second operating system, wherein the chip loads a communication value into a first bus, and the first bus sends a communication signal carrying the communication value to a communication register corresponding to the second operating system to achieve communication between the first operating system and the second operating system, wherein the communication value is used to indicate the communication content between the first operating system and the second operating system.
  • the chip loads the control value to the second bus, and the second bus sends the control signal carrying the control value to the register corresponding to the hardware controller to realize the operating system's control over the hardware controller, wherein the control value is used to indicate the operating system's control content over the hardware controller.
  • the operating system controls the hardware controller by accessing (such as performing read and write operations) the registers of each hardware controller.
  • the operating system accesses the registers of the hardware controller by, but not limited to, reading or writing the register addresses of each hardware controller, and the addresses of these registers may be, but not limited to, unique and determined during chip design.
  • the operating system can implement a specific function (such as the communication function between the above-mentioned operating systems or the control function of the operating system on the hardware controller) by writing a specific value (i.e., the above-mentioned communication register or the register corresponding to the hardware controller) to a specific address (i.e., the above-mentioned communication register or the register corresponding to the hardware controller).
  • control value of 00 means that the air conditioner accelerates by one gear
  • control value of 01 means that the air conditioner decelerates by one gear
  • the various operating systems and the operating systems and hardware controllers can communicate, control, etc. through the bus, but are not limited to interactions.
  • the read and write operations of the operating system on the registers of the hardware controllers will eventually be converted into control signals of the first bus (or the second bus) on the hardware controllers.
  • This part of the conversion work and the control process of the first bus (or the second bus) on the hardware controllers can be, but are not limited to, automatically implemented by the internal hardware of the chip.
  • the implementation process follows the bus specification. Among them, during the operation of the first bus (or the second bus), on the one hand, physical signals related to the control and bus protocol can be transmitted, and on the other hand, valid data can be transmitted to each hardware controller through its physical data channel.
  • the embedded system includes: a chip and at least two operating systems, wherein the chip includes a processor, a hardware controller, a first bus and a second bus, wherein the bandwidth of the first bus is higher than the bandwidth of the second bus, and the first bus is configured as a multi-master multi-slave mode, and the second bus is configured as a one-master multi-slave mode; at least two operating systems run based on the processor, wherein the processing resources of the processor are dynamically allocated to At least two operating systems are provided, and the processing resources of the processor include the processor core; at least two operating systems communicate through a first bus; at least two operating systems control the hardware controller through a second bus, thereby solving the problem of low overall utilization of core resources due to the fact that most of the processing resources of the multi-core processor are in an idle state in the related art, and improving the utilization of processing resources.
  • the at least two operating systems include a first operating system running on at least one processor core of a processor and a second operating system running on at least one processor core, and the response speed of the first operating system is higher than that of the second operating system; wherein the second operating system includes:
  • a service management module configured to allocate a group of services to be allocated to corresponding operating systems according to a resource dynamic allocation rule, wherein the resource dynamic allocation rule includes dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate;
  • a resource dynamic allocation module used to determine a resource allocation result corresponding to a group of services to be allocated, wherein the resource allocation result is used to indicate a processing resource in the processing resources of the processor corresponding to each service to be allocated in the group of services to be allocated;
  • the resource adaptive scheduling module is used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each service to be allocated and the resource allocation result.
  • At least two operating systems include a first operating system and a second operating system, and each operating system runs on at least one processor core.
  • the first operating system and the second operating system may be similar to those in the above embodiment, and will not be described in detail in this embodiment.
  • the second operating system further includes:
  • the load balancing strategy module is used to generate a rule structure by reading a rule configuration file, wherein the rule structure is used to record dynamic resource allocation rules.
  • the load balancing strategy module generates a rule structure in a manner similar to that in the aforementioned embodiment, which will not be described in detail here.
  • the load balancing policy module is also used to obtain a rule update configuration file through the external interface of the second operating system, wherein the rule update configuration file is used to update the configured resource dynamic allocation rules; and use the rule update configuration file to update the rule structure to update the resource dynamic allocation rules recorded in the rule structure.
  • the resource dynamic allocation rules stored in the load balancing policy module can be flexibly configured through the external interface of the second operating system.
  • the configuration method is similar to that in the above-mentioned embodiment and will not be described in detail here.
  • the service management module is used to allocate a group of services to be allocated to the corresponding operating system according to the allocation rule corresponding to the service response speed in the dynamic resource allocation rule by executing the following steps:
  • a group of services to be allocated whose service response speed requirements are greater than or equal to a set response speed threshold are allocated to the first operating system, and a group of services to be allocated whose service response speed requirements are less than the set response speed threshold are allocated to the second operating system.
  • the manner in which the service management module allocates the services to be allocated according to the service response speed is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the service management module is used to allocate a group of services to be allocated to the corresponding operating system according to the allocation rule corresponding to the service resource occupancy rate in the dynamic resource allocation rule by executing the following steps:
  • a group of services to be allocated whose service resource occupancy rate is less than a first occupancy rate threshold is allocated to the first operating system, and a group of services to be allocated whose service resource occupancy rate is greater than or equal to the first occupancy rate threshold is allocated to the second operating system.
  • the manner in which the service management module allocates the services to be allocated according to the service resource occupancy rate is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the service management module is further configured to allocate a group of services to be allocated to the corresponding operating system by performing at least one of the following steps:
  • the services to be allocated which have a service coupling degree with the allocated services of the second operating system greater than or equal to a second coupling degree threshold, in a group of services to be allocated, are allocated to the second operating system.
  • the manner in which the service management module allocates the services to be allocated according to the service coupling degree is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the service management module is further configured to allocate a group of services to be allocated to the corresponding operating system by executing the following steps:
  • the manner in which the service management module allocates the to-be-allocated service containing sensitive information to the first operating system is similar to that in the aforementioned embodiment, and is not described in detail here.
  • the resource dynamic allocation module is used to determine the resource allocation result corresponding to a group of services to be allocated by executing the following steps:
  • a resource mapping table of a group of services to be allocated and the processing resources of the processor is generated in combination with the resource utilization of the processing resources of the first operating system and the resource utilization of the processing resources of the second operating system.
  • the way in which the resource dynamic allocation module generates a resource mapping table of a group of services to be allocated and processing resources of the processor is similar to that in the above-mentioned embodiment, and is not described in detail here.
  • the resource dynamic allocation module allocates the processing resources of the processor to the first operating system and the second operating system in units of processor cores.
  • the resource adaptive scheduling module is used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each service to be allocated and the resource allocation result by executing the following steps:
  • the unallocated processing resources are allocated to the operating system to which the to-be-allocated business corresponding to the unallocated processing resources is allocated.
  • the resource adaptive scheduling module allocates the unallocated processing resources to the operating system in a manner similar to that in the aforementioned embodiment, which will not be described in detail here.
  • the embedded system further comprises:
  • the resource preemption and release module is used to preempt and release processing resources between the first operating system and the second operating system.
  • the resource preemption and release module performs preemption and release of processing resources between different operating systems in a similar manner as in the above-mentioned embodiment, and will not be described in detail here.
  • the resource preemption and release module preempts and releases processing resources between the first operating system and the second operating system through a first bus, where the first bus is a bus for communication between different processor cores of a processor.
  • the resource preemption and release module is used to implement the preemption and release of processing resources between the first operating system and the second operating system through the first bus by executing the following steps:
  • a first interaction response returned by the second operating system in response to the first interaction request is obtained through the first bus, wherein the first interaction response is used to instruct the first operating system to perform resource interaction with the second operating system according to the first interaction response.
  • the resource preemption and release module performs resource interaction between the first operating system and the second operating system through the inter-core communication interface in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the first operating system includes:
  • the first system control module is used to detect the resource utilization of the processing resources of the first operating system, and when it is determined based on the resource utilization of the processing resources of the first operating system that the first operating system is to interact with the second operating system for resources, the resource preemption and release module is triggered to transmit the first interaction request to the second operating system through the first bus.
  • the first system control module triggers the resource interaction mode based on the resource utilization rate of the processing resources of the first operating system.
  • the first system control module is also used to perform at least one of the following steps: when the resource utilization of the processing resources of the first operating system is greater than or equal to the first utilization threshold, determine that the first operating system is to preempt the processing resources of the second operating system; when the processing resources of the first operating system are in an idle state and there is no business to be executed by the first operating system, determine that the first operating system is to release the processing resources to the second operating system.
  • the manner in which the first system control module determines the type of resource interaction to be performed by the first operating system is similar to that in the aforementioned embodiment, and is not described in detail herein.
  • the first system control module is further configured to control the first operating system to enter a dormant state when there is no service scheduled by the first operating system and no service to be allocated to the first operating system.
  • the manner in which the first system control module controls the first operating system to enter the sleep state is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the resource preemption and release module is used to transmit the first interaction request of the first operating system to the second operating system through the first bus by performing at least one of the following steps:
  • a resource release request with the second interrupt number is transmitted to the second operating system through the first bus, wherein the resource release request is used to request to release the processing resources occupied by the first operating system to the second operating system.
  • the resource preemption and release module performs resource interaction through inter-core interrupts in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the resource preemption and release module is used to implement the preemption and release of processing resources between the first operating system and the second operating system through the first bus by executing the following steps:
  • a second interactive response returned by the first operating system in response to the second interactive request is obtained through the first bus, wherein the second interactive response is used to indicate whether the first operating system allows the second operating system to preempt processing resources of the first operating system.
  • the resource preemption and release module performs resource interaction between the first operating system and the second operating system through the inter-core communication interface in a manner similar to that in the aforementioned embodiment, and will not be described in detail here.
  • the second operating system includes:
  • the second system control module is used to detect the resource utilization of the processing resources of the second operating system, and when it is determined that the second operating system is to preempt the processing resources of the first operating system based on the resource utilization of the processing resources of the second operating system, the resource preemption and release module is triggered to transmit the second interaction request to the first operating system through the first bus.
  • the manner in which the second system control module triggers resource interaction based on the resource utilization of the processing resources of the second operating system is similar to that in the above-mentioned embodiment, and is not described in detail here.
  • the second system control module is further configured to perform at least one of the following steps:
  • the manner in which the second system control module determines the resource interaction to be performed by the second operating system is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the first operating system is further configured to ensure that the service priority of the service in the execution of the first operating system is not lower than that of the second operating system. In the case of the business priority of the system's pending business, it is determined that the first operating system refuses the second operating system to preempt the processing resources of the first operating system; in the case where the business priority of the business being executed by the first operating system is lower than the business priority of the pending business of the second operating system, it is determined that the first operating system allows the second operating system to preempt the processing resources of the first operating system.
  • the manner in which the first operating system determines whether to allow the second operating system to occupy the processing resources is similar to that in the above-mentioned embodiment, and is not described in detail here.
  • the resource preemption and release module is used to transmit the second interaction request of the second operating system to the first operating system through the first bus by executing the following steps:
  • a second preemption request whose interrupt number is the third interrupt number is transmitted to the first operating system through the first bus, wherein the second preemption request is used to request to preempt the processing resources of the first operating system.
  • the resource grabbing and releasing module performs resource interaction through the first bus in a manner similar to that in the above-mentioned embodiment, which will not be described in detail here.
  • the resource preemption and release module is used to obtain the second interactive response returned by the first operating system in response to the second interactive request through the first bus by performing at least one of the following steps:
  • a resource release rejection response with the interrupt number being the fifth interrupt number is transmitted to the second operating system via the first bus, wherein the resource release rejection response is used to instruct the first operating system to reject the second operating system from preempting the processing resources of the first operating system.
  • the resource grabbing and releasing module performs resource interaction through the first bus in a manner similar to that in the above-mentioned embodiment, which will not be described in detail here.
  • the resource adaptive scheduling module is also used to perform at least one of the following steps: merging the processing resources of the second operating system preempted by the first operating system into the available resource pool of the first operating system; merging the processing resources of the first operating system preempted by the second operating system or the processing resources actively released by the first operating system to the second operating system into the available resource pool of the second operating system.
  • the resource adaptive scheduling module processes resource scheduling between different operating systems in a manner similar to that in the aforementioned embodiment, which will not be described in detail here.
  • a processor is used to boot and run a first operating system on a first initial processing resource through a boot loader after the chip is powered on, and to boot and run a second operating system on a second initial processing resource through a boot loader, wherein the first initial processing resource is an initial processing resource among the processing resources of the processor corresponding to the first operating system, and the second initial processing resource is an initial processing resource among the processing resources of the processor corresponding to the second operating system.
  • the way in which the processor boots and runs each operating system on the corresponding initial processing resource through the boot loader is similar to that in the above-mentioned embodiment, and will not be described in detail here.
  • the first initial processing resource is a designated processor core among processor cores of the processor
  • the second initial processing resource is other processor cores among processor cores of the processor except the designated processor core.
  • the processor is configured to implement booting and running a first operating system on a first initial processing resource through a boot loader by executing the following steps:
  • the first operating system is booted and executed on the first initial processing resource through the secondary program loader.
  • the way in which the processor boots and runs the operating system on the initial processing resources through the secondary program loader is similar to that in the aforementioned embodiment, and is not described in detail here.
  • the processor is also used to perform a security boot check on the code of the secondary program loader through a preset program in a boot chip embedded in a mainboard of the device, wherein the secondary program loader is executed after the security boot check result is normal.
  • the way in which the processor performs a security boot check on the code of the secondary program loader is similar to that in the aforementioned embodiment and will not be described in detail here.
  • the processor is configured to implement booting and running the second operating system on the second initial processing resource through the boot loader by executing the following steps:
  • the second initial processing resource is awakened by the secondary program loader, and the universal boot loader is guided to execute so as to guide and run the second operating system.
  • the way in which the processor boots and runs the second operating system through the secondary program loader is similar to that in the aforementioned embodiment, and is not described in detail here.
  • FIG12 is a structural block diagram of an optional operating device of an embedded system according to an embodiment of the present application. As shown in FIG12, the above-mentioned device may include:
  • the first allocation unit 1202 is used to allocate a group of to-be-allocated services to corresponding operating systems in the embedded system according to a dynamic resource allocation rule, wherein the dynamic resource allocation rule includes dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate, service coupling degree, and service importance, and the embedded system includes a first operating system and a second operating system, the first operating system and the second operating system run on a processor, and the response speed of the first operating system is higher than that of the second operating system;
  • a first determining unit 1204 connected to the first allocating unit 1202, is used to determine a resource allocation result corresponding to a group of services to be allocated, wherein the resource allocation result is used to indicate a processing resource corresponding to each service to be allocated in the group of services to be allocated in the processing resources of the processor, and the processing resources of the processor include a processor core;
  • the second allocation unit 1206 is connected to the first determination unit 1204, and is used to allocate the processing resources of the processor to the first operating system and the second operating system according to the operating system corresponding to each service to be allocated and the resource allocation result.
  • first allocation unit 1202 in this embodiment can be used to execute the above step S202
  • first determination unit 1204 in this embodiment can be used to execute the above step S204
  • second allocation unit 1206 in this embodiment can be used to execute the above step S206.
  • a group of to-be-allocated services are allocated to the corresponding operating systems in the embedded system according to the dynamic resource allocation rule, wherein the dynamic resource allocation rule includes dynamically allocating resources according to at least one of the following: service response speed, service resource occupancy rate, service coupling degree, service importance, and the embedded system includes a first operating system and a second operating system, the first operating system and the second operating system are running on a processor, and the response speed of the first operating system is higher than that of the second operating system; determining the resource allocation result corresponding to the group of to-be-allocated services, wherein the resource allocation result is used to indicate the processing resources corresponding to each to-be-allocated service in the group of to-be-allocated services in the processing resources of the processor, and the processing resources of the processor include a processor core; according to the operating system corresponding to each to-be-allocated service and the resource allocation result, the processing resources of the processor are allocated to the first operating system and the second operating system,
  • the above device further comprises:
  • the generating unit is used to generate a rule structure by reading a rule configuration file, wherein the rule structure is used to record a resource dynamic allocation rule.
  • the above device further comprises:
  • An acquisition unit configured to acquire a rule update configuration file through an external interface of the second operating system, wherein the rule update configuration file is used to update a configured resource dynamic allocation rule;
  • the updating unit is used to update the rule structure using the rule update configuration file, so as to update the resource dynamic allocation rule recorded in the rule structure.
  • the first allocation unit includes at least one of the following:
  • the first allocation module is used to allocate the to-be-allocated businesses whose business response speed requirements are greater than or equal to the set response speed threshold in a group of to-be-allocated businesses to the first operating system, and to allocate the to-be-allocated businesses whose business response speed requirements are less than the set response speed threshold in a group of to-be-allocated businesses to the second operating system.
  • the second allocation module is used to allocate the to-be-allocated services whose service resource occupancy rate is less than the first occupancy rate threshold in the group of to-be-allocated services to the first operating system, and to allocate the to-be-allocated services whose service resource occupancy rate is greater than or equal to the first occupancy rate threshold in the group of to-be-allocated services to the second operating system. system;
  • the third allocation module is used to allocate the to-be-allocated services containing sensitive information in a group of to-be-allocated services to a target operating system, wherein the target operating system is an operating system of the first operating system and the second operating system that interacts less frequently with the user object.
  • the first allocation unit includes at least one of the following:
  • a fourth allocation module configured to allocate services to be allocated, whose service coupling degree with services allocated to the first operating system is greater than or equal to a first coupling degree threshold, from a group of services to be allocated, to the first operating system;
  • the fifth allocation module is used to allocate to the second operating system services to be allocated, the services to be allocated having a service coupling degree greater than or equal to a second coupling degree threshold value among a group of services to be allocated.
  • the first determining unit includes:
  • the generation module is used to generate a resource mapping table of a group of services to be allocated and the processing resources of the processor according to the allocation results of a group of services to be allocated, combined with the resource utilization of the processing resources of the first operating system and the resource utilization of the processing resources of the second operating system.
  • processing resources of a processor are allocated to the first operating system and the second operating system in units of processor cores.
  • the second allocation unit comprises:
  • the sixth allocation module is used to allocate the unallocated processing resources to the operating system to which the to-be-allocated business corresponding to the unallocated processing resources is allocated when it is determined according to the resource allocation result that there are corresponding to-be-allocated businesses in the unallocated processing resources of the processor.
  • the above device further comprises:
  • the first execution unit is used to preempt and release processing resources between the first operating system and the second operating system.
  • the first execution unit includes:
  • the execution module is used to preempt and release processing resources between the first operating system and the second operating system through the inter-core communication interface.
  • the execution module includes:
  • a first transmission submodule is used to transmit a first interaction request of the first operating system to the second operating system through the inter-core communication interface, wherein the first interaction request is used to request resource interaction with the second operating system, and the resource interaction includes one of the following: resource preemption and resource release;
  • the first acquisition submodule is used to acquire, through the inter-core communication interface, a first interaction response returned by the second operating system in response to the first interaction request, wherein the first interaction response is used to instruct the first operating system to perform resource interaction with the second operating system according to the first interaction response.
  • the above device further comprises:
  • a first detection unit configured to detect resource utilization of processing resources of the first operating system
  • the second determining unit is used to trigger the transmission of the first interaction request to the second operating system through the inter-core communication interface when it is determined that the first operating system is to interact with the second operating system for resources according to the resource utilization of the processing resources of the first operating system.
  • the device further comprises at least one of the following:
  • a third determining unit configured to determine, when a resource utilization rate of the processing resources of the first operating system is greater than or equal to a first utilization rate threshold, that the first operating system is to preempt the processing resources of the second operating system;
  • the fourth determining unit is configured to determine that the processing resources of the first operating system are to be released to the second operating system when the processing resources of the first operating system are in an idle state and there is no business to be executed by the first operating system.
  • the above device further comprises:
  • the control unit is used to control the first operating system to enter a dormant state when there is no service scheduling for the first operating system and no service to be allocated to the first operating system.
  • the first transmission submodule includes:
  • a first transmission subunit is used to transmit a first preemption request whose interrupt number is the first interrupt number to the second operating system through the inter-core communication interface, wherein the first preemption request is used to request to preempt the processing resources of the second operating system;
  • the second transmission subunit is used to transmit a resource release request with the second interrupt number to the second operating system through the inter-core communication interface, wherein the resource release request is used to request to release the processing resources occupied by the first operating system to the second operating system.
  • the execution module includes:
  • a second transmission submodule used to transmit a second interaction request of the second operating system to the first operating system through the inter-core communication interface, wherein the second interaction request is used to request to seize processing resources of the first operating system;
  • the second acquisition submodule is used to acquire, through the inter-core communication interface, a second interaction response returned by the first operating system in response to the second interaction request, wherein the second interaction response is used to indicate whether the first operating system allows the second operating system to preempt processing resources of the first operating system.
  • the above device further comprises:
  • a second detection unit used to detect resource utilization of processing resources of the second operating system
  • the fifth determining unit is used to trigger the transmission of the second interaction request to the first operating system through the inter-core communication interface when it is determined that the second operating system is to preempt the processing resources of the first operating system according to the resource utilization rate of the processing resources of the second operating system.
  • the device further comprises at least one of the following:
  • a sixth determining unit configured to determine, when a current resource utilization rate of the processing resources of the second operating system is greater than or equal to a second utilization rate threshold, that the second operating system is to preempt the processing resources of the second operating system;
  • the seventh determination unit is used to determine the processing resources of the second operating system to be preempted by the second operating system when it is determined that the resource utilization of the processing resources of the second operating system is greater than or equal to a third utilization threshold based on the executing business of the second operating system and the pending business of the second operating system.
  • the above device further comprises:
  • an eighth determining unit configured to determine that the first operating system refuses the second operating system to preempt processing resources of the first operating system if the service priority of the service being executed by the first operating system is not lower than the service priority of the service to be executed by the second operating system;
  • the ninth determining unit is configured to determine that the first operating system allows the second operating system to preempt processing resources of the first operating system when the service priority of the service being executed by the first operating system is lower than the service priority of the service to be executed by the second operating system.
  • the second transmission submodule includes:
  • the third transmission subunit is used to transmit a second preemption request with an interrupt number of the third interrupt number to the first operating system through the inter-core communication interface, wherein the second preemption request is used to request to preempt the processing resources of the first operating system.
  • the second acquisition submodule includes:
  • a fourth transmission subunit configured to transmit a resource release permission response whose interrupt number is a fourth interrupt number to the second operating system through an inter-core communication interface, wherein the resource release permission response is used to instruct the first operating system to allow the second operating system to preempt processing resources of the first operating system;
  • the fifth transmission subunit is used to transmit a resource release rejection response with the fifth interrupt number to the second operating system through the inter-core communication interface, wherein the resource release rejection response is used to instruct the first operating system to reject the second operating system from preempting the processing resources of the first operating system.
  • the device further comprises at least one of the following:
  • a second execution unit configured to merge the processing resources of the second operating system preempted by the first operating system into an available resource pool of the first operating system
  • the third execution unit is used to merge the processing resources of the first operating system preempted by the second operating system or the processing resources actively released by the first operating system to the second operating system into the available resource pool of the second operating system.
  • the above device further comprises:
  • a boot unit is used to boot and run a first operating system on a first initial processing resource through a boot loader after the chip where the processor is located is powered on, and to boot and run a second operating system on a second initial processing resource through a boot loader, wherein the first initial processing resource is an initial processing resource in the processing resources of the processor corresponding to the first operating system, and the second initial processing resource is an initial processing resource in the processing resources of the processor corresponding to the second operating system.
  • the first initial processing resource is a designated processor core among processor cores of the processor
  • the second initial processing resource is other processor cores among processor cores of the processor except the designated processor core.
  • the guiding unit comprises:
  • the boot module is used to boot and run the first operating system on the first initial processing resource through the secondary program loader.
  • the above device further comprises:
  • the checking unit is used to perform a security boot check on the code of the secondary program loader through a preset program in the boot chip solidified on the mainboard of the device, wherein the secondary program loader is executed after the check result of the security boot check is normal.
  • the guiding unit further comprises:
  • the execution module is used to wake up the second initial processing resource through the secondary program loader and guide the execution of the universal boot loader to guide the running of the second operating system.
  • the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
  • An embodiment of the present application further provides a chip, wherein the chip includes at least one of a programmable logic circuit and an executable instruction, and the chip runs in an electronic device to implement the steps in any of the above method embodiments.
  • the embodiment of the present application further provides a BMC chip, wherein the BMC chip may include: a storage unit and a processing unit connected to the storage unit.
  • the storage unit is used to store a program
  • the processing unit is used to run the program to execute the steps in any of the above method embodiments.
  • An embodiment of the present application also provides a mainboard, wherein the mainboard includes: at least one processor; at least one memory for storing at least one program; when the at least one program is executed by the at least one processor, the at least one processor implements the steps in any one of the above method embodiments.
  • An embodiment of the present application also provides a server, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus, and the memory is used to store computer programs; the processor is used to implement the steps in any of the above method embodiments when executing the program stored in the memory to achieve the same technical effect.
  • the communication bus of the above-mentioned server may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc.
  • the communication bus may be divided into an address bus, a data bus, a control bus, etc.
  • the communication interface is used for communication between the above-mentioned server and other devices.
  • the memory may include RAM, or may include NVM (Non-Volatile Memory), such as at least one disk storage.
  • the memory may also be at least one storage device located away from the aforementioned processor.
  • the aforementioned processor may be a general-purpose processor, including a CPU, NP (Network Processor), etc.; it may also be a DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component.
  • An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
  • the computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, a ROM, a RAM, a mobile hard disk, a magnetic disk, or an optical disk.
  • An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
  • the electronic device may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
  • modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation.
  • the present application is not limited to any specific combination of hardware and software.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Multi Processors (AREA)
  • Computer Hardware Design (AREA)
  • Hardware Redundancy (AREA)

Abstract

本申请公开了一种嵌入式系统的运行方法和装置、嵌入式系统及芯片,该方法包括:根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,嵌入式系统包括第一操作系统和第二操作系统,第一操作系统的响应速度高于第二操作系统;确定与一组待分配业务对应的资源分配结果,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源,处理器的处理资源包括处理器核心;根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统。

Description

嵌入式系统的运行方法和装置、嵌入式系统及芯片 技术领域
本申请实施例涉及计算机领域,具体而言,涉及一种嵌入式系统的运行方法和装置、嵌入式系统及芯片。
背景技术
随着半导体行业和集成电路技术的快速发展,多核处理器已成为多个领域的重要计算单元。在对响应速度敏感的应用场景下,可以通过处理器加上专门的加速硬件的方式,由多核处理器承载对响应速度不敏感的业务,而由加速硬件承载对响应速度敏感的业务。然而,上述业务处理方式,由于多核处理器多数的处理资源(例如,核心资源)处于空闲状态,导致处理资源的整体利用率较低。
发明内容
本申请实施例提供了一种嵌入式系统的运行方法和装置、嵌入式系统及芯片,以至少解决相关技术中存在由于多核处理器多数的处理资源处于空闲状态导致的处理资源的整体利用率较低的问题。
根据本申请实施例的一个方面,提供了一种嵌入式系统的运行方法,包括:根据资源动态分配规则将一组待分配业务分配给所述嵌入式系统中对应的操作系统,其中,所述资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,所述嵌入式系统包括第一操作系统和第二操作系统,所述第一操作系统和所述第二操作系统运行于处理器上,所述第一操作系统的响应速度高于所述第二操作系统;确定与所述一组待分配业务对应的资源分配结果,其中,所述资源分配结果用于指示所述处理器的处理资源中与所述一组待分配业务中的每个待分配业务对应的处理资源,所述处理器的处理资源包括处理器核心;根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统。
根据本申请实施例的另一方面,还提供了一种嵌入式系统,包括:第一操作系统和第二操作系统,所述第一操作系统和所述第二操作系统运行于处理器上,所述第一操作系统的响应速度高于所述第二操作系统;业务管理模块,用于根据资源动态分配规则将一组待分配业务分配给对应的操作系统,其中,所述资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率;资源动态分配模块,用于确定与所述一组待分配业务对应的资源分配结果,其中,所述资源分配结果用于指示所述处理器的处理资源中与所述一组待分配业务中的每个待分配业务对应的处理资源,所述处理器的处理资源包括处理器核心;资源自适应调度模块,用于根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统。
根据本申请实施例的又一个实施例,还提供了一种嵌入式系统,包括:芯片和至少两个操作系统,其中,所述芯片包括处理器、硬件控制器、第一总线和第二总线,其中,所述第一总线的带宽高于所述第二总线带宽,且所述第一总线被配置为多主多从模式,所述第二总线被配置为一主多从模式;所述至少两个操作系统基于所述处理器运行,其中,所述处理器的处理资源被动态分配给所述至少两个操作系统,所述处理器的处理资源包括处理器核心;所述至少两个操作系统通过所述第一总线进行通信;所述至少两个操作系统通过所述第二总线实现对所述硬件控制器的控制。
根据本申请实施例的又一方面,还提供了一种嵌入式系统的运行装置,包括:第一分配单元,用于根据资源动态分配规则将一组待分配业务分配给所述嵌入式系统中对应的操作系统,其中,所述资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,所述嵌 入式系统包括第一操作系统和第二操作系统,所述第一操作系统和所述第二操作系统运行于处理器上,所述第一操作系统的响应速度高于所述第二操作系统;第一确定单元,用于确定与所述一组待分配业务对应的资源分配结果,其中,所述资源分配结果用于指示所述处理器的处理资源中与所述一组待分配业务中的每个待分配业务对应的处理资源,所述处理器的处理资源包括处理器核心;第二分配单元,用于根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统。
根据本申请实施例的又一方面,还提供了一种芯片,其中,所述芯片包括可编程逻辑电路以及可执行指令中的至少之一,所述芯片在电子设备中运行,用于实现上述任一项方法实施例中的步骤。
根据本申请实施例的又一方面,还提供了一种BMC芯片,其中,包括:存储单元以及与所述存储单元连接的处理单元,所述存储单元用于存储程序,所述处理单元用于运行所述程序,以执行上述任一项方法实施例中的步骤。
根据本申请实施例的又一方面,还提供了一种主板,其中,包括:至少一个处理器;至少一个存储器,用于存储至少一个程序;当所述至少一个程序被所述至少一个处理器执行,使得所述至少一个处理器实现上述任一项方法实施例中的步骤。
根据本申请实施例的又一方面,还提供了一种服务器,其中,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;存储器,用于存放计算机程序;处理器,用于执行存储器上所存放的程序时,实现上述任一项方法实施例中的步骤。
根据本申请的又一个实施例,还提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。
根据本申请的又一个实施例,还提供了一种电子设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项方法实施例中的步骤。
在本申请实施例中,在处理器的不同处理资源上运行嵌入式系统的不同操作系统的方式,根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统,其中,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,嵌入式系统包括第一操作系统和第二操作系统,第一操作系统和第二操作系统运行于处理器上,第一操作系统的响应速度高于第二操作系统;确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源,处理器的处理资源包括处理器核心;根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统,由于在处理器上运行嵌入式系统的至少两个操作系统,不同的操作系统的响应速度不同,可以用于运行对响应速度要求不同的业务,基于资源动态分配规则将处理器的待执行业务分配给不同的操作系统,并将待执行业务分配给不同的处理资源,从而可以基于待执行业务与操作系统的对应关系、以及待执行业务与处理资源的对应关系将处理器的处理资源动态分配给不同的操作系统,通过上述业务执行方式,无需增加额外的加速硬件,同时由于所有的业务均是由处理器内的处理资源执行的,在原本由处理器执行的业务的基础上,额外处理原本由加速硬件执行的业务,可以实现增加处理器所处理的业务量的目的,达到提高处理资源的利用率的技术效果,从而解决了相关技术中存在由于多核处理器多数的处理资源处于空闲状态导致的核心资源的整体利用率较低的问题。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。
为了更清楚地说明本申请实施例或相关技术中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是根据本申请实施例的一种嵌入式系统的运行方法的硬件环境示意图;
图2是根据本申请实施例的一种可选的嵌入式系统的运行方法的流程示意图;
图3是根据本申请实施例的一种可选的嵌入式系统的运行方法的示意图;
图4是根据本申请实施例的另一种可选的嵌入式系统的运行方法的示意图;
图5是根据本申请实施例的又一种可选的嵌入式系统的运行方法的示意图;
图6是根据本申请实施例的又一种可选的嵌入式系统的运行方法的示意图;
图7是根据本申请实施例的又一种可选的嵌入式系统的运行方法的示意图;
图8是根据本申请实施例的另一种可选的嵌入式系统的运行方法的流程示意图;
图9是根据本申请实施例的又一种可选的嵌入式系统的运行方法的流程示意图;
图10是根据本申请实施例的一种可选的嵌入式系统的示意图;
图11是根据本申请实施例的另一种可选的嵌入式系统的示意图;
图12是根据本申请实施例的一种可选的嵌入式系统的运行装置的结构框图。
具体实施方式
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
本申请实施例所提供的方法实施例可以在服务器、计算机终端、设备终端或者类似的运算装置中执行。以运行在服务器上为例,图1是根据本申请实施例的一种嵌入式系统的运行方法的硬件环境示意图。如图1所示,服务器可以包括一个或多个(图1中仅示出一个)处理器102(处理器102可以包括但不限于微处理器MCU或可编程逻辑器件FPGA等的处理装置)和用于存储数据的存储器104,在一个示例性实施例中,上述服务器还可以包括用于通信功能的传输设备106以及输入输出设备108。本领域普通技术人员可以理解,图1所示的结构仅为示意,其并不对上述服务器的结构造成限定。例如,服务器还可包括比图1中所示更多或者更少的组件,或者具有与图1所示等同功能或比图1所示功能更多的不同的配置。
存储器104可用于存储计算机程序,例如,应用软件的软件程序以及模块,如本申请实施例中的嵌入式系统的运行方法对应的计算机程序,处理器102通过运行存储在存储器104内的计算机程序,从而执行各种功能应用以及数据处理,即实现上述的方法。存储器104可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器104可进一步包括相对于处理器102远程设置的存储器,这些远程存储器可以通过网络连接至服务器。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
传输设备106用于经由一个网络接收或者发送数据。上述的网络具体实例可包括服务器的通信供应商提供的无线网络。在一个实例中,传输设备106包括一个网络适配器(Network Interface Controller,简称为NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输设备106可以为射频(Radio Frequency,简称为RF)模块,其用于通过无线方式与互联网进行通讯。
在本实施例中提供了一种嵌入式系统的运行方法,应用于上述服务器,图2是根据本申请实施例的一种可 选的嵌入式系统的运行方法的流程示意图,如图2所示,该流程包括如下步骤:
步骤S202,根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统。
本实施例中的嵌入式系统的运行方法可以应用到在处理器的处理资源上运行业务的、并对处理资源进行动态均衡调度的场景中。上述嵌入式系统可以是嵌入式多系统,嵌入式多系统是指在嵌入式系统的多核处理器中运行多种操作系统(例如,第一操作系统、第二操作系统等),且这些操作系统同时运行于同一嵌入式系统中,多种操作系统可以是相同类型的操作系统,也可以是不同类型的操作系统,例如,异构操作系统(架构不同的不同类型的操作系统)。业务在处理器上的执行可以通过处理器的多个核心上的处理资源并行执行的,这里的处理器可以为多核处理器,例如,8核处理器,也可以是包含其他数量的核心的处理器,本实施例中对于多核处理器包含的核心数不做限定。
相关技术中,随着半导体行业和集成电路技术的快速发展,多核处理器已经成为云计算、AI(Artificial Intelligence,人工智能)、大数据、工业互联网和5G(5th Generation Mobile Communication Technology,第五代移动通信技术)等领域的重要计算单元。为了实现硬件计算资源共享,可以引入虚拟化技术提升多核处理器的利用率,即,基于处理器硬件平台虚拟出多个虚拟机,每个虚拟机运行一个独立的操作系统。
然而,基于虚拟机的操作系统由于增加了虚拟机管理等开销,一般无法满足业务的实时性要求。因此,在对响应速度(与业务的实时性有关)敏感的应用场景下,一般是直接采用独占物理机的形式运行操作系统,这种“裸金属”式的处理器使用方式能显著降低业务处理时延。在嵌入式系统开发的各行业领域(例如,服务器、物联网等)中,为了实现功能要求日益强大的系统管理功能,同样会将其所承载的业务按照对响应速度要求(实时性要求)的不同程度进行统筹划分,并为不同的业务类型配置不同的硬件实现平台,例如,复杂且种类繁多的非实时型业务由多核心处理器CPU(Central Processing Unit,中央处理器,作为计算机系统的运算和控制核心,CPU是信息处理、程序运行的最终执行单元)承接,而对响应速度要求较强的业务则由专门的加速硬件实现。这里的加速硬件可以包括但不限于:FPGA(Field Programmable Gate Array,现场可编程门阵列器件)、CPLD(Complex Programmable Logic Device,复杂可编程逻辑器件)或专用ASIC(Application Specific Integrated Circuit,专用集成电路)芯片等。
然而,对于嵌入式系统中多核心处理器加上加速硬件的解决方案,处理器的所有处理资源(例如,处理器核心)上通常只运行单一种类的操作系统,且大部分时间多数的处理资源处于空闲状态,处理资源的整体利用率较低。这里,常见的嵌入式产品(例如,手机、平板)通常是多核运行一种操作系统(例如,安卓、IOS、Windows),CPU核心的负载大部分情况下占用率也是在30%以下(CPU能力通常是过剩的),CPU是按时间片工作的,没有占用时就处于空闲状态。并且,为了应对部分对响应时间敏感的业务而增加FPGA/CPLD等加速硬件资源投入不利于成本控制。
为了至少部分解决上述技术问题,在本实施例中,采用在处理器的不同处理资源上运行嵌入式系统的不同操作系统的方式,不同的操作系统的响应速度不同,可以用于运行对响应速度要求不同的业务,基于资源动态分配规则将处理器的待执行业务分配给不同的操作系统,并将待执行业务分配给不同的处理资源,从而可以基于待执行业务与操作系统的对应关系、以及待执行业务与处理资源的对应关系将处理器的处理资源动态分配给不同的操作系统,通过上述业务执行方式,无需增加额外的加速硬件,便于进行成本控制,同时由于所有的业务均是由处理器内的处理资源执行的,在原本由处理器执行的业务的基础上,额外处理原本由加速硬件执行的业务,增加了处理器所处理的业务量,可以提高处理资源的整体利用率。
在本实施例中,嵌入式系统包括第一操作系统和第二操作系统,第一操作系统的响应速度高于第二操作系统,而第一操作系统和第二操作系统运行于处理器上,即,运行于处理器的不同处理资源上,处理器的处理资源可以包括以下至少之一:第一操作系统的处理资源(调度给第一操作系统的处理资源),第二操作系统的处理资源(调度给第二操作系统的处理资源),未分配处理资源。这里,处理器可以是多核处理器(例如,八核 处理器),处理器的处理资源(即,处理器资源)可以包括处理器核心(处理器硬核),还可以包括其他类型的资源,例如,控制器逻辑单元、对外接口、总线资源等。
在处理器运行的过程中,可以获取一组待分配业务,即,待分配给第一操作系统和第二操作系统的业务。由于不同的待分配业务对于响应速度、业务资源占用率、与其他业务的业务耦合度、业务重要性等维度上可能会存在区别,因此,可以预先配置资源动态分配规则,资源动态分配规则可以包括用于进行业务分配的规则,将业务分配给对应的操作系统,以便由对应的操作系统的处理资源执行分配给自己的业务。可选地,资源动态分配规则可以包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,不同的分配规则可以具有对应的优先级,例如,优先级按照由高到低的顺序依次为:业务重要性,业务耦合度,业务响应速度,业务资源占用率。根据源动态分配规则,可以将一组待分配业务(或者待分配任务,不同的待分配业务可以对应于不同的进程)分配给嵌入式系统中对应的操作系统,得到业务分配结果。
可选地,基于对响应时间的约束,第一操作系统可以是具有明确固定的时间约束的操作系统,所有处理过程(任务调度)需要在固定的时间约束内完成,否则系统会出错,其可以是实时操作系统(Real Time Operating System,简称RTOS),例如,FreeRTOS、RTLinux等,还可以是其他嵌入式系统中的实时操作系统。第二操作系统不具备该特征,第二操作系统一般采用公平任务调度算法,线程/进程数量增加时,就需要分享CPU时间,任务调试具有不确定性,可称为非实时操作系统,例如,contiki、HeliOS、Linux(全称GNU/Linux,是一套可自由传播的类Unix操作系统)等,还可以是其他嵌入式系统中的非实时操作系统,其中,Linux系统是一个基于POSIX(Portable Operating System Interface,可移植操作系统接口)的多用户、多任务、支持多线程和多CPU的操作系统。
对应地,分配给第一操作系统的业务通常为实时性业务,实时性业务是指需要在规定的时间内得到调度的业务,该业务需要处理器以足够快的速度予以处理,其处理的结果又能在规定的时间内来控制生产过程或者对处理系统做出快速响应。作为一个典型的场景,工业控制中对机器手的控制属于实时性业务,系统需要在检测到机器手误操作之前及时采取措施,否则可能会造成严重后果。分配给第二操作系统的业务通常为非实时性业务,非实时性业务是指对调度时间不敏感的业务,对调度的延迟具有一定的容忍度,例如,服务器中读取温度传感器(sensor)的传感器数据。
需要说明的是,实时操作系统是指当外界事件或数据产生时,能够接受并以足够快的速度予以处理,其处理的结果又能在规定的时间之内来控制生产过程或对处理系统做出快速响应,调度一切可利用的资源完成实时业务,并控制所有实时业务协调一致运行的操作系统具有及时响应和高可靠性的特点。
可选地,将一组待分配业务分配给对应的操作系统可以是由业务管理模块执行的,如图3所示,该业务管理模块可以是运行在第一操作系统或者第二操作系统上的软件模组,以运行在第二操作系统上为例,业务管理模块可以由Linux系统中的软件实现。该业务管理模块可以根据资源动态分配规则,将一组待分配业务分配给嵌入式系统中对应的操作系统。
步骤S204,确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源。
在将每个待分配业务分配至对应的操作系统之后,根据业务分配结果,可以为每个待分配业务分配对应的处理资源,得到与一组待分配业务对应的资源分配结果。在为待分配业务分配处理资源时,可以为分配给第一操作系统的业务分配第一操作系统的处理资源,分配给第二操作系统的业务分配第二操作系统的处理资源,同时,考虑到负载均衡,在存在未分配处理资源时,可以为部分业务分配未分配处理资源。
处理器的处理资源可以以时间片为单位进行处理资源的动态分配,考虑到频繁的切换处理资源所属的操作系统以及业务处理时间并不一定是时间片的整数倍,从而导致部分业务的响应时间被延长,可以以处理器核心为单位被分配给第一操作系统和第二操作系统,即,处理器的处理器核心是以整个处理器核心为单位被分配给对应的操作系统,每个操作系统所分配的处理器核心的数量为整数个,且不同的操作系统分配的处理器核心互 不相同。
可选地,确定与一组待分配业务对应的资源分配结果可以是由资源动态分配模块执行的,如图3所示,该资源动态分配模块可以是运行在第一操作系统或者第二操作系统上的软件模组,以运行在第二操作系统上为例,资源动态分配模块可以由第二操作系统中的软件模组实现,其可以根据业务管理模块的输出,进行针对业务的处理资源的动态分配,这里,软件模组可以是具有预设功能的程序模块,例如,对于资源动态分配模块,其可以是具有资源动态分配功能的程序模块,对于业务管理模块,其可以是具有业务管理功能的程序模块,每种软件模组可以作为一个整体进行布设及调整,同时可以在不同的应用工程中应用。
步骤S206,根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统。
根据与每个待分配业务对应的操作系统以及资源分配结果,可以将处理器的处理资源分配给第一操作系统和第二操作系统。可选地,可以将处理器的未分配处理资源分配给与其对应的操作系统,未分配处理资源可以是基于未分配处理资源与待分配业务的对应关系以及待分配业务与操作系统的对应关系确定的。
可选地,将处理器的处理资源分配给第一操作系统和第二操作系统可以是由资源自适应调度模块(例如,核心自适应调度模块)执行的,该资源自适应调度模块可以是运行在第一操作系统或者第二操作系统上的软件模组,以运行在第二操作系统上为例,资源自适应调度模块可以由Linux系统中的软件实现,其可以根据业务管理模块的输出和资源动态分配模块的输出,完成对处理器的处理资源(例如,处理器硬核资源)的实际调度动作。如图4所示,经过核心资源自适应模块的资源调度,(M+N)个核心中的M个核心调度给了实时操作系统,N个核心调度给了非实时操作系统。
例如,可以在同一处理器的不同硬核上运行异构的操作系统(异构操作系统),使整个处理器系统具备实时及非实时业务的并行处理能力,同时,通过自适应调整不同操作系统占用的处理器硬核资源(例如,处理器核心),实现处理器资源利用率的显著提升。这里,异构是指嵌入式系统的同一个多核处理器中运行的操作系统类型不同,多系统是指嵌入式系统的同一个多核处理器上运行的操作系统数量为多个,且这些操作系统在时间维度上是同时运行的。
这里,需要说明的是,针对服务器而言,服务器至少具有可扩展性高和稳定性高的特性,其中,由于企业网络是不可能长久不变的,在网络信息化的今天,如果服务器没有一定的可扩展性,会影响到服务器在企业的使用,进而影响到企业之后的发展,因此,可拓展性成为服务器所需的最基本特性,只有在拥有较高的可扩展性才能保证后期更好的利用。可扩展性除了硬件上的可扩展性之外,还包含软件上的可扩展性,由于服务器的功能与计算机相比较而言还是十分复杂,因此不仅仅是在硬件配置方面,还有就是软件配置也是很重要的,想要实现更多的功能,没有全面软件支持也是没有办法想象的。
此外,由于服务器需要处理大量的数据用以支撑业务的持续性运行,因此服务器还有一个很重要的特征,例如,稳定性高,如果服务器的数据传输不能稳定运行,则无疑会对业务开展造成极大的影响。
本申请的方案利用服务器可扩展性高的特点,引入了第一操作系统、第二操作系统双软件系统用于生成硬件接口信号,同时还可以引入GPLD、BMC芯片等硬件设备分别用于调整硬件接口信号的传输电压、监控服务器内部其他器件的运行状态。在此基础上,本申请中采用由第一操作系统生成请求命令对应的硬件接口信号的方式,首先通过第一操作系统获取请求命令,然后确定请求命令对应的多个逻辑位信息,最后根据多个逻辑位信息和定时器生成请求命令对应的硬件接口信号。由上述内容可知,本申请通过第一操作系统生成请求命令对应的硬件接口信号,从而实现了使用软件方式模拟生成硬件接口信号的技术效果,进而达到了无需芯片本身具备相关硬件接口信号的硬件逻辑设计的目的不仅能够降低芯片的设计难度,还能减低芯片的设计成本。本申请达到了在无需对芯片进行硬件接口信号的硬件逻辑设计的基础上利用软件系统生成硬件接口信号的目的,从而降低了芯片的设计难度,进而解决了相关技术中需要芯片本身具备控制器的硬件逻辑设计,从而导致的芯片的设计成本较高的技术问题。
另外,引入了第一操作系统、第二操作系统双软件系统还能确保服务器的稳定性,由于第二操作系统的业务响应速度小于第一操作系统的业务响应速度,因此,使用业务响应速度更快的第一操作系统生成硬件接口信号,能够保证硬件接口信号的生成不会中断,从而确保硬件接口信号能够持续稳定的输出。
通过上述步骤,根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统,其中,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,嵌入式系统包括第一操作系统和第二操作系统,第一操作系统和第二操作系统运行于处理器上,第一操作系统的响应速度高于第二操作系统;确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源,处理器的处理资源包括处理器核心;根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统,解决了相关技术中存在由于多核处理器多数的处理资源处于空闲状态导致的核心资源的整体利用率较低的问题,提高了处理资源的利用率。
在一个示例性实施例中,上述方法还包括:
S11,通过读取规则配置文件,生成规则结构体,其中,规则结构体用于记录资源动态分配规则。
资源动态分配规则可以是基于规则配置文件进行配置的,通过读取的规则配置文件,可以生成用于记录资源动态分配规则的规则结构体,这里,规则配置文件可以是负载均衡策略文件(payload_balance.config),负载均衡策略文件可以用于配置运行的各种业务(或进程)的分类方法、实时性等级的评估原则等。负载均衡策略文件中可以不同的参数配置资源动态分配规则,负载均衡策略配置文件的一个示例如下:
classification kinds=2//取值为1表示按重要和非重要等属性对进程进行分类,否则按预置的分类方法(如实时与非实时)对进程进行分类;
real-time grade evaluation=2//取值为1表示将过去统计分钟(statistic minutes)内CPU的平均占用率作为进程实时性等级评估原则;否则表示按预置的优先级作为进程实时性等级评估原则;
statistic minutes=5//表示各进程的平均占用率的统计时间(单位为minute,分钟),当real-time grade evaluation为1时有效。
可选地,资源动态分配规则可以存储在负载均衡策略模块,这里,负载均衡策略模块可以是运行在第一操作系统或者第二操作系统下的软件模组(例如,运行在Linux系统下的软件模组),其可以为业务管理模块提供策略指导,包括系统中运行的各种业务(或进程)的分类方法、实时性等级的评估原则等。业务管理模块可以对系统中的业务按实时性等级进行业务划分与管理,进一步指导资源自适应调度模块进行处理器资源的重分配。示例性地,其可以根据负载均衡策略模块的输出,执行业务的实际分类,产生包含实时业务与非实时业务的列表。
需要说明的是,上述分类方法与实时性等级评估原则是开放的,用户可以自己定义某种方法或原则,业务管理模块进行业务管理所基于规则可以是动态配置的,可以在已有规则的基础上进行进一步规则的设置。业务管理模块中可以设置有相同功能的多个规则,但规则之间不存在矛盾,即,可以基于规则的配置时间、规则的优先级等规则选取条件,确定作用相同的规则中,当前使用的规则,从而避免规则之间出现矛盾。上述配置文件load_balance.config描述了一种可能情况,在配置文件中,classification_kinds变量指示具体的分类标准(例如,按业务的重要性或实时性)及分类类别(例如,重要业务和一般业务、实时业务与非实时业务等),而real-time_grade_evaluation变量指示实时性评估标准(可以是按过去statistic_minutes分钟内CPU的平均占用率或预置的业务优先级),实时性等级类型由用户自定义,可定义为高、普通、低三种,也可以细分更多种。
负载均衡策略模块的输出即为配置好的分类方法、实时性等级评估原则等,在软件实现时,可以是具体的配置文件(如load_balance.config文件),也可以是结构体变量,这些文件或结构体变量最终均能被业务管理模块访问到,进而获取负载均衡的具体策略。
通过本实施例,通过读取规则配置文件,生成规则结构体以记录资源动态分配规则,可以提高信息配置的便捷性。
在一个示例性实施例中,上述方法还包括:
S21,通过第二操作系统的对外接口获取规则更新配置文件,其中,规则更新配置文件用于更新已配置的资源动态分配规则;
S22,使用规则更新配置文件更新规则结构体,以更新规则结构体所记录的资源动态分配规则。
规则结构体可以是固定格式,即,在嵌入式系统运行的过程中不允许被修改,也可以是可灵活配置的格式,即,可以通过特定格式的配置文件进行配置更改。在本实施例中,可以获取规则更新配置文件,该规则更新配置文件用于更新已配置的资源动态分配规则;使用规则更新配置文件,可以更新规则结构体,从而更新规则结构体所记录的资源动态分配规则。
在使用规则更新配置文件更新规则结构体时,可以是直接根据规则更新配置文件生成新的规则结构体,并使用新生成的规则结构体替换已有的规则结构体,也可以是使用规则更新配置文件所指示的规则参数的参数值更新规则结构体中对应的规则参数的参数值。
可选地,特定格式的配置文件可以是通过第一操作系统或者第二操作系统的对外接口进行读取的,考虑到所需处理的业务量级,嵌入式系统的资源动态调度等操作可以由第二操作系统负责。在获取规则更新配置文件时,可以通过第二操作系统的对外接口获取规则更新配置文件。
例如,负载均衡策略模块可以是固定格式,也可以通过Linux系统的对外接口进行配置,例如,可以定义如前述的特定格式的配置文件(load_balance.config),通过文件读写方式进行配置更改。
需要说明的是,对外接口是多核处理器的对外接口,可以是网络接口,SPI(Serial Peripheral Interface,串行外设接口)控制器接口、UART(Universal Asynchronous Receiver/Transmitter,通用异步收发传输器)串口等,只要能从外界获取数据的通路即可。读取文件用到的硬件和具体的文件位置有不同的实现方案,例如,通过网络接口可从Web(World Wide Web,全球广域网)界面加载配置文件;通过SPI控制器可从板卡的SPI Flash(闪存)中读取配置文件;通过UART串口可从另一台PC(Personal Computer,个人计算机)上的串口数据收发软件工具获取配置文件。
通过本实施例,通过获取规则更新配置文件并使用获取的规则更新配置文件更新规则结构体,可以提高资源动态分配规则配置的灵活性。
在一个示例性实施例中,根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统,包括:
S31,将一组待分配业务中业务响应速度要求大于或者等于设定响应速度阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务中业务响应速度要求小于设定响应速度阈值的待分配业务分配给第二操作系统。
在进行待分配业务分配时,可以基于待分配业务的业务响应速度要求将待分配业务分配给对应的操作系统。业务响应速度可以用于评估业务的实时性等级,业务响应速度要求越高,其对操作系统的调度时间和响应速度越敏感,实时性等级越高,业务响应速度要求高的业务需要操作系统以足够快的速度予以处理,其处理的结果又能在规定的时间内来控制生产过程或者对处理系统做出快速响应,而业务响应速度要求不高的业务,对调度的延迟具有一定的容忍度。
对于业务响应速度要求大于或者等于设定响应速度阈值的待分配业务,其对操作系统的调度时间和响应速度敏感,可以将此类待分配业务分配给第一操作系统(例如,将实时业务分配给实时操作系统)。对于业务响应速度要求小于设定响应速度阈值的待分配业务,其对响应速度和调度时间不敏感的业务,因此,可以将此类待分配业务分配给第二操作系统(例如,将非实时业务分配给非实时操作系统)。这里,业务响应速度要求可以是通过业务响应速度的指示参数进行指示的,设定响应速度阈值可以是毫秒级的响应速度阈值或者秒级的响 应速度阈值,例如,100ms、200ms、1s等等,本实施例中对于设定响应速度阈值不做限定。
可选地,在将一组待分配业务分配给嵌入式系统中对应的操作系统时,可以输出与第一操作系统对应的第一业务列表和第二操作系统对应的第二业务列表,第一业务列表用于记录分配给第一操作系统的业务,而第二业务列表用于记录分配给第二操作系统的业务,即,业务分配结果包括第一业务列表和第二业务列表,输出的第一业务列表和第二业务列表可以用于进行处理器的处理资源的动态调度过程。
例如,对系统业务实时性等级划分,获得实时性业务与非实时性业务列表,假设总共有20个业务,其中实时性业务为业务1和业务2,非实时性业务为业务3~业务20。
这里,业务管理模块可以对当前待执行的业务进行分类,BMC系统首次运行时,由于系统当前要运行的所有业务对系统是已知的,所以业务管理模块根据负载均衡模块的输出对这些业务进行一次分类,分类后不同业务将被分配到不同的操作系统(RTOS系统与Linux系统)中执行,后续运行过程中,如果业务进程出现数量变动(例如,某些进程挂死、或有新的进程启动)时,业务管理模块还会继续进行业务划分,实时地对现存业务按照负载均衡策略进行划分与管理。业务管理模块可以是Linux系统中的一个常驻的进程,它本身是一直运行着的,且对当前运行的进程进行管理与划分。
通过本实施例,通过按照业务响应速度要求将待分配业务分配给对应的操作系统,可以保证对调度时间敏感的业务的业务响应的及时性。
在一个示例性实施例中,根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统,包括:
S41,将一组待分配业务中业务资源占用率小于第一占用率阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务中业务资源占用率大于或者等于第一占用率阈值的待分配业务分配给第二操作系统。
在进行待分配业务分配时,可以基于待分配业务的业务资源占用率将待分配业务分配给对应的操作系统。业务资源占用率可以是单位时间内业务对于处理资源的平均占比(例如,每分钟的CPU占用率),业务资源占用率的高低影响了本业务的响应速度以及后续业务的响应速度,因此,可以基于业务资源占用率评估业务的实时性等级,业务资源占用率越高,其对操作系统的调度时间和响应速度的影响越大,实时性等级越低,而业务资源占用率不高的业务,其对操作系统的调度时间和响应速度的影响不大,实时性等级越高。
对于业务资源占用率小于第一占用率阈值的待分配业务,其对操作系统的调度时间和响应速度的影响不大,可以将此类待分配业务分配给第一操作系统。对于业务资源占用率大于或者等于第一占用率阈值的待分配业务,其对操作系统的调度时间和响应速度的影响较大,因此,可以将此类待分配业务分配给第二操作系统。这里,第一占用率阈值可以根据需要进行配置,其可以是10%、15%、20%或者其他阈值,同时,该第一占用率阈值可以进行动态调整。
通过本实施例,通过按照业务资源占用率将待分配业务分配给对应的操作系统,可以保证对业务资源占用率低的业务响应的及时性。
在一个示例性实施例中,根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统,包括以下至少之一:
S51,将一组待分配业务中与第一操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,分配给第一操作系统;
S52,将一组待分配业务中与第二操作系统的已分配业务的业务耦合度大于或者等于第二耦合度阈值的待分配业务,分配给第二操作系统。
在进行待分配业务分配时,可以基于待分配业务的业务耦合度将待分配业务分配给对应的操作系统。业务耦合度可以用于表示待分配业务与各个操作系统中的已分配业务之间的关联程度。如果一个待分配业务与某一个操作系统的已分配业务的业务耦合度较高,则不适宜将其分配给另一个操作系统。因此,可以基于待分配业务与各个操作系统中的已分配业务之间的业务耦合度,将待分配业务分配给对应的操作系统。
可选地,可以通过业务的输入和输出之间的关联评价业务耦合度,业务耦合度可以通过不同的耦合度等级进行表示,如果业务的输入和输出之间没有关系,耦合度等级为低级(或者其他表示业务之间没有关联的耦合度等级),如果一个业务的执行依赖于另一个应用的输出(没有该输出作为输入业务无法开始进行),则业务之间的耦合度等级为高级,如果一个业务的执行用到了另一个应用的输出,但该输出不会妨碍业务的正常执行(在业务执行到对应的操作时能够获取到该输出即可,且对应的操作不是核心操作),则业务之间的耦合度等级为中级。此外,也可以通过数值表示业务耦合度,可以通过一种或多种耦合度条件(例如,输入和输出之间的关联关系)评价业务耦合度,将满足的耦合度条件所对应的数值,确定为业务耦合度的数值。
如果一组待分配业务中存在与第一操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,则可以将此类待分配业务分配给第一操作系统,而如果一组待分配业务中存在与第二操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,则可以将此类待分配业务分配给第二操作系统。
例如,除了产生实时业务列表和非实时业务列表,业务管理模块还负责业务解耦评估与管理,即,从所有实时业务中找出可以独立出来交给实时操作系统运行的业务,以便硬件资源动态分配模块进行处理器资源的重分配,对于不能独立出来交给实时操作系统运行的业务,如果其与非实时业务的业务耦合度高,则可以将其分配给非实时操作系统。
这里,由于有些业务虽然具有实时性要求,但它与系统中的其他非实时业务的交互非常频繁(即,业务耦合度高),这时,为了提升整体的数据交互效率,把这类业务分配给非实时操作系统。而还有一类实时业务,它本身相对独立,这时只需要将其划分到实时操作系统即可,这个过程即为“解耦”操作。判断业务独立出来的标准并不唯一,可以是上述业务间关联的密切程度,也可以是其他用户关切的指标。
重分配的策略是开放的,一种可能的策略为:系统首次运行时,根据业务管理模块分配给实时操作系统与非实时操作系统的业务数量的比例分配处理器核心,后续运行过程中根据双系统中各自的核心资源占用率调整资源分配,从这个角度讲,重分配过程与核心抢占与释放过程是相互配合的过程。
在一个可选的实施方式中,第一操作系统上运行的业务可以但不限于包括硬件接口信号的生成业务,在本实施方式中提供了一种硬件接口信号的生成过程,该过程包括如下步骤:
步骤1,通过第一操作系统获取请求命令。这里,请求命令可以是一种硬件接口信号的生成命令,例如,硬件接口信号可以是PECI信号,则请求命令是基于PECI协议的一种PECI请求命令。硬件接口信号还可以是其他协议类型的硬件接口信号,例如,HDMI(high definition multimedia interface,高清多媒体接口)信号、RGMII(reduced gigabit media independent interface,并行总线)信号、SGMII(serial gigabit media independent interface,单路传输的串行总线)信号、GPIO(general purpose input/output,通用型输入输出端口)信号、SPI(serial peripheral interface,串行外设接口)信号等。在此基础上,请求命令也可以是其他协议类型的请求命令,例如,在硬件接口信号为GPIO信号时,请求命令为GPIO请求命令。本申请对于请求命令和硬件接口信号的具体类型不作特殊限定。
步骤2,确定请求命令对应的多个逻辑位信息。
在步骤2中,第一操作系统在得到请求命令之后,可以分析得到请求命令对应的多个逻辑位信息,其中,多个逻辑位信息之间存在先后顺序,第一操作系统通过请求命令对应的多个逻辑位信息可以生成请求命令对应的波形信号(即硬件接口信号),从而通过硬件接口信号将请求命令包含的信息传输给其他设备。
可选地,请求命令中包括有至少一个字段,每个字段可以通过逻辑位0或1进行表示,在此基础上,每个字段与逻辑位1或0之间对应的转换关系即为该字段对应的逻辑位信息,在请求命令对应多个字段的情况下,请求命令对应有多个逻辑位信息。此外,每个逻辑位可通过高电平信号和低电平信号的结合使用来表示,例如,对于逻辑位0,可使用第一预设时长的高电平信号和第二预设时长的低电平信号来组合表示,对于逻辑位1,可使用第二预设时长的高电平信号和第一预设时长的低电平信号来组成表示,其中,第一预设时长和第二 预设时长不同。在此基础上,由于每个逻辑位既包含有高电平信号,也包含有低电平信号,因此每个逻辑位实际上是通过一段波形信号(高低电平信号之间的变换呈现为一个波形)来表示的,由于请求命令对应有多个逻辑位信息,也就是对应有多个逻辑位,因此请求命令对应的硬件接口信号是由每个逻辑位信息对应的波形信号组合得到的一个波形信号。
步骤3,根据多个逻辑位信息和定时器生成请求命令对应的硬件接口信号。
可选地,步骤3中的定时器可以是第一操作系统中的一个计时程序,定时器还可以是第一操作系统所在芯片上的一个寄存器,其中,定时器至少可以提供计时功能以及计数功能。本申请采用定时器的计时功能和计数功能,结合多个逻辑位信息生成请求命令对应的硬件接口信号。
需要注意到的是,以芯片为BMC芯片、硬件接口信号为PECI信号为例,在相关技术中,为了实现BMC芯片与CPU等元器件之间的PECI通信,相关技术需要BMC芯片本身具备PECI控制器的硬件逻辑设计,从而导致了BMC芯片的设计成本较高的问题。换言之,相关技术中,为了在BMC芯片上生成PECI信号,则必须要预先在BMC芯片上实现PECI控制器的硬件逻辑设计,而在本申请中,仅需要第一操作系统即可在BMC芯片上生成PECI信号,无需必须在BMC芯片上实现PECI控制器的硬件逻辑设计,从而降低了BMC芯片的设计难度和设计成本。
基于上述步骤,在本实施方式中,采用由第一操作系统生成请求命令对应的硬件接口信号的方式,首先通过第一操作系统获取请求命令,然后确定请求命令对应的多个逻辑位信息,最后根据多个逻辑位信息和定时器生成请求命令对应的硬件接口信号。
由上述内容可知,本实施方式中通过第一操作系统生成请求命令对应的硬件接口信号,从而实现了使用软件方式模拟生成硬件接口信号的技术效果,进而达到在无需对芯片进行硬件接口信号的硬件逻辑设计的基础上,利用软件系统生成硬件接口信号的目的,不仅能够降低芯片的设计难度,还能减低芯片的设计成本。
可选地,在通过第一操作系统检测到第二操作系统触发的第一请求的情况下,获取请求数据,其中,第一操作系统和第二操作系统在同一处理器上运行,请求数据由第二操作系统生成,第二操作系统的业务响应速度小于第一操作系统的业务响应速度。最后,由第一操作系统对请求数据进行解析,得到请求命令。
可选地,在获取请求数据之前,可以通过第二操作系统将请求数据存储至目标内存(即处理器上的存储空间)中,并在请求数据存储完毕之后,通过第二操作系统触发第一请求,其中,第一请求用于通知第一操作系统从目标内存中读取请求数据,目标内存为第一操作系统和第二操作系统均能够访问的内存。
在一种可选的实施例中,第一操作系统还可以接收硬件接口信号对应的响应数据,其中,响应数据的传输形式与硬件接口信号的传输形式相同。其次,第一操作系统还将响应数据的数据结构调整为第二数据结构。
另外,在将响应数据的数据结构调整为第二数据结构之后,通过第一操作系统触发第二请求,其中,第二请求用于通知第二操作系统读取响应数据。
以第一操作系统为RTOS系统,第二操作系统为Linux系统,硬件接口信号为PECI信号为例。针对命令请求过程,首先由Linux系统中涉及PECI业务的上层应用(如故障诊断、CPU温度获取等)根据需要主动发起PECI请求命令,这些请求命令包括但不限于基本的Ping()命令,获取CPU温度命令及读取MSR寄存器信息命令等,不同的PECI请求命令的代码实现由对应的接口函数完成。
可选地,Linux系统按照PECI协议规范将各请求命令的目标地址、读写长度、命令码、para参数等请求数据写入目标内存中,待请求数据全部写入目标内存之后,Linux系统产生第一请求通知RTOS系统。其中,第一请求可以是一种SGI中断请求(software generated interrupt,一种处理器核之间的通信中断请求)。
需要注意到的是,在通过第二操作系统将请求数据存储至目标内存中的过程中,第二操作系统将请求数据按照第一数据结构的形式存储至目标内存中,其中,第一数据结构至少包括设备地址、写长度、读长度、命令码以及请求参数,设备地址用于表征目标器件的地址,目标器件为依据硬件接口信号生成响应数据的器件,命令码用于区别不同的请求命令,写长度用于表征从命令码开始到请求数据结束的字节数量,读长度用于表征请 求数据中包含完成码以及读数据在内的字节数量,请求参数用于表征请求命令的参数。
针对命令响应过程,由RTOS系统接收PECI总线传来的响应数据,然后完成数据解析,以将响应数据的信号形式从硬件接口信号的形式转换为软件信号的形式,例如,识别硬件接口信号中的高电平信号与低电平信号之间的波形变化,从而得到对应的逻辑位信息,基于逻辑为信息得到软件信号数据。解析后的响应数据经命令参数结构化模块进行调整并写入目标内存中。待解析后的响应数据全部写入完毕后,RTOS系统触发第二请求通知Linux系统。Linux系统检测到第二请求,主动读取目标内存中存储的解析后的响应数据,数据经处理后返回给上层应用。其中,第二请求可以是一种SGI中断请求。
目标内存除了可以是共享内存之外,还可以是其他内存,例如,随机存取存储器(Random Access Memory,简称为RAM)、闪存存储器(Flash)等等。
在一种可选的实施例中,在根据逻辑位信息和定时器生成请求命令对应的硬件接口信号之后,第一操作系统可以对硬件接口信号的电压进行转换,得到目标硬件接口信号。
可选地,第一操作系统可以将硬件接口信号输入至电压转换器件中,得到电压转换器件输出的目标硬件接口信号。上述的电压转换器件可以是CPLD,并且CPLD可以与目标器件相连接,其中,目标器件可以是服务器中的CPU。需要注意到的是,上述业务除了可以应用于替代PECI接口生成PECI信号之外,还可以应用在其他硬件接口上。
由上述内容可知,联合嵌入式系统的第一操作系统与第二操作系统,通过核间中断与共享内存的方式实现了嵌入式系统中数据的交互,在RTOS系统中构建请求命令的波形发生功能模块,通过软件模拟的方式实现嵌入式系统与外部器件之间进行硬件接口信号的通信。另外,充分利用RTOS系统的高实时性特点,保证了在模拟请求命令波形时时序的准确性,具有灵活高效的特点。能够显著降低芯片设计难度,由于采用软件模拟生成硬件接口信号,为嵌入式系统中通信功能与其他业务功能间的优化设计提供了更多可能性,同时由于省去芯片中专门用于实现硬件接口信号通信的控制器,因此能够降低芯片的设计成本和制造成本。
在一个可选的实施方式中,第一操作系统上运行的业务可以但不限于包括串口切换业务,在本实施方式中提供了一种串口的切换过程,该过程包括如下步骤:
步骤1,在检测到第二操作系统接收到串口切换指令的情况下,通过第二操作系统将串口切换指令发送至第一操作系统。
可选地,在用户发起串口切换的时,可以通过第二操作系统检测是否接收到用户发起的串口切换指令。需要说明的是,串口切换指令中需要包括待切换至的目标串口的信息,例如,串口切换指令包括待切换至的目标串口的串口号。
在一个可选的实例中,串口切换指令的格式可以是<switch_command_app-n number-t sleep_time>,switch_command_app表征切换指令程序,-n代表切换的目标串口号,number的取值可以为1、2、3,-t代表从指令发起后休眠多久后执行切换动作,sleep_time单位为秒。
需要说明的是,在实现串口切换时可以为当前可以进行串口切换的串口进行编号,以便后续在进行串口切换时,通过串口号实现对目标串口的切换。
在一可选的实施例中,当前可以进行串口切换的串口包括:BMC Linux系统串口、服务器BIOS(Basic Input Output System,基本输入输出系统)串口以及SMART NIC(network interface controller,智能网络接口控制器)串口,对应的可以用1代表BMC Linux系统串口、2代表服务器BIOS串口,以及3代表SMART NIC串口。
步骤2,通过第一操作系统依据串口切换指令执行串口切换。
可选地,在检测到第二操作系统接收到串口切换指令的情况下,第二操作系统会立刻将串口切换指令发送至第一操作系统中。需要说明的是,可以将第一操作系统与第二操作系统分别运行两个处理器核心中,然后第一操作系统与第二操作系统之间采用核间通信,这样可以有助于提高信号传递的可靠性。
需要说明的是,第一操作系统对指令的响应速度远远快于第二操作系统对指令的响应速度,这样通过第一操作系统可以快速响应串口切换指令,并且在极短的时间内完成切换工作。
综上,通过运行于同一个处理器中的第一操作系统和第二操作系统来代替CPLD或FPGA实现串口切换软件功能,在第二操作系统接收到串口切换指令的情况下,通过第二操作系统将串口切换指令转发至第一操作系统中,第一操作系统根据串口切换指令实现串口的切换,避免了相关技术中需要通过CPLD或者FPGA将各个串口连接起来,然后利用CPLD或者FPGA中的开关结构的方式来实现串口切换,减少了硬件成本,并且在第一操作系统接收到串口切换指令之后,可以迅速在很短的时间内完成串口切换,因此,通过本方案提出的技术方法既可以有效降低串口切换成本,还可以有效提高串口切换的效率。
为了第二操作系统能够实现串口切换,在本实施方式提供的串口切换过程中,串口切换指令中至少包括:目标串口的串口号,在通过第一操作系统依据串口切换指令执行串口切换之前,包括以下步骤:通过第一操作系统从目标存储器中获取串口切换指令的解析规则;依据解析规则对串口切换指令中的目标串口的串口号进行解析,确定串口号对应的设备,其中,目标串口为设备的串口,目标串口连接于芯片中。
通过第一操作系统依据串口切换指令执行串口切换包括:通过第一操作系统确定设备的串口地址;依据串口地址将目标串口映射至芯片的目标输出接口。
为了使得第一操作系统能够实现串口切换,第一操作系统可以对串口切换指令进行解析,进而能够得到目标串口对应的设备。
在一可选的实施例中,可根据芯片或者服务器主板的不同来定制对串口切换指令的解析规则,并将解析规则保存在目标存储器中,目标存储器可以是带电可擦可编程只读存储器(eeprom)、非易失性内存(flash)等存储介质。需要说明的是,目标存储器可以部署在芯片中,还可以不部署在芯片中。通过目标存储器存储解析规则,提高了数据的安全性,以及可根据芯片或服务器主板的不同来定制解析规则,使得可编程性和可扩展性比较好。
在第一操作系统接收到串口切换指令之后,从目标存储器中读取串口切换指令的解析规则,然后利用解析规则对串口切换指令中的目标串口的串口号进行解析,得到这个串口号对应的设备。
在得到串口号对应的设备之后,第一操作系统就可以通过设备的串口地址将目标串口映射至芯片的目标输出接口。将设备的串口地址映射到目标输出接口之后,就可以通过目标输出接口实现对设备的访问。需要说明的是,串口切换指令和解析规则可以根据使用的芯片的型号以及第一操作系统、第二操作系统的类型进行设置。
在本申请实施例一提供的串口切换方法中,芯片包括:串行数据总线,在通过第一操作系统确定设备的串口地址之前,该方法还包括:确定与串行数据总线的串口连接的多个设备;通过串行数据总线将每个设备的串口映射至芯片的内存中,以得到每个设备的串口地址。
可选地,在上述的芯片中还包括串行数据总线,当前多个设备的串口的TX和RX与串行数据总线相连,比如当前的串口包括BMC Linux系统串口(UART1)、服务器BIOS串口(UART2)以及SMART NIC串口(UART3)。UART,Universal Asynchronous Receiver/Transmitter,通用异步收发传输器。串口数据总线会将UART1、UART2和UART3不同串口的TX和RX数据映射到BMC内存的不同地址空间中,也就是上述的通过串行数据总线将每个设备的串口映射至芯片的内存中。例如,UART1 TX和RX buffer为串口UART1的串口地址,UART2TX和RX buffer为串口UART2的串口地址,UART3 TX和RX buffer为串口UART3的串口地址。
当用户下发串口切换指令时,第一操作系统(RTOS)选择UART映射的不同三段内存(三选一),将其中一段内存数据交互给客户,达到模拟CPLD硬件串口切换电路的目的。需要说明的是,如果不能区分不同设备的串口,那么开发人员在维修时不能准确定位哪一个设备的串口是存在问题的,因此,需要通过串口切换实现对异常问题的定位。
在本实施方式中,在依据串口地址将目标串口映射至芯片的目标输出接口之后,若目标输出接口与目标智 能网卡连接,包括:通过智能网卡检测是否接收到对目标串口的访问请求;若接收到对目标串口的访问请求,则通过智能网卡将访问请求转发至目标串口。
可选地,在芯片的目标输出接口中还可以与目标智能网卡连接,然后通过智能网卡检测是否接收到用户对目标串口的访问请求,如果接收到对目标串口的访问请求,可以直接通过目标智能网卡实现对设备的串口访问,实现SOL(Serial over LAN,一种数据封包格式和协议的规范)功能。通过上述步骤,提高了对设备的串口访问效率。
在一可选的实施例中,在依据串口地址将目标串口映射至芯片的目标输出接口之后,还包括以下步骤:通过第一操作系统获取串口切换指令的执行结果,其中,执行结果为以下之一:切换成功和切换失败;通过第一操作系统将执行结果发送至第二操作系统。
通过第二操作系统接收串口切换指令的执行结果,其中,执行结果由第一操作系统发送至第二操作系统,执行结果为以下之一:串口切换成功和串口切换失败。在第一操作系统在切换完串口之后,会获取串口切换指令的执行结果,然后把串口切换指令的执行结果反馈到第二操作系统中,告知第二操作系统串口成功或者失败。
为了提高串口切换的成功率,在本实施方式中,在通过第二操作系统接收串口切换指令的执行结果之后,还包括:若执行结果为执行失败,则重复执行通过第二操作系统下发串口切换指令至第一操作系统的步骤,直至执行结果为成功,或者,执行串口切换的次数超过预设次数。若执行串口切换的次数超过预设次数,通过第二操作系统触发提示信号,其中,提示信号用于提示串口切换失败。
如果串口切换指令的执行结果为执行失败,那么需要重复执行通过第二操作系统下发串口切换指令至第一操作系统的步骤,直至执行结果为成功,或者,执行串口切换的次数超过预设次数,预设次数可以设置为3次。如果执行串口切换的次数超过了预设次数,对应的第二操作系统触发提示信号,来提示串口切换失败,以便对这种情况及时处理。
在检测到第一操作系统检测接收到串口切换指令之前,还包括:在第二操作系统启动完成后,第二处理器核心触发第一中断,并发送第一信号至第一操作系统;通过第一操作系统依据第一信号检测芯片中的多个串口的运行状态,得到检测结果;通过第一处理器核心触发第二中断,并将检测结果通过第二信号发送至第二操作系统;通过第二操作系统接收检测结果,以确定芯片中的运行正常的串口数量。
在第二处理器核心触发第一中断,并发送第一信号至第一操作系统之后,检测第一操作系统是否接收到第一信号;若第一操作系统接收到第一信号,则通过第一操作系统检测芯片中多个串口的运行状态,得到检测结果。
当第二操作系统启动完成之后,第二处理器核心触发第一中断(IPI中断,IPI,inter processor interrupts,处理器间中断),来将第一信号发送到第一操作系统,第一操作系统通过第一信号可以得知第二操作系统已正常启动,可以和第二操作系统进行正常交互,并且第一操作系统会根据第一信号检测芯片中的多个串口的运行状态,确定所有的串口是否运行正常。
在第一操作系统检测得到检测结果之后,第一处理器核心会触发第二中断来将检测结果通过第二信号发送至第二操作系统,第二操作系统通过检测结果确定可切换的串口数量(即上述的运行正常的串口数量),以便后续对这些串口进行串口切换。同时为了第一操作系统能够更加快速的实现串口切换,在第一操作系统检测完成后,第一操作系统开始阻塞等待接收第二操作系统发出的串口切换指令。
在一可选的实施例中,第一操作系统为RTOS,当第二操作系统为Linux时,第一操作系统运行在CPU0,第二操作系统运行在CPU1,串口切换前的准备步骤包括:当CPU1上的Linux系统启动到特定的阶段时候,CPU1会触发一个IPI中断,通知CPU0上的RTOS系统,Linux已正常启动,可以和CPU1上的Linux进行正常交互,RTOS系统收到来自CPU1上的IPI中断后,会启动串口切换控制器程序,检查UART1、UART2、UART3是否正常,然后CPU0再触发一个IPI中断,通知CPU1上的Linux操作系统,RTOS系统已启动完成,同时上报 的信息包含CPU0上的RTOS操作系统拥有可切换的串口数量,然后CPU0上的RTOS操作系统开始阻塞等待接收CPU1上的操作系统发出的切换指令。
在第二操作系统运行存在异常的情况下,通过服务终端将串口切换指令下发至第一操作系统;通过第一操作系统依据串口切换指令执行串口切换。
由于第二操作系统运行的功能较多、承担的业务量也比较大,因此,可以存在运行异常或者需要重启的情况,那么当第二操作系统运行存在异常时,可以直接通过服务终端将串口切换指令下发至第一操作系统,保证第一操作系统正常执行串口切换。需要说明的是,服务终端可以是芯片所处的服务器上的终端。
通过上述步骤,保证了第一操作系统不依赖于第二操作系统来实现对串口的切换,提高了第一操作系统执行串口切换的独立性。
综上,在本实施方式提供的串口切换过程中,通过运行于同一个处理器中的第一操作系统和第二操作系统来代替CPLD或FPGA实现串口切换软件功能,在第二操作系统接收到串口切换指令的情况下,通过第二操作系统将串口切换指令转发至第一操作系统中,第一操作系统根据串口切换指令实现串口的切换,避免了采用硬件的方式来实现串口切换,减少了硬件成本,并且第一操作系统接收到串口切换指令之后,可以迅速在很短的时间内完成串口切换,因此,上述过程既可以有效降低串口切换成本,还可以有效提高串口切换的效率。
通过本实施例,通过按照业务耦合度将待分配业务分配给对应的操作系统,可以保证对业务耦合度较高的多个业务进行业务处理的准确性。
在一个示例性实施例中,根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统,包括:
S61,将一组待分配业务中包含敏感信息的待分配业务,分配给目标操作系统,其中,目标操作系统是第一操作系统和第二操作系统中,与使用对象交互频率低的操作系统。
在本实施例中,对于包含敏感数据(例如,密码等敏感信息)的待分配业务(其可以为重要敏感型的业务,比如,不希望暴露给用户的业务),其可以被分配到目标操作系统,通过目标操作系统对包含敏感信息的待分配业务进行硬核级别的安全防护隔离,这里,目标操作系统是第一操作系统和第二操作系统中,与使用对象交互频率低的操作系统,或者,响应速度快的操作系统,例如,第一操作系统。
例如,该业务处理模块负责进一步对系统业务进行硬核级别的安全防护隔离,即,将重要敏感型(不希望暴露给用户)的业务划分为实时业务,最终可以实现这些业务由非实时操作系统至实时操作系统的卸载,起到安全防护的效果。这里,该业务处理模块划分出的不同业务在软件实现时可以采用结构体的形式进行组织。通过对异构操作系统间安全空间进行设计,将敏感型业务由非实时操作系统卸载至实时操作系统,达到硬核级别安全防护的目的。这里,敏感性业务是指:与安全相关的业务,比如,用户密码、身份信息等涉及用户个人隐私的业务。
这里,硬核级别是指业务在处理器核心层面进行了隔离,即,敏感型业务分配给实时操作系统(实时操作系统所占核心区别于非实时操作系统,所以属于核心层面的隔离),实时操作系统与非实时操作系统相比,与用户交互的频率和程度相对较弱,所以作为使用者的用户很难“探测”到运行在其上的业务产生的敏感数据。对于上层应用而言,用户的身份认证管理、安全加密等业务属于上述重要敏感性业务,通过业务管理模块将上述业务强行划分为实时业务,后续进行硬件资源动态分配时就能实现上述业务在实时操作系统运行,起到安全隔离效果。
通过本实施例,通过将包含敏感信息的待分配业务分配给与用户交互频率低的操作系统,可以对系统业务进行硬核级别的安全防护隔离,提高业务执行的安全性。
在一个示例性实施例中,确定与一组待分配业务对应的资源分配结果,包括:
S71,根据一组待分配业务的分配结果,结合第一操作系统的处理资源的资源利用情况和第二操作系统的处理资源的资源利用情况,生成一组待分配业务与处理器的处理资源的资源映射表。
在本实施例中,一组待分配业务的分配结果用于指示待分配业务与操作系统之间的对应关系,分配给一个操作系统的待执行业务通常使用该操作系统的处理资源执行,而如果某一操作系统分配的业务量过大且当前存在未分配处理资源,则也可以为分配给某一操作系统的待分配业务分配未分配处理资源。因此,根据一组待分配业务的分配结果,结合第一操作系统的处理资源的资源利用情况和第二操作系统的处理资源的资源利用情况,可以生成一组待分配业务与处理器的处理资源的资源映射表,以指示为每个待分配业务所分配的处理资源。
这里,每个待分配业务仅与某一处理器核心具有映射关系,而同一处理器核心可与多个待分配业务具有映射关系,不同的业务可以通过占用同一处理器核心的不同时间片与同一处理器核心具有映射关系。在同一时间,同一处理器核心仅被一个业务占用,即,仅用于执行一个业务。分配给一个操作系统的不同业务可以按照分配时间、业务响应速度要求或者其他方式确定占用同一处理器资源的时间片。
例如,资源动态分配模块根据业务管理模块的输出结果,对处理器资源进行动态调整,形成不同业务与实际硬件资源的资源映射表,优化不同硬件资源在异构操作系统下的部署结构,以达到提升全系统硬件资源利用率的目的。上述资源动态分配过程由第二操作系统中的软件进行管理配置。
以八核处理器(核心1~核心8)为例,已调度给第一操作系统的处理器核心包括:核心1,已调度给第二操作系统的处理器核心包括:核心2、核心3和核心4,待分配的业务有6个,实时性业务为业务1和业务2,非实时性业务为业务3~业务6,为6个业务分配对应的处理器核心,为业务1分配核心1,为业务2分配核心5,为业务3分配核心2,为业务4分配核心3,为业务5分配核心4,为业务6分配核心6。
通过本实施例,基于业务与操作系统的对应关系,结合不同操作系统的处理资源的使用情况进行处理资源的动态分配,可以保证处理资源分配的合理性。
在一个示例性实施例中,根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统,包括:
S81,在根据资源分配结果确定处理器的处理资源中的未分配处理资源存在对应的待分配业务的情况下,将未分配处理资源分配给与未分配处理资源对应的待分配业务所分配给的操作系统。
在进行处理资源分配时,如果处理器的处理资源中的未分配处理资源存在对应的待分配业务,即,为待分配业务分配了未分配处理资源,可以将未分配处理资源分配给与未分配处理资源对应的待分配业务所分配给的操作系统。
可选地,资源自适应调度模块可以根据硬件资源动态分配的结果,完成对处理器的处理资源的实际调度动作。资源自适应调度模块调度一部分处理器核心执行分配给第一操作系统的业务,如图4中所示的核心组1的M个核心,调度其余的处理器核心运行分配给第二操作系统的业务,如图4中所示的核心组2的N个核心。
以前述八核处理器为例,根据业务分配结果和资源分配结果,可以将未分配的核心4分配给第一操作系统,将未分配的核心5和核心6分配给Linux系统。整个调度过程可以由第二操作系统主导。
通过本实施例,基于资源分配结果将未分配的处理器资源调度给对应的操作系统,可以提高处理器资源的利用率。
在一个示例性实施例中,上述方法还包括:
S91,在第一操作系统和第二操作系统之间进行处理资源的抢占和释放。
在本实施例中,除了基于待分配业务进行处理器资源的动态分配以外,在各个操作系统运行的过程中,可以基于操作系统的处理资源的使用状态(负载情况),在第一操作系统和第二操作系统之间进行处理资源的抢占与释放。这里,处理资源的动态分配可以是基于除了第一操作系统和第二操作系统以外的其他控制逻辑模块所执行的资源调度方式,而处理资源的抢占和释放是由第一操作系统和第二操作系统主动发起的资源调度方式。
可选地,进行处理资源的抢占和释放可以是由核心抢占与释放模块执行的,该核心抢占与释放模块可以是 运行在第一操作系统和/或第二操作系统上的软件模组。以运行在在第一操作系统和第二操作系统上为例,核心抢占与释放模块主要完成系统实时运行过程中异构操作系统动态地对处理器核心进行抢占与释放,以达到处理器资源利用率的最大化目标。一个操作系统的资源抢占成功意味着另一操作系统的资源释成功,对应地,一个操作系统的资源抢占失败意味着另一操作系统的资源释放失败。如图5所示,经过核心抢占与释放,(M+N)个核心中的P个核心调度给了实时操作系统,(M+N-P)个核心调度给了非实时操作系统。
这里,核心抢占与释放模块可以用于完成异构操作系统实时运行的过程中,异构操作系统动态地对处理器核心等处理资源进行抢占与释放,以达到最大化处理器资源利用率的目标。
通过本实施例,通过在不同操作系统之间进行处理资源的抢占与释放,可以在操作系统运行的过程中基于操作系统的负载情况进行处理资源的动态调整,提高资源利用的合理性,同时,可以提高业务处理的效率。
在一个示例性实施例中,在第一操作系统和第二操作系统之间进行处理资源的抢占和释放,包括:
S101,通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放。
对于相关技术中由专门的加速硬件执行对于响应速度有要求的业务的方案,处理器与加速硬件(例如,CPU与FPGA/CPLD)之间的通信总线速率较低,整体性能不高。在本实施例中,通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放,即,可以由一个操作系统通过核间通信接口向另外一个操作系统发送用于进行处理资源抢占的请求或者用于请求进行处理资源释放的请求,以实现处理资源的抢占或者释放。相对于通过通信总线进行交互的方式,通过处理器内部的核间通信接口进行交互具更高的通信速率,提高了通信的整体性能。
例如,核间通信接口模块可以用于完成第一操作系统与第二操作系统的通信与交互功能。在进行核心抢占与释放的过程中,抢占方与释放方可以将各自的状态(如忙闲状态)通过核间通信接口告知对方,同时还需要特定的信号事件来表征异构操作系统的行为(如抢占行为)。因此,通过该核间通信接口模块进行核心抢占与释放,可以维持异构操作系统硬核资源平衡,保证处理器具有较高的占用率。
可选地,在不同操作系统之间进行处理资源的抢占和释放可以是通过核间中断完成的,例如,SGI(Software Generated Interrupt,软件触发中断,Linux系统中的核间中断),一个操作系统可以通过IPI(Inter Processor Interrupt,处理器间中断)向另一个操作系统发出资源抢占请求(例如,核心抢占请求)或者资源释放请求(例如,核心释放请求),以请求进行处理资源的抢占或者释放。以Linux系统为例,在Linux系统中可以基于自定义的中断向量表及异构操作系统间的中断事件实现核间通信。这里,IPI是在SOC(System on Chip,系统级芯片,也称片上系统)内多个核心(core)之间触发的中断,有别于常见的外设中断,因此核心可以专门预留部分中断号给IPI,在ARM 64架构(一种CPU构架)上是0-15这16个中断号。
可选地,抢占与释放过程取决于异构操作系统实时负载情况,例如,当第二操作系统负载急速增加,需要更多处理器核心支撑时,它可以通过IPI向第一操作系统发出核心抢占请求,以抢占第一操作系统的处理器核心,若第一操作系统此时处于空闲状态(比如,无任务调度)或者至少部分核心资源处于空闲状态,它将释放核心资源给第二操作系统,此时第二操作系统核心抢占成功,同时意味着第一操作系统核心释放成功。
需要说明的是,核心抢占与释放过程是一个动态循环往复的过程,每次核心抢占与释放都伴随着处理器硬核资源的调整,如图5所示,经过一次抢占与释放核心组1的核心数变成了P,核心组的核心数变成了M+N-P。此外,核心抢占与释放过程可以协同负载均衡策略、业务管理、资源自适应调度(例如,核心自适应调度)等模块来共同决定最终的核心调整结果。
这里,不同模块共同决定核心调整结果是指:某系统需要抢占更多核心资源时,最终的抢占成功与否需要负载均衡策略、业务管理、核心自适应调整等模块共同决定。例如,其中一种可能情况,当第二操作系统需要更多资源时,而第一操作系统虽然此时处于空闲状态(休眠状态),但由于第一操作系统很快要唤醒并运行一个重要的业务线程,且该线程运行时也需要很多的资源,这时第一操作系统就不能释放核心资源给第二操作系 统。此过程中判断业务重要性的标准、及最终资源不分配给第二操作系统的操作等均会涉及到负载均衡策略、业务管理、核心自适应调整等模块的参与。这些模块各自的策略又包含开放性的特点,这就决定了他们共同决定出的最终核心调整结果也是由这些策略共同作用的结果。
通过本实施例,通过核间通信接口进行不同操作系统之间的处理资源的抢占和释放,可以提高通信速率,提高通信的整体性能。
在一个示例性实施例中,通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放,包括:
S111,通过核间通信接口将第一操作系统的第一交互请求传输至第二操作系统,其中,第一交互请求用于请求与第二操作系统进行资源交互,资源交互包括以下之一:资源抢占,资源释放;
S112,通过核间通信接口获取第二操作系统响应第一交互请求返回的第一交互响应,其中,第一交互响应用于指示第一操作系统根据第一交互响应与第二操作系统进行资源交互。
在本实施例中,对于第一操作系统,考虑到处理器所处理的大部分业务是对业务响应速度的要求不高的业务,对应地,由第一操作系统处理的业务的业务量通常较少,因此,第一操作系统可以通过核间通信接口请求抢占第二操作系统的处理资源或者主动向第二操作系统释放其所占用的处理资源。可选地,处理资源的抢占和释放可以是通过请求-响应的交互方式进行的。
在需要抢占第二操作系统的处理资源或者主动向第二操作系统释放处理资源时,第一操作系统可以通过核间通信接口将第一操作系统的第一交互请求传输至第二操作系统,以请求与第二操作系统进行资源抢占和资源释放中的一种资源交互。在接收到第一交互请求之后,第二操作系统可以基于自身的负载情况等确定是否允许第一操作系统占用其至少部分处理资源或者是否接受第一操作系统释放的处理资源,并通过核间通信接口将第一交互响应返回给第一操作系统,从而可以使得第一操作系统根据第一交互响应与第二操作系统进行资源交互。
需要说明的是,上述处理资源的抢占和释放是在操作系统层面上的处理资源的调度(即,在第一操作系统和第二操作系统之间完成处理资源调度的协商),而并不是实际的处理资源调度,在进行处理资源的实际调度时,由资源自适应调度模块完成处理资源的实际调度。
通过本实施例,通过对请求-响应的方式进行不同操作系统之间的资源交互,且允许响应速度快的操作系统主动向响应速度慢的操作系统释放处理资源,可以提高处理资源的利用率。
在一个示例性实施例中,上述方法还包括:
S121,检测第一操作系统的处理资源的资源利用率;
S122,在根据第一操作系统的处理资源的资源利用率,确定第一操作系统待与第二操作系统进行资源交互的情况下,触发通过核间通信接口将第一交互请求传输至第二操作系统。
在本实施例中,处理资源的抢占与释放过程可以取决于异构操作系统的实时负载情况。在不同的操作系统内可能运行有用于检测被系统的负载情况的负载检测模块,其可以属于本系统内的系统控制模块,对于第一操作系统,其上可以运行有第一系统控制模块,该系统控制模块中的负载检测模块可以检测第一操作系统的处理资源的资源利用率,第一操作系统的处理资源的资源利用率可以用于表示第一操作系统的负载情况,处理资源的资源利用率越高,系统负载越重,反之,处理资源的资源利用率越低,系统负载越轻。
根据第一操作系统的处理资源的资源利用率,可以确定第一操作系统是否需要与第二操作系统进行资源交互,例如,如果一个操作系统(例如,第一操作系统)当前的资源利用率过高(达到一个指定利用率阈值),或者根据一个操作系统待执行业务确定出该操作系统未来的资源利用率过高(达到一个指定利用率阈值),则可以确定该操作系统需要抢占另一操作系统(例如,第二操作系统)的处理资源,如果资源利用率过低(低于另一个指定利用率阈值),则可以确定该操作系统需要释放处理资源给另一操作系统。可选地,如果确定第一操作系统待与第二操作系统进行资源交互,可以触发执行通过核间通信接口将第一交互请求传输至第二操作系 统的步骤。
通过本实施例,通过对请求-响应的方式进行不同操作系统之间的资源交互,且允许响应速度快的操作系统主动向响应速度慢的操作系统释放处理资源,可以提高处理资源的利用率。
在一个示例性实施例中,上述方法还包括以下至少之一:
S131,在第一操作系统的处理资源的资源利用率大于或者等于第一利用率阈值的情况下,确定第一操作系统待抢占第二操作系统的处理资源;
S132,在第一操作系统的处理资源处于空闲状态且不存在待第一操作系统执行的业务的情况下,确定第一操作系统待释放处理资源给第二操作系统。
在本实施例中,可以预先设定第一操作系统的处理资源的资源利用率的阈值,即,第一利用率阈值,如果第一操作系统的处理资源的资源利用率大于或者等于第一利用率阈值,可以确定第一操作系统当前的负载过重,需要抢占第二操作系统的处理资源满足自身的业务需求。
可选地,由于第一操作系统的响应速度高于第二操作系统,其通常是用于处于一些特定业务,但特定业务的触发具有一定的随机性、且通常业务频率通常较低,因此,第一操作系统的处理资源有一定概率处于空闲状态并且不存在待第一操作系统执行的业务。在此情况下,可以确定第一操作系统待释放至少部分处理资源给第二操作系统。
这里,可以在第一操作系统的处理资源处于空闲状态的情况下,查找与第一操作系统对应的待执行业务队列,如果该待执行业务队列为空(即,没有待执行业务),则确定第一操作系统在一定时间范围内不存在待执行业务,如果待执行业务队列不为空(即,包含待执行业务),则即使第一操作系统当前未执行业务,也不会释放处理资源给第二操作系统。
通过本实施例,通过在处理资源的资源利用率过高时进行处理资源的抢占,在处理资源处于空闲状态且没有后续需要处理的业务时进行处理资源的释放,可以提高资源调度的合理性,提高处理资源的利用率。
在一个示例性实施例中,上述方法还包括:
S141,在第一操作系统没有业务调度、且没有待分配给第一操作系统的业务的情况下,控制第一操作系统进入休眠状态。
在本实施例中,第一操作系统可以基于处理器周期性运行;或者,第一操作系统响应接收到的唤醒请求基于处理器运行;或者,第一操作系统根据处理器上所产生的当前操作业务与第一操作系统之间的匹配度基于处理器运行。第一操作系统可以在运行结束后进行休眠;第二操作系统在第一操作系统休眠期间将第一操作系统所使用的处理器资源(例如,处理器核心)添加至第二操作系统的调度资源池(即,可用资源池)中。
可选地,如果第一操作系统没有业务调度、且没有待分配给第一操作系统的业务(比如,第一操作系统的资源占用率低于或即将低于其设定的占用率下限),可以触发第一操作系统的主动休眠,即,主动进入休眠状态。在控制第一操作系统进行休眠状态之前,可以首先将第一操作系统的核心资源释放给第二操作系统(可以通过中断请求的方式进行资源释放);还可以对第一操作系统的系统现场数据进行保存,例如,将上述数据压入堆栈中,已便在第一操作系统被唤醒后,基于保存的系统现场数据恢复到之前的运行状态。
例如,当第一操作系统无任务调度(即,处于空闲状态)时,第一操作系统发送核心释放请求给第二操作系统,这时,第一操作系统的核心资源将由第二操作系统接管,第一操作系统进入休眠状态。
在一个可选的应用场景中,第一操作系统(例如,RTOS)周期性被唤醒运行,第一操作系统和第二操作系统交替占用调度同一处理资源(可以是处理器核心,例如,CPU核0),该同一处理器资源可以是第一处理资源,对应地,第二操作系统的处理资源可以是第二处理资源。在第一操作系统调度第一处理资源的时间片内,第二操作系统在第一时刻产生一个接管该第一处理资源的中断,导致第一操作系统不得不休眠。这时第一操作系统将现场保存在堆栈中,进行休眠,然后将第一处理资源释放给第二操作系统接管,等待第二操作系统调度完成后,在第二时刻将产生第一操作系统抢占第一处理资源的中断唤醒第一操作系统,第一操作系统从该时刻 又开始进入轮循模式占用调度第一处理资源。
在上述可选的应用场景中,在第二操作系统调度第一处理资源的时间片内,此时第一操作系统处于休眠状态,在第三时刻第一操作系统可能由于硬件上报的中断事件导致被唤醒,第二操作系统会将运行在第一处理资源的进程现场保留,第一操作系统占用第一处理资源,处理完硬件上报的中断事件后,在第四时刻又进入休眠状态,此时第一操作系统上报释放第一处理资源的中断给第二操作系统,第二操作系统继续按照设置的周期调度第一处理资源,恢复现场运行进程。
可选地,在本实施例中,第一操作系统在周期性运行的情况下,其单个运行周期的时长与两个运行周期之间的间隔时长可以相同也可以不同。两个运行周期之间的间隔时长中第一操作系统可以但不限于处于休眠状态,由第二操作系统来使用为第一操作系统分配的处理资源。如果单个运行周期的时长与两个运行周期之间的间隔时长相同,则第一操作系统和第二操作系统交替占用为第一操作系统分配的处理资源相同时长。如果单个运行周期的时长与两个运行周期之间的间隔时长不同,则第一操作系统和第二操作系统交替占用为第一操作系统分配的处理资源不同时长。可以第一操作系统占用的时长大于第二操作系统占用的时长,也可以第二操作系统占用的时长大于第一操作系统占用的时长。
在一个可选的实施方式中,以设备触发第一操作系统唤醒运行为例,提供了一种触发模式下第一操作系统(比如RTOS)唤醒策略,触发模式可以由第一操作系统总线域的设备发起的中断启动,第一操作系统总线域连接了设备0至设备N,当第一操作系统处于休眠状态时,假设某一时刻设备0触发中断给第一操作系统,第一操作系统随即被唤醒,唤醒后的第一操作系统先触发抢占第一处理资源的中断给第二操作系统,第二操作系统收到中断后首先释放第一处理资源,并保存现场(将运行的数据压入堆栈),然后第一操作系统调度第一处理资源处理设备0触发的中断所指示的操作业务,如果当前处于轮询模式下,后续处理过程与上述轮询模式相同,这里不再赘述。
通过本实施例,在一个操作系统全部的处理资源(例如,核心资源)已释放给另一个操作系统,并在所占用的处理资源为零时,控制操作系统进入到休眠状态,由于允许操作系统将全部的处理资源释放给另一个操作系统,从而提高处理资源的利用率。
在一个示例性实施例中,通过核间通信接口将第一操作系统的第一交互请求传输至第二操作系统,包括以下至少之一:
S151,通过核间通信接口将中断号为第一中断号的第一抢占请求传输至第二操作系统,其中,第一抢占请求用于请求抢占第二操作系统的处理资源;
S152,通过核间通信接口将中断号为第二中断号的资源释放请求传输至第二操作系统,其中,资源释放请求用于请求将资源释放系统所占用的处理资源释放给第二操作系统。
在本实施例中,在不同操作系统之间进行处理资源的抢占和释放可以是通过核间中断完成的,可以定义不同的中断事件对不同的资源交互类型,而不同的中断事件可以对应于不同的中断号,其中,为第一操作系统向第二操作系统申请抢占处理资源的第一中断事件所分配的中断号为第一中断号,为第一操作系统主动向第二操作系统释放处理资源的第二中断事件所分配的中断号为第二中断号。
作为一种可选的实施方式,第一交互请求可以是第一抢占请求,即,用于请求抢占第二操作系统的处理资源的请求,第一操作系统可以通过核间通信接口将中断号为第一中断号的第一抢占请求传输至第二操作系统,即,中断号为第一中断号的核间通信中断的触发源为第一操作系统,响应源为第二操作系统,此核间通信中断的含义为第一操作系统抢占第二操作系统的处理资源。
作为另一种可选的实施方式,第一交互请求可以是资源释放请求,即,用于请求将第一操作系统所占用的处理资源释放给第二操作系统,第一操作系统可以通过核间通信接口将中断号为第二中断号的资源释放请求传输至第二操作系统,即,中断号为第二中断号的核间通信中断的触发源为第一操作系统,响应源为第二操作系统,此核间通信中断的含义为第一操作系统主动释放处理资源给第二操作系统。
通过本实施例,通过分配用于在不同操作系统间抢占和主动释放处理资源的中断号,通过核间通信中断的方式进行操作系统间的资源调度,提高了资源调度的准确性。
在一个示例性实施例中,通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放,包括:
S161,通过核间通信接口将第二操作系统的第二交互请求传输至第一操作系统,其中,第二交互请求用于请求抢占第一操作系统的处理资源;
S162,通过核间通信接口获取第一操作系统响应第二交互请求返回的第二交互响应,其中,第二交互响应用于指示第一操作系统是否允许第二操作系统抢占第一操作系统的处理资源。
在本实施例中,对于第二操作系统,考虑到处理器所处理的大部分业务是对业务响应速度的要求不高的业务,对应地,由第二操作系统处理的业务的业务量通常较多,因此,第二操作系统可以通过核间通信接口请求抢占第一操作系统的处理资源。可选地,处理资源的抢占可以是通过请求-响应的交互方式进行的。
在需要抢占第一操作系统的处理资源时,第二操作系统可以通过核间通信接口将第二操作系统的第二交互请求传输至第一操作系统,以请求与第一操作系统进行以资源抢占为目标的资源交互。在接收到第二交互请求之后,第一操作系统可以基于自身的负载情况等确定是否允许第二操作系统占用其至少部分处理资源,并通过核间通信接口将第二交互响应返回给第二操作系统,从而可以使得第二操作系统根据第二交互响应与第一操作系统进行资源交互。
需要说明的是,上述处理资源的抢占是在操作系统层面上的处理资源的调度(即,在第一操作系统和第二操作系统之间完成处理资源调度的协商),而并不是实际的处理资源调度,在进行处理资源的实际调度时,由资源自适应调度模块完成处理资源的实际调度。
通过本实施例,通过对请求-响应的方式进行不同操作系统之间的资源交互,可以提高处理资源的利用率,同时,也可以提高业务处理的响应速度。
在一个示例性实施例中,上述方法还包括:
S171,检测第二操作系统的处理资源的资源利用率;
S172,在根据第二操作系统的处理资源的资源利用率,确定第二操作系统待抢占第一操作系统的处理资源的情况下,触发通过核间通信接口将第二交互请求传输至第一操作系统。
在本实施例中,处理资源的抢占过程可以取决于异构操作系统的实时负载情况。在不同的操作系统内可能运行有用于检测被系统的负载情况的负载检测模块,其可以属于本系统内的系统控制模块,对于第二操作系统,其上可以运行有第二系统控制模块,该系统控制模块中的负载检测模块可以检测第二操作系统的处理资源的资源利用率,第二操作系统的处理资源的资源利用率可以用于表示第二操作系统的负载情况,处理资源的资源利用率越高,系统负载越重,反之,处理资源的资源利用率越低,系统负载越轻。
根据第二操作系统的处理资源的资源利用率,可以确定第二操作系统是否需要与第一操作系统进行资源交互,例如,如果当前的资源利用率过高(达到一个指定利用率阈值)或者根据待执行业务确定出未来的资源利用率过高(达到一个指定利用率阈值),则可以确定第二操作系统需要抢占第一操作系统的处理资源。如果确定第二操作系统待与第一操作系统进行资源交互,可以触发执行通过核间通信接口将第二交互请求传输至第一操作系统的步骤。
通过本实施例,通过对请求-响应的方式进行不同操作系统之间的资源交互,且允许响应速度慢的操作系统主动抢占响应速度快的操作系统的处理资源,可以提高处理资源的利用率。
在一个示例性实施例中,上述方法还包括以下至少之一:
S181,在第二操作系统当前的资源利用率大于或者等于第二利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源;
S182,在根据第二操作系统的执行中业务和待执行业务确定第二操作系统的处理资源的资源利用率大于或 者等于第三利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源。
在本实施例中,考虑到业务处理的复杂性,业务与业务之间可能存在耦合关系,业务的重要性影响其所允许分配给的操作系统,此外,不同业务之间的优先处理等级之间也可能存在区别,第二操作系统可以综合自身的资源利用率、其待分配业务、待执行业务等多个方面的因素,确定是否需要抢占第一操作系统的处理资源。
作为一种可选的实施方式,可以预先设定第二操作系统的处理资源的资源利用率的阈值,即,第二利用率阈值,如果第二操作系统的处理资源的资源利用率大于或者等于第二利用率阈值,可以确定第二操作系统当前的负载过重,需要抢占第一操作系统的处理资源满足自身的业务需求。
作为另一种可选的实施方式,除了当前执行中业务以外,第二操作系统还需处理已分配给第二操作系统的业务,因此,可以预先设定第二操作系统的处理资源的资源利用率的阈值,即,第三利用率阈值,如果根据第二操作系统的执行中业务和第二操作系统的待执行业务确定第二操作系统的处理资源的资源利用率大于或者等于第三利用率阈值,可以确定第二操作系统待抢占第一操作系统的处理资源,可以确定第二操作系统即将处于负载过重状态,需要抢占第一操作系统的处理资源满足自身的业务需求。
此外,除了执行已分配业务(可以包括当前执行中业务,还可以包括已分配业务)以外,第二操作系统还可能会处理当前待分配的业务(即,新增的待分配业务)中,与其已分配业务之间的业务耦合度较高的业务,因此,可以预先设定第二操作系统的处理资源的资源利用率的阈值,即,第四利用率阈值,和新增的待分配业务与已分配业务之间业务耦合度的阈值,即,第三耦合度阈值,如果第二操作系统的处理资源当前的资源利用率大于或者等于第四利用率阈值、且新增的待分配业务与第二操作系统的已分配业务的业务耦合度大于或者等于第三耦合度阈值,可以确定第二操作系统即将处于负载过重状态,需要抢占第一操作系统的处理资源满足自身的业务需求。
可选地,第二利用率阈值与第三利用率阈值可以是相同的,也可以是不同的,例如,两者均为50%、60%或者其他值,第四利用率阈值可以是小于第二利用率阈值和第三利用率阈值的一个值,例如,40%,还可以是其他的利用率阈值,本实施例中对于各个利用率阈值不做限定。
通过本实施例,基于操作系统当前执行中业务、当前执行中业务和已分配业务、或者当前执行中业务和已分配业务以及新增的待分配业务,确定操作系统的资源调度需求,可以提高资源调度的灵活性,同时,也可提高处理资源的利用率。
在一个示例性实施例中,上述方法还包括:
S191,在第一操作系统的执行中业务的业务优先级不低于第二操作系统的待执行业务的业务优先级的情况下,确定第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源;
S192,在第一操作系统的执行中业务的业务优先级低于第二操作系统的待执行业务的业务优先级的情况下,确定第一操作系统允许第二操作系统抢占第一操作系统的处理资源。
对于第一操作系统,如果其当前处于空闲状态,且没有已分配业务待执行,或者没有待分配业务必须分配给第一操作系统,第一操作系统可以直接确定允许第二操作系统抢占自身的处理资源。如果第一操作系统当前正在处理业务、存在已分配待执行的业务、或者存在必须分配给第一操作系统的待分配业务,则需要综合上述业务的业务优先级等因素确定是否允许第二操作系统占用第一操作系统的处理资源。
可选地,如果第一操作系统的执行中业务的业务优先级不低于第二操作系统的待执行业务的业务优先级,表示第一操作系统执行中业务的紧要程度不低于第二操作系统待执行业务的紧要程度,第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源。而如果第一操作系统的执行中业务的业务优先级低于待执行业务的业务优先级,表示第一操作系统的执行中业务的紧要程度低于第二操作系统待执行业务的紧要程度,确定第一操作系统允许第二操作系统抢占第一操作系统的处理资源。
这里,虽然第一操作系统的响应速度高于第二操作系统的响应速度,通常业务优先级高的业务会优先分配给第一操作系统,但是,考虑到业务之间的耦合关系,业务优先级高的业务也可能会被分配给第二操作系统。 因此,在进行资源抢占时可以基于业务优先级进行判断。也可以考虑在第一操作系统的执行中业务以及待执行业务的业务优先级均不低于第二操作系统的待执行业务的业务优先级时,才允许进行处理资源的抢占。
通过本实施例,通过综合业务优先级等因素进行操作系统间处理资源的调度,可以提高资源调度的灵活性和合理性。
在一个示例性实施例中,通过核间通信接口将第二操作系统的第二交互请求传输至第一操作系统,包括:
S201,通过核间通信接口将中断号为第三中断号的第二抢占请求传输至第一操作系统,其中,第二抢占请求用于请求抢占第一操作系统的处理资源。
在本实施例中,与前述实施例中类似的,在不同操作系统之间进行处理资源的抢占和释放可以是通过核间中断完成的,可以定义不同的中断事件对不同的资源交互类型,而不同的中断事件可以对应于不同的中断号,其中,为第二操作系统向第一操作系统申请抢占处理资源的第三中断事件所分配的中断号为第三中断号。
可选地,第二交互请求可以是第二抢占请求,即,于请求抢占第一操作系统的处理资源的请求,第二操作系统可以通过核间通信接口将中断号为第三中断号的第二抢占请求传输至第一操作系统,即,中断号为第三中断号的核间通信中断的触发源为第二操作系统,响应源为第一操作系统,此核间通信中断的含义为第二操作系统抢占第一操作系统的处理资源。
通过本实施例,通过分配用于在不同操作系统间抢占处理资源的中断号,通过核间通信中断的方式进行操作系统间的资源调度,提高了资源调度的准确性。
在一个示例性实施例中,通过核间通信接口获取第一操作系统响应第二交互请求返回的第二交互响应,包括以下至少之一:
S211,通过核间通信接口将中断号为第四中断号的允许资源释放响应传输至第二操作系统,其中,允许资源释放响应用于指示第一操作系统允许第二操作系统抢占第一操作系统的处理资源;
S212,通过核间通信接口将中断号为第五中断号的拒绝资源释放响应传输至第二操作系统,其中,拒绝资源释放响应用于指示第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源。
在本实施例中,与前述实施例中类似的,在不同操作系统之间进行处理资源的抢占和释放可以是通过核间中断完成的,可以定义不同的中断事件对不同的资源交互类型,而不同的中断事件可以对应于不同的中断号,其中,为第二操作系统向第二操作系统申请返回资源抢占响应的第四中断事件和第五中断时间所分配的中断号为第五中断号,其中,第四中断事件为允许资源抢占的中断事件,第五中断事件为拒绝资源抢占的中断事件。
作为一种可选的实施方式,如果第一操作系统确定允许第二操作系统占用其至少部分处理资源,第一操作系统可以通过核间通信接口将中断号为第四中断号的允许资源释放响应传输至第二操作系统,即,中断号为第四中断号的核间通信中断的触发源为第一操作系统,响应源为第二操作系统,此核间通信中断的含义为第一操作系统被动释放处理资源给第二操作系统。
作为另一种可选的实施方式,如果第一操作系统确定拒绝第二操作系统占用其处理资源,第一操作系统可以通过核间通信接口将中断号为第五中断号的拒绝资源释放响应传输至第二操作系统,即,中断号为第五中断号的核间通信中断的触发源为第一操作系统,响应源为第二操作系统,此核间通信中断的含义为第一操作系统拒绝释放处理资源给第二操作系统。
通过本实施例,通过分配用于在不同操作系统间允许抢占处理资源和拒绝抢占处理资源的中断号,通过核间通信中断的方式进行操作系统间的资源调度,提高了资源调度的准确性。
作为一种可选示例,下面以RTOS系统和Linux系统为例对核间通信中断进行解释说明。在Linux系统中可以基于自定义的中断向量表及异构操作系统间的中断事件实现核间通信。Linux操作系统充分利用SGI未定义的位号,实现终端信号的自定义,降低核间通信的成本。未定义的位号可以是8-15号,在多核异构操作系统中,为了最大程度的兼容当下的资源分配方式,使用8-15号(共8个中断)表征核间中断向量表,向量表的一种可行分配方案如表1所示:
表1
其中,前述第一中断号对应于中断号12,前述第二中断号对应于中断号8,前述第三中断号对应于中断号9,前述第四中断号对应于中断号10,前述第五中断号对应于中断号11。
如表1所示,主动释放是指:当RTOS系统无业务调度(即,处于空闲状态)时,发送中断号为8的SGI中断到Linux系统,这时,RTOS的核心资源将由Linux系统接管,RTOS系统进入休眠状态,被动释放是指:当Linux系统业务负载急剧增加时,发送中断号为9的SGI中断到RTOS系统,若此时RTOS系统正在执行的进程允许被打断(RTOS系统上的进程都有优先级,可以根据实际情况配置,如果优先级高于中断9,则不可打断,低于则可以打断),RTOS系统将发送中断号为10的SGI中断到Linux系统并被动地释放其占用CPU核心资源供Linux系统调度使用,此后,RTOS系统进入休眠状态,若此时RTOS系统不允许被打断,它将发送中断号为11的SGI中断到Linux系统,以此告知Linux系统,此时RTOS的核心资源无法被释放,此时,Linux系统会按照当前的运行策略继续执行,不发生变化。
需要说明的是,核间通信向量表并不是唯一的,并不限于上述表1中所限定的核间通信向量表。
在一个可选的实施方式中,提供了一种核间通信的方法。上述方法包括如下步骤:
步骤1,第一操作系统将目标数据(可以是业务数据)发送至处理器内存中的目标虚拟通道(可以是存储空间)。
可选地,目标数据为待发送的数据,目标虚拟通道是内存中的一段空闲存储空间,第一操作系统将目标数据发送至处理器内存中的目标虚拟通道是指第一操作系统的CPU核将待发送数据写入目标虚拟通道。
步骤2,第一操作系统向第二操作系统发送中断通知消息(可以是前述的核间中断请求)。可选地,第一操作系统的CPU核向第二操作系统的CPU核发送中断通知消息,中断通知消息中可以携带目标虚拟通道的地址,用于通知第二操作系统从目标虚拟通道中获取目标数据,中断通知消息可以是软件触发的,也可以是硬件触发的。
步骤3,第二操作系统响应中断通知消息,从内存中的目标虚拟通道获取目标数据。可选地,第二操作系统的CPU核响应中断通知消息,从中断通知消息中解析目标虚拟通道的地址,再根据解析的地址定位至内存中的目标虚拟通道,从目标虚拟通道获取目标数据,实现第一操作系统和第二操作的系统之间的数据交互。
通过上述步骤,在处理器上运行的多个操作系统需要互相传输数据时,发送数据的第一操作系统将目标数据发送至处理器内存中的目标虚拟通道,并向第二操作系统发送中断通知消息,接收数据的第二操作系统响应中断通知消息从目标虚拟通道获取目标数据,解决了核间通信过程浪费资源,对操作系统的依赖性强的问题,达到减少核间通信过程对资源的浪费,对操作系统的依赖的效果。
在一个示例性实施例中,内存中包含数据存储区和元数据存储区,数据存储区被划分为多个存储单元,每个存储单元用于存储业务数据,元数据存储区用于存储数据存储区的各个存储单元的大小以及被占用状态。
可选地,目标虚拟通道由数据存储区的一个或多个存储单元构成,元数据存储区可以划分为与存储单元的数量相同的存储片,每个存储片用于记录一个存储单元的大小以及被占用状态,存储单元的大小可以由存储单元的首地址和末尾地址表征,也可以由首地址和存储单元的长度来表征,占用状态包含被占用状态和未被占用状态,可以由空闲标志的数值来表征。
在一个示例性实施例中,第一操作系统将目标数据发送至处理器内存中的目标虚拟通道包括:第一操作系 统读取元数据存储区中的记录,根据读取的记录确定数据存储区中处于空闲状态、总空间大于等于目标数据的长度的至少一个存储单元,得到目标虚拟通道;将元数据存储区中目标虚拟通道对应的至少一个存储单元的状态设置为被占用状态,并将目标数据存储在目标虚拟通道。
需要说明的是,为了保证目标数据可以连续写入内存,写入的目标虚拟通道需要是空闲的、且大于等于目标数据的长度的存储空间,由于内存划分为元数据存储区和数据存储区,可以读取元数据存储区记录的各个存储单元的占用状态,从中找出处于空闲状态的、可以满足数据存储需求的存储单元。
例如,每个存储单元的大小相等,若目标数据的长度大于一个存储空间的长度,则根据目标数据的长度确定所需的存储单元的数量,从中找出处于空闲状态的、连续的、数量满足数据存储需求的多个存储单元,构成目标虚拟通道。
再例如,每个存储单元的大小相等,数据存储区已预先对存储单元进行组合,得到多个大小不同的虚拟通道,每个虚拟通道由一个或多个存储单元组合而成,可以读取元数据存储区记录的各个虚拟通道的占用状态,从中找出处于空闲状态的、长度大于目标数据的长度的虚拟通道,也即目标虚拟通道。需要说明的是,当系统软件需要申请共享内存空间时候会判断需要申请的数据长度是否大于虚拟通道存放数据的最大长度,如大于虚拟通道存放数据的最大长度,系统软件可以把需要发送的数据分多次多送,保证每次发送数据的长度小于等于虚拟通道存放数据的最大长度,从而保证通信的顺利进行。
在一个示例性实施例中,第二操作系统响应中断通知消息,从内存中的目标虚拟通道获取目标数据包括:第二操作系统读取元数据存储区中的记录,根据读取的记录确定目标虚拟通道;从目标虚拟通道对应的至少一个存储单元获取目标数据,并将至少一个存储单元的状态设置为空闲状态。
也即,第二操作系统从目标虚拟通道对应的存储单元提取目标数据之后,为了不影响其他系统或任务对目标虚拟通道的使用,将目标虚拟通道对应的存储单元的状态设置为空闲状态。
在一个示例性实施例中,第一操作系统将目标数据发送至处理器内存中的目标虚拟通道包括:第一操作系统的驱动层接收目标数据,在内存中确定处于空闲状态的虚拟通道,得到目标虚拟通道;将目标虚拟通道的状态设置为被占用状态,并将目标数据存储至目标虚拟通道。
可选地,实时操作系统和非实时操作系统均具有驱动层,驱动层接收待发送的目标数据之后,调用接口在内存中寻找目标虚拟通道,为避免在写入数据的过程中其他系统申请使用目标虚拟通道,在找到目标虚拟通道之后,将目标虚拟通道的状态设置为被占用状态,再将目标数据写入目标虚拟通道。
在一个示例性实施例中,在第一操作系统中包含应用层的情况下,应用层设置有人机交互接口,在第一操作系统的驱动层在内存中确定处于空闲状态的虚拟通道之前,第一操作系统的应用层可以通过人机交换接口接收用户输入的待发送数据,采用预设格式封装待发送数据,得到目标数据,并调用数据写入函数通过预设通信接口将目标数据传递至驱动层,其中,预设通信接口设置在驱动层上。
可选地,应用层把需要发送的数据按照预设格式填充好,得到目标数据,然后在系统的/dev路径生成一个设备文件ipidev,应用层需要从驱动层读写数据的时候,可以先使用系统自带的open函数打开设备文件/dev/ipidev,然后就可以使用系统自带的写函数把目标数据从应用层发送到驱动层,驱动层再把数据放在共享内存中的目标虚拟通道,然后触发中断通知第二操作系统取数据。
在一个示例性实施例中,第二操作系统响应中断通知消息,从内存中的目标虚拟通道获取目标数据包括:第二操作系统基于中断通知消息触发中断处理函数,通过中断处理函数从内存中确定目标虚拟通道,并从目标虚拟通道获取目标数据。
在一个示例性实施例中,通过中断处理函数从内存中确定目标虚拟通道,并从目标虚拟通道获取目标数据包括:通过中断处理函数调用目标任务,由目标任务从内存中确定目标虚拟通道,并从目标虚拟通道获取目标数据。
可选地,中断处理函数发送任务通知唤醒负责数据提取的目标任务,目标任务先通过调用接口在共享内存 中寻找目标虚拟通道,然后从目标虚拟通道中读取目标数据并进行数据解析。
在一个示例性实施例中,在第二操作系统包含应用层的情况下,内存中存储有功能标识,功能标识指示目标功能,通过中断处理函数从内存中确定目标虚拟通道,并从目标虚拟通道获取目标数据包括:通过中断处理函数从内存中确定功能标识和目标虚拟通道,并将目标虚拟通道的地址信息发送给功能标志匹配的目标应用程序,其中,目标应用程序为应用层中的目标应用程序;目标应用程序调用数据读取函数通过预设通信接口将地址信息传递至驱动层,驱动层从目标虚拟通道获取目标数据,并将目标数据传递至目标应用层程序,其中,预设通信接口设置在驱动层,目标应用程序根据功能标识匹配的处理函数处理目标数据,以执行目标功能。
可选地,第二应用系统接收到中断通知消息之后,应用层调用对应的中断处理函数从内存中寻找目标虚拟通道,得到目标虚拟通道的地址信息,然后在系统的/dev路径生成一个设备文件ipidev,应用层需要从驱动层读写数据的时候,可以先使用系统自带的open函数打开设备文件/dev/ipidev,然后就可以使用系统自带的读函数读取目标虚拟通道中的目标数据,也即,驱动层根据目标虚拟通道的地址信息在共享内存中找到对应的目标数据,返回给应用层目标数据和目标数据的长度,在一个示例性实施例中,设置目标虚拟通道的状态为空闲。
需要说明的是,应用层的不同应用程序可以利用目标数据实现不同的功能,内存中存储有功能标识,指示应用程序通过目标数据实现的目标功能,可选地,功能标识可以为Net、Cmd,系统初始化的时候会把Net、Cmd和应用程序PID注册到驱动,驱动层根据收到的NetFn和Cmd就可以找到应用程序的PID,根据PID将数据要发送到对应的应用程序。
例如,NetFn=1,Cmd=1表示第一操作系统和第二操作系统之间互发“hello word”,在系统开始时会初始化一个数组,数组的一共三列,第一列NetFn,第二列Cmd,第三列对应NetFn和Cmd的处理函数记为xxCmdHandler。例如当第二操作系统收到第一操作系统发过来的消息时,从消息中获得NetFn和Cmd,判断NetFn=1,Cmd=1,就会去执行“helloword”对应的处理函数HelloCmdHandler去完成对应的功能。
在一个示例性实施例中,数据存储区中包含多个内存通道,每个内存通道由一个或多个存储单元构成,元数据存储区存储有多条记录,每条记录用于记录一个内存通道的元数据,每个内存通道的元数据至少包含内存通道的通道ID、内存通道的大小、内存通道的被占用状态,第一操作系统读取元数据存储区中的记录,根据读取的记录确定数据存储区中处于空闲状态、总空间大于等于目标数据的长度的至少一个存储单元,得到目标虚拟通道包括:遍历元数据存储区存储的记录,判断是否存在指示内存通道处于空闲状态、且内存通道的大小大于等于目标数据的长度的第一目标记录;在存在第一目标记录的情况下,将第一目标记录中记录的通道ID指示的内存通道确定为目标虚拟通道。
需要说明的是,可以将数据存储区划分为n个虚拟的内存通道,每个内存通道大小可以不等,也即,n个虚拟通道的大小依次为20*m、21*m、22*m、23*m……2n-1*m,其中,m为一个存储单元的大小,并设置以下结构体作为元数据管理内存通道:
typedef struct{
uint32_t Flag;
uint16_t ChannelId;
uint8_t SrcId;
uint8_t NetFn;
uint8_t Cmd;
uint32_t Len;
uint32_t ChannelSize;
uint8_t*pData;
uint8_t CheckSum;
}IpiHeader_T
其中,uint32_t Flag表征内存通道的状态,例如,0xA5A5A5A5表示此通道非空,否则为空;uint16_t ChannelId表示通道ID;uint8_t SrcId表示源CPU ID,源CPU是指向内存通道写入数据的CPU;uint8_t NetFn和uint8_t Cmd是功能参数;uint32_t Len为内存通道存储的数据的长度;uint32_t ChannelSize表示内存通道的大小;uint8_t*pData是指内存通道的首地址;uint8_t CheckSum是指校验和,第一操作系统需要发送数据时,会将发送的数据通过校验和算法计算出校验值,并将校验值发送至第二操作系统,第二操作系统在接收到数据和校验值的情况下,根据接收到的数据通过相同的校验和算法算出校验值,将计算出的校验值和接收到的校验值进行比较,如果一致,说明接收到的数据有效,如果不一致,说明接收到的数据无效。每个虚拟的内存通道对应一条结构体记录,此结构体记录会按照通道ID递增的方式依次存放在共享内存的开始位置,系统上电后会初始化这些结构体记录,初始化Flag为0表示此通道为空,初始化ChannelId依次为0、1、2…n-1,初始化ChannelSize为对应虚拟内存通道的大小,初始化pData指向对应虚拟内存通道的首地址。
在一个示例性实施例中,第一操作系统在确定目标虚拟通道时,根据待发送的目标数据的大小使用接口GetEmptyChannel在所有的内存通道中的寻找满足以下两个条件的虚拟通道:通道结构体IpiHeader中的空闲标志Flag不等于0xA5A5A5A5(也即通道处于空闲状态),且通道结构体IpiHeader中的通道的大小ChannelSize大于等于目标数据的大小(也即内存大小可以满足目标数据的存储需求)。在寻找到满足上述条件的目标虚拟通道后,把该通道的状态设置为非空,也即,设置通道结构体IpiHeader中的空闲标志Flag为0xA5A5A5A5,然后把目标数据拷贝到目标虚拟通道中。
在一个示例性实施例中,在内存通道被占用的情况下,内存通道的元数据还包括目标数据的源CPU核的ID以及目标数据的目的CPU核的ID,第二操作系统读取元数据存储区中的记录,根据读取的记录确定目标虚拟通道包括:遍历元数据存储区存储的记录,判断是否存在第二目标记录,其中,第二目标记录指示内存通道处于被占用状态、且目的CPU核的ID为第二操作系统的CUP核的ID,源CPU核的ID非第二操作系统的CUP核的ID;在存在第二目标记录的情况下,将第二目标记录中记录的通道ID指示的内存通道确定为目标虚拟通道。
也即,目标虚拟通道是所有的通道中满足以下三个条件的虚拟通道:一是通道结构体IpiHeader中的空闲标志Flag等于0xA5A5A5A5(即,指示通道处于被占用状态);二是通道结构体中的TargetId等于当前CPU的ID(即,指示目标数据的目的CUP是第二操作系统的CPU);三是通道结构体中的TargetId不等于SrcId(即,指示目标数据不是第二操作系统的CPU发送的)。
需要说明的是,若使用1位表示空闲标Flag,0表示通道空,1表示通道非空,如果Flag原本是0,突变为1,则系统在读取Flag之后会认为通道非空,从而导致通信异常。而本实施例中,将空闲标Flag设置为多位特殊字符,例如,0xA5A5A5A5,由于多位同时突变为特殊字符该概率大大小于一位突变概率,可以防止存储介质位突变对Flag的值造成影响,从而提高了通信的安全性。
在一个示例性实施例中,元数据存储区存储有状态映射表,状态映射表中有多条记录,每条记录用于记录一个存储单元的被占用状态,第一操作系统读取元数据存储区中的记录,根据读取的记录确定数据存储区中处于空闲状态、总空间大于等于目标数据的长度的至少一个存储单元,得到目标虚拟通道包括:确定目标数据待占用的存储单元的预设数量;从状态映射表的初始位置依次扫描每条记录;在扫描到连续的预设数量的目标记录的情况下,确定预设数量的目标记录指示的连续存储单元,其中,目标记录表征存储单元处于空闲状态;将连续存储单元确定为目标虚拟通道。
需要说明的是,为了便于数据的存储和提取,由于操作系统传递业务数据时需要占用内存中连续的存储单元,因此,首先需要确定内存申请指令中的存储单元的数量,由于每一存储单元的内存空间相同,因此可以通过所需内存的空间大小计算出需要的连续存储单元的预设数量,记作numb。
可选地,第一操作系统从状态映射表中的索引位置遍历记录,索引位置可以为状态映射表的起始位置,从状态映射表的起始位置开始,依次查询状态映射表的每条记录,判断是否存在连续的记录空闲内存页的大于等于numb的记录,在存在符合上述条件的记录的情况下,通过记录与内存页的对应关系,确定处理器中的连续存储单元,并将该连续存储单元确定为目标虚拟通道,以向目标虚拟通道写入数据。
在一个示例性实施例中,中断通知消息中包含连续存储单元的首地址和预设数量,第二操作系统读取元数据存储区中的记录,根据读取的记录确定目标虚拟通道包括:从状态映射表的初始位置依次扫描每条记录;在扫描到记录有连续存储单元的首地址的情况下,将扫描到的地址指示的存储单元以及预设数量减一的连续存储单元确定为目标虚拟通道。
可选地,连续存储单元是指数量等于numb的连续存储单元,状态映射表中的每条记录还记录有对应存储单元的首地址,第二操作系统在映射表中扫描到数量等于numb的连续存储单的首地址的记录情况下,说明扫描到了目标虚拟通道的首地址,首地址指示的存储单元以及该存储单元之后的numb-1个连续存储单元构成目标虚拟通道,第二操作系统目标虚拟通道中获取数据,以完成和第一操作系统的数据交互。
在一个示例性实施例中,通过计数器对扫描到的连续的目标记录进行记录,在按照存储单元的数量从状态映射表的初始位置依次扫描每条记录的过程中,在当前扫描到目标记录的情况下,控制计数器加一,在当前扫描到非目标记录的情况下,控制计数器清零。
可选地,利用计数器的数值与所需存储单元数量的大小关系判断是否存在连续的预设数量的目标记录,也即是否存在预设数量的连续存储单元,可选地,将计数器的计数记作cntr,若扫描到的一个存储单元为空,则将cntr进行加1操作,若扫描到的存储单元不为空,则将累加的连续、处于空闲状态的存储单元的数量cntr清零,继续从该存储单元后一个地址处开始寻找连续、处于空闲状态的存储单元;直到cntr等于numb,表示已找到了满足内存需求的连续、处于空闲状态的存储单元;如果在扫描完整个状态映射表之后,不存在cntr大于等于numb,则表明本次动态申请内存失败,不存在预设数量的连续存储单元。
在一个示例性实施例中,在第一操作系统读取元数据存储区中的记录,根据读取的记录确定数据存储区中处于空闲状态、总空间大于等于目标数据的长度的至少一个存储单元,得到目标虚拟通道之前,该方法还包括:第一操作系统发送内存申请指令,并对处理器的内存执行加锁操作,其中,内存申请指令用于申请使用处理器的内存;在对内存加锁成功的情况下,读取状态映射表中的记录。
可选地,内存申请指令是运行在处理器上的操作系统发出的申请使用处理器的内存的指令,需要说明的是,为防止多个操作系统同时申请使用处理器的内存时导致申请冲突,因此,在操作系统发送内存申请指令时,先对处理器的内存执行加锁操作,当加锁成功后才可以申请使用内存,加锁操作是指内存申请的排他操作,在当前操作系统加锁成功之后,若没有释放加锁,其他服务器没有申请使用处理器内存的权限。
在一个示例性实施例中,对处理器的内存执行加锁操作包括:判断内存当前是否处于被加锁状态,其中,被加锁状态表征内存处于被申请使用的状态;在内存当前未处于被加锁状态的情况下,对内存执行加锁操作;在内存当前处于被加锁状态的情况下,确定对内存的加锁失败,在预设时长后再次申请对处理器的内存进行加锁,直至对内存加锁成功,或者,直至申请加锁的次数大于预设次数。
在处理器运行之前,需要将处理器中的元数据存储区以及数据存储区进行初始化操作,可选地,将元数据存储区中的状态映射表存储的记录进行初始化,并将内存管理信息进行初始化操作。
在进行申请内存操作前,对内存管理信息进行如下配置:
typedef struct{
uint32_t MemReady;
uint32_t MemLock;
}MallocMemInfo_T;
其中,结构体MallocMemInfo_T的成员变量MemLock表示共享内存是否已初始化完成,变量MemReady为 0xA5A5A5A5,表示初始化操作已完成,可以正常动态申请和释放内存;结构体MallocMemInfo_T的成员变量MemReady表征是否被加锁。
可选地,若读取到变量MemLock为0,表示此时没有系统或任务在申请内存,也即内存当前未处于被加锁状态。若读取到变量MemLock为0xA5A5A5A5,表示有系统或任务正在申请内存,需要等此次申请完成后再申请,当前申请加锁失败。
在一个示例性实施例中,若对内存进行加锁操作时存在加锁失败的情况下,通过预设时长的等待后再次申请内存的加锁,直至加锁成功,例如,预设时长可以为100微秒。
在一个示例性实施例中,若申请加锁失败,并且重复申请的次数超出了预设次数,表明当前时长中处理器中的内存处于不可分配状态,则停止申请操作。例如,预设次数可以为3次,在申请请加锁的次数大于3次的情况下,可以向发送申请的操作系统返回当前内存不可用的消息。
可选地,在处理器的内存空间中存在可供第一操作系统使用的目标虚拟通道后,第一操作系统将需要传输的目标数据存储到相应的目标虚拟通道,在一个示例性实施例中,根据第一操作系统的数据写入情况更新处理器的内存空间的占用状态,也即将目标连续内存空间由未占用状态变为被占用状态,同时,为了使得其他系统或任务可以申请内存,释放对内存的加锁。
在一个示例性实施例中,该方法还包括:在未扫描到连续的预设数量的目标记录的情况下,释放对内存的加锁。
可选地,在对状态映射表中的记录进行扫描后,检测不到预设数量的、连续、处于空闲状态的存储单元,表明处理器的内存中没有足够的空间内存页供第一操作系统使用,本次动态申请内存失败,释放对内存的加锁。
在一个示例性实施例中,通过软件中断的方式向第二操作系统发送中断通知消息。可选地,通过软件中断的方式向第二操作系统发送中断通知消息包括:向处理器的预设寄存器中写入中断号和第二操作系统的CPU核的ID,并基于中断号和第二操作系统的CPU核的ID生成中断通知消息。
可选地,软中断是软件产生的中断,软件可以给执行自己的CPU核发送中断,也可以给其他的CPU核发送中断。预设寄存器可以为GICD_SGIR寄存器,可以通过软件向GICD_SGIR寄存器写入SGI(Software Generated Interrupts,软件中断)中断号、目的CPU ID,来产生一个软件中断,SGI中断号是为核间通信保留的软中断号。
可选地,硬件中断是指通过硬件设备产生的中断,可以为私有外设中断,也可以为共享外设中断,需要说明的是,硬中断是CPU外部的硬件引入的中断,具有随机性,软中断是CPU中运行的软件执行中断指令引入的中断,是预先设定的,本实施例不限定产生中断通知消息的方式。
在一个可选的实施方式中,提供了一种共享内存的方法。该方法包括如下步骤:
步骤1,接收内存申请指令,并对处理器的内存执行加锁操作,其中,内存申请指令用于申请使用处理器的内存。
可选地,内存申请指令是运行在处理器上的操作系统发出的申请使用处理器的内存的指令,其可以是第一操作系统发送的。需要说明的是,为防止多个操作系统同时申请使用处理器的内存时导致申请冲突,因此,在操作系统发送内存申请指令时,先对处理器的内存执行加锁操作,当加锁成功后才可以申请使用内存,加锁操作是指内存申请的排他操作,在当前操作系统加锁成功之后,若没有释放加锁,其他服务器没有申请使用处理器内存的权限。
在本申请实施例提供的共享内存的方法中,在对处理器的内存执行加锁操作之前,该方法还包括:判断内存当前是否处于被加锁状态,其中,被加锁状态表征内存处于被申请使用的状态;在内存当前未处于被加锁状态的情况下,对内存执行加锁操作。
可选地,由于多个系统或多个任务在同时申请使用内存时会导致申请冲突,处理器的内存在同一时间段内 只能被一个系统或任务进行加锁,因此,在检测到当前内存未处于被加锁状态的情况下,当前操作系统才能对内存执行加锁操作。
可选地,通过判断内存中存储的预设变量是否为预设值来判断内存是否处于被加锁状态,若预设变量不为预设参值数,则表明内存未处于被加锁状态,没有其他系统或任务在申请内存空间,则加锁成功;反之,预设变量为预设参数,则表明在当前时刻内存处于被加锁状态,存在除该操作系统之外的其他系统或任务在申请内存空间,则加锁失败。
在该共享内存的方法中,在判断内存当前是否处于被加锁状态之后,还包括:在内存当前处于被加锁状态的情况下,确定对内存的加锁失败;在对内存的加锁失败的情况下,在预设时长后再次申请对处理器的内存进行加锁,直至对内存加锁成功,或者,直至申请加锁的次数大于预设次数。
可选地,若对内存进行加锁操作时存在加锁失败的情况下,通过预设时长的等待后再次申请内存的加锁,直至加锁成功,例如,预设时长可以为100微秒。
在一个示例性实施例中,若申请加锁失败,并且重复申请的次数超出了预设次数,表明当前时长中处理器中的内存处于不可分配状态,则停止申请操作。例如,预设次数可以为3次,在申请请加锁的次数大于3次的情况下,可以向发送申请的操作系统返回当前内存不可用的消息。
步骤2,在对内存加锁成功的情况下,读取内存的被占用状态,并根据内存的被占用状态判断内存中是否存在空闲的目标内存空间,其中,目标内存空间的大小大于等于内存申请指令申请的内存的大小。
在申请加锁成功后,操作系统对处理器中的内存进行申请,可选地,根据操作系统发出的内存申请指令,扫描用于记录内存被占用状态的信息,判断是否存在目标内存空间,也即,判断处理器中是否存在处于未被占用状态的、连续的可以满足内存使用需求的内存空间,满足内存使用需求是指内存空间的大小大于等于操作系统申请的内存大小。在一个示例性实施例中,判断处于未被占用状态的、连续的内存空间的大小是否大于等于操作系统申请的内存大小,得到判断结果。
需要说明的是,申请内存时还可以使用不连续的内存空间,可以在非一个最小内存块后的后面增加一个指针,指向下一个申请获得的最小内存块,同时,在数据读写的时候,根据存储地址和指针实现数据跨数据块的数据读写。本实施例不限定目标内存空间的形式。
步骤3,在内存中存在目标内存空间的情况下,将目标内存空间的地址信息反馈至内存申请指令的发送端,更新内存的被占用状态,并释放对内存的加锁。这里,发送端是指发送内存申请指令的操作系统(例如,第一操作系统),需要说明的是,由于操作系统在核间通信时,通过使用共享内存发送和接收数据,并在收发数据的过程中使用申请的内存返回的地址进行数据的存取,因此需要确定已申请的内存空间的地址信息。
可选地,在处理器的内存空间中存在可供操作系统使用的目标内存空间(可以是由前述判断结果指示的)后,将该目标连续空间的地址信息发送给该操作系统,操作系统根据地址信息将需要传输的数据存储到相应的内存空间中。
在一个示例性实施例中,根据操作系统的数据写入情况更新处理器的内存空间的占用状态,即,将目标内存空间由未占用状态变为被占用状态,并释放在动态申请内存之前的加锁操作,以使其他操作系统可以申请使用处理器的内存空间。
通过上述步骤,可以解决多个内核间共享内存的使用效率低、灵活性差以及过于依赖操作系统的问题,达到提高共享内存灵活性以及使用效率,并降低对操作系统的依赖的效果。
在该共享内存的方法中,内存中包括元数据存储区和数据存储区,数据存储区用于存储业务数据,元数据存储区存储有状态映射表,状态映射表用于记录数据存储区的被占用状态,读取内存的被占用状态,并根据内存的被占用状态判断内存中是否存在空闲的目标内存空间包括:从元数据存储区中读取状态映射表中的记录,并根据状态映射表中的记录判断数据存储区中是否存在目标内存空间。
通过查询状态映射表中的记录的方式查询内存的被占用状态,可选地,获取处理器中存储的元数据存储 区,并识别元数据存储区中的状态映射表,通过遍历状态映射表中的记录,读取数据存储区的被占用状态,判断数据存储区中是否存在连续的、处于空闲状态的、满足内存使用需求的内存空间。
在本申请实施例提供的共享内存的方法中,数据存储区由多个内存页构成,状态映射表中包含多条记录,每条记录用于记录一个内存页的被占用状态,从元数据存储区中读取状态映射表中的记录,并根据状态映射表中的记录判断数据存储区中是否存在目标内存空间包括:确定内存申请指令申请的内存页的预设数量;从状态映射表的初始位置依次扫描每条记录;在扫描到连续的预设数量的目标记录的情况下,确定内存中存在目标内存空间,其中,目标记录指示内存页处于空闲状态。
需要说明的是,数据存储区按照相同的内存大小划分为多个分配单元,将每一个分配单元记作一个内存页,例如,数据存储区的内存空间为A字节,划分的分配单元为B字节,则该数据存储区共包含A/B个内存页,状态映射表中的记录也即内存页记录,每条内存页记录用于记录一个内存页的被占用状态,状态映射表中的内存页记录和数据存储区中的内存页的数量相同。
图6是根据本申请实施例的共享内存的方法中状态映射表和内存页的关系示意图,如图6所示,数据存储区即为动态分配内存块区,元数据存储区包括动态分配内存映射表区,其中,映射表区按照数据存储区划分内存页的数量划分相同数量的记录,并将该记录记作内存页记录,并将所有内存页记录组合为状态映射表,状态映射表中所有内存页记录与数据存储区的所有内存页存在一一对应关系,每一内存页记录中表示对应的内存页的分配状态,也即内存页是否被占用。
可选地,由于操作系统进行协同的业务数据需要占用处理器中连续的内存页,因此,首先需要确定内存申请指令中的内存页的预设数量,由于每一内存页的内存空间相同,因此可以通过所需内存的空间大小计算出需要的连续内存页的预设数量,记作numb。
在一个示例性实施例中,在获取到处理器的元数据存储区中的状态映射表后,从状态映射表中的索引位置遍历内存页记录,索引位置可以为状态映射表的起始位置,从状态映射表的起始位置开始,依次查询状态映射表的每条内存页记录,确定是否存在连续的记录空闲内存页的大于等于numb的内存页记录,在存在符合上述条件的内存页记录的情况下,通过内存页记录与内存页的对应关系,确定处理器中存在目标内存空间。
在本申请实施例提供的共享内存的方法中,在从状态映射表的初始位置依次扫描每条记录之后,该方法还包括:在扫描完毕状态映射表中的所有记录,且不存在连续的预设数量的目标记录的情况下,确定内存中不存在目标内存空间。
可选地,从状态映射表的起始位置开始,查询状态映射表的内存页记录确定是否存在连续、并且内存页数量大于等于numb的空间,若扫描完毕整个状态映射表后仍未发现存在连续的、预设数量的空闲内存页,则表明不存在目标内存空间。
在本申请实施例提供的共享内存的方法中,通过计数器对扫描到的目标记录的数量进行记录,在从状态映射表的初始位置依次扫描每条记录的过程中,在当前扫描到目标记录的情况下,控制计数器加一,在当前扫描到非目标记录的情况下,控制计数器清零,其中,非目标记录指示内存页处于被占用状态。
可选地,通过利用计数器的数值与所需内存页数量的大小关系判断是否存在连续的预设数量的目标记录,也即是否存在目标内存空间,可选地,将计数器的计数记作cntr,若扫描到的一页内存页为空,则将cntr进行加1操作,若扫描到的内存页不为空,则将累加的连续、空闲状态的内存页的数量cntr清零,继续从该内存页后一个地址处开始寻找连续的空的内存页;直到cntr等于numb,表示已找到了满足内存需求的连续、处于空闲状态的内存页;如果在扫描完整个状态映射表的过程,cntr小于numb,则表明本次动态申请内存失败,不存在目标内存空间。
在本申请实施例提供的共享内存的方法中,在初始位置为状态映射表中的最后一个位置的情况下,将目标内存空间的地址信息反馈至内存申请指令的发送端包括:确定连续的预设数量的目标记录中最后扫描到的目标记录,将最后扫描到的目标记录指示的内存页的首地址反馈至发送端。
可选地,当对状态映射表进行扫描时,扫描方式可以选择从状态映射表的第一个位置扫描或者从状态映射表的最后一个位置开始扫描,当扫描方式为从状态映射表的最后一个位置扫描时,在计数器显示的数值cntr大于等于预设数量numb时,将扫描到的最后一个内存页记录对应的内存页的首地址,并再内存页记录中将这些内存页的状态置为非空,将首地址作为本次内存申请指令的整个连续内存页的首地址。
在一个示例性实施例中,将该地址反馈至发出内存申请指令的操作系统,由操作系统根据地址信息对内存进行数据写入操作。
在本申请实施例提供的共享内存的方法中,初始位置为状态映射表中的第一个位置,将目标内存空间的地址信息反馈给内存申请指令的发送端包括:确定连续的预设数量的目标记录中首个扫描到的目标记录,将首个扫描到的目标记录指示的内存页的首地址反馈至发送端。
可选地,当扫描方式为从状态映射表的第一个位置扫描时,在计数器显示的数值cntr大于等于预设数量numb的情况下,将扫描到的第一个内存页记录的地址作为首地址,将其发送到发出内存申请指令的操作系统中,由操作系统根据地址信息对内存进行数据写入操作。
在本申请实施例提供的共享内存的方法中,在从状态映射表的初始位置依次扫描每条记录的过程中,通过预设变量存储扫描到的连续的目标记录中的首个目标记录。
可选地,预设变量是指状态映射表中用于存储初始位置的地址信息的变量,并将其记作offset,每扫描到一个空闲、连续的内存页时,计数器显示的数值cntr进行加1操作,在计数器显示的数值cntr大于等于预设数量numb的情况下,将offset当前存储的地址信息作为首个目标记录的地址。
在本申请实施例提供的共享内存的方法中,在读取内存的被占用状态,并根据内存的被占用状态判断内存中是否存在空闲的目标内存空间之后,该方法还包括:在内存中不存在空闲的目标内存空间的情况下,释放对内存的加锁。
可选地,在对状态映射表中的内存页记录进行扫描后。检测到不包含预设数量的、连续、空闲的内存页,也即不包含目标内存空间时,表明处理器的内存中没有足够的空间内存页供该操作系统使用,本次动态申请内存失败,释放对内存的加锁。
在本申请实施例提供的共享内存的方法中,内存中包括元数据存储区和数据存储区,数据存储区用于存储业务数据,元数据存储区存储有内存管理信息,判断内存当前是否处于被加锁状态包括:读取元数据存储区存储的内存管理信息,判断内存管理信息是否包含预设信息,其中,预设信息表征内存处于被加锁状态;在内存管理信息包含预设信息的情况下,确定内存当前未处于被加锁状态;在内存管理信息不包含预设信息的情况下,确定内存当前处于被加锁状态。
对于判断处理器的内存是否处于被加锁状态,需要利用元数据存储区中的内存管理信息进行判断,可选地,在获取到元数据存储区的内存管理信息时,利用根据判断内存管理信息中是否包含预设信息,其中,预设信息是用于表征内存是否处于被加锁状态;若内存管理信息中未包含预设信息,则表明当前内存处于未被加锁状态,反之则处于被加锁状态。
在本申请实施例提供的共享内存的方法中,内存管理信息包括第一字段信息和第二字段信息,第一字段信息用于描述内存是否处于被加锁状态,第二字段用于描述内存是否初始化完成,在接收内存申请指令之前,该方法还包括:初始化数据存储区存储的第一字段信息和第二字段信息。
在嵌入式系统运行之前,需要将处理器中的元数据存储区以及数据存储区进行初始化操作,可选地,将元数据存储区中的状态映射表存储的内存页记录进行初始化,并将内存管理信息进行初始化操作。
可选地,内存管理信息由第一字段信息以及第二字段信息组成,第一字段信息表征是否被加锁,第二字段信息用于表征是否初始化完成。
在本申请实施例提供的共享内存的方法中,更新内存的被占用状态包括:将状态映射表中记录的目标内存空间对应的内存页的状态变更为被占用状态。
可选地,在操作系统需要占用目标内存空间的情况下,通过识别目标内存空间的多个内存页的地址信息,按照内存页与内存页记录的对应关系,更新元数据存储区的状态映射表区的内存页记录,使其由未占用状态变为被占用状态。进一步地,根据操作系统的数据写入情况更新处理器的内存空间的占用状态,也即将目标内存空间由未占用状态变为被占用状态,并释放在动态申请内存之前的加锁操作。
可选地,响应第一操作系统的存储操作,将目标数据存储至目标内存空间,并将连续内存空间的地址信息发送至第二操作系统;接收第二操作系统基于地址信息发送的获取指令,将目标内存空间存储的目标数据发送至第二操作系统。
这里,在申请内存成功后,第一操作系统将需要传递的目标数据存储值申请的目标内存空间,并向与第一操作系统协同的第二操作系统发送该目标内存空间的地址信息,通知第二操作系统进行数据获取。可选地,在第二操作系统接收到目标内存空间的地址信息后,发出数据的获取指令,嵌入式系统接收该指令并将存储在目标内存空间的目标数据发送到第二操作系统中。
通过上述步骤,接收第一操作系统的内存申请指令,并对处理器的内存执行加锁操作,其中,内存申请指令用于申请使用处理器的内存;在对内存加锁成功的情况下,读取内存的被占用状态,并根据内存的被占用状态判断内存中是否存在空闲的目标内存空间,其中,目标内存空间的大小大于等于内存申请指令申请的内存的大小;在内存中存在目标内存空间的情况下,将目标内存空间的地址信息反馈至内存申请指令的发送端,更新内存的被占用状态,并释放对内存的加锁;响应第一操作系统的存储操作,将目标数据存储至目标内存空间,并将连续内存空间的地址信息发送至第二操作系统;接收第二操作系统基于地址信息发送的获取指令,将目标内存空间存储的目标数据发送至第二操作系统,解决了多个内核间共享内存的使用效率低、灵活性差以及过于依赖操作系统的问题,达到提高共享内存灵活性以及使用效率,并降低对操作系统的依赖的效果。
在一个示例性实施例中,在第一操作系统使用物理地址作进行数据读写操作,第二操作系统使用虚拟地址作进行数据读写操作的情况下,第二操作系统将目标内存空间的地址信息转换为虚拟地址,并采用虚拟地址访问内存,从目标内存空间读取目标数据。
由于在核间通信使用共享内存发送和接收数据时,会使用动态申请内存返回的地址,但是不同的系统使用地址系统可能不同,例如,实时操作系统为第一操作系统,非实时操作系统为第二操作系统,实时操作系统中访问共享内存可以直接使用物理地址,非实时操作系统中不能直接使用物理地址访问共享内存,则需要使用映射后的虚拟地址,在第二操作系统接收到目标内存空间的地址信息后,通过地址信息offset进行转换,将其映射为虚拟地址,并根据虚拟地址进行操作。可选地,非实时操作系统下的共享内存虚拟基地址vBase(共享内存真实物理地址假设为0x96000000);实时操作系统下共享内存物理基地址pBase(即,0x96000000)。
非实时操作系统中动态申请的内存返回的地址也是虚拟地址vData,非实时操作系统中,Offset=vData-vBase;数据发送从非实时操作系统中发送到实时操作系统中,实时操作系统使用地址pData访问动态申请的共享内存pData=pBase+Offset。实时操作系统中动态申请的内存返回的地址是物理地址pData,实时操作系统中Offset=pData-pBase;数据发送从实时操作系统中发送到非实时操作系统中,非实时操作系统使用地址vData访问动态申请的共享内存vData=vBase+Offset。
在一个示例性实施例中,内存中包括元数据存储区和数据存储区,元数据存储区和数据存储区与前述实施例中类似,在此不做赘述。可选地,获取处理器中存储的元数据存储区,并识别元数据存储区中的状态映射表,从状态映射表中的索引位置开始遍历每一条内存页记录,依次查询状态映射表的每条内存页记录,确定是否存在连续的记录空闲内存页的大于等于预设数量的内存页记录,在存在符合上述条件的内存页记录的情况下,通过内存页记录与内存页的对应关系,确定处理器中存在目标内存空间,通过内存页记录与内存页的对应关系,确定处理器中存在目标内存空间。
在本实施例中还提供了一种共享内存的方法,该方法包括:在操作系统发出内存申请指令前,为防止多个操作系统同时申请处理器的内存空间时导致申请冲突,需要申请加锁操作,并判断是否加锁成功;在判断结果 表示动态申请内存加锁成功的情况下,根据发出的内存申请指令中内存大小计算需要分配的连续内存页的页数,并记作nmemb;若判断结果表示申请加锁失败的情况下,在等待一段时间(可以为100微秒)后重新发出申请,直至申请成功,若申请加锁失败的次数大于预设次数(预设次数可以为三次)的情况下,则退出内存申请。
在一个示例性实施例中,在申请加锁成功后,对处理器的元数据存储区进行初始化操作,并将状态映射表的最后位置记作offset,并根据申请内存指令中的所需内存的空间大小计算出需要的连续内存页的数量,并将内存页数量记作nmemb,并设置用记录内存页数量的计数器,记作cmemb,然后获取处理器中的元数据存储区的状态映射表,并从状态映射表的offset位置开始扫描整个状态映射表,通过状态映射表中存储的内存页记录与数据存储区中内存页的对应关系,寻找连续的空的内存页,如果扫描的当前的内存页处于被占用状态,则将offset=offset-cmemb,然后把计数器中累加的连续的空的内存页的数据cmemb清零,继续从新的offset位置重新开始寻找连续的空的内存页;若扫描的内存页为空,也即处于空闲状态时,将计数器的数值cmemb加1,并offset=offset-1,继续判断下一个内存页,直到cmemb等于nmemb,也即计数器数据与所需内存的空间大小相等时,表示扫描到满足要求的连续内存页。
在一个示例性实施例中,将符合要求的内存页在对应的状态映射表中标记为被占用状态,将最后一个找到的内存页的首地址作为动态申请的整个连续的内存页的首地址,释放动态申请内存的锁,本次动态申请内存成功。
若在扫描整个状态映射表的过程中,offset的值小于0,则表明没有符合要求的内存页供操作系统使用,释放动态申请内存的锁,本次动态申请内存失败。
此外,动态申请了空间之后发现空间不够用时还可以动态调整大小,可以再次发出更新后的内存申请指令,并对内存执行加锁操作,在加锁成功的情况下,若更新后的内存申请指令需要申请的内存空间增大,判断已申请的目标连续内存之后是否存在所需的内存空间,在存在的情况下,申请成功,若更新后的内存申请指令需要申请的内存空间减小,则释放部分内存空间。
本实施例通过划分多个存储区,利用索引位置根据实际需要的空间大小动态申请,使用完成后释放掉,并且动态申请了空间之后发现空间不够用时还可以动态调整大小,可以达到提高共享内存灵活性以及使用效率的效果。
在一个示例性实施例中,上述方法还包括以下至少之一:
S221,将第一操作系统抢占的第二操作系统的处理资源合并到第一操作系统的可用资源池中;
S222,将第二操作系统抢占的第一操作系统的处理资源或者第一操作系统主动释放给第二操作系统的处理资源合并到第二操作系统的可用资源池中。
在本实施例中,处理资源的调度可以是通过将对应的处理资源合并到对应的操作系统的可用资源池实现的。对应地,对于第一操作系统抢占第二操作系统的处理资源的场景,在资源抢占成功的情况下,可以将第一操作系统抢占的第二操作系统的处理资源合并到第一操作系统的可用资源池中。对于第二操作系统抢占第一操作系统的处理资源、以及第一操作系统主动释放处理资源给第二操作系统的场景,在资源抢占成功或者资源释放成功的情况下,可以将第二操作系统抢占的第一操作系统的处理资源或者第一操作系统主动释放的处理资源合并到第一操作系统的可用资源池中。
例如,资源自适应调度模块可以配合第一操作系统的处理器框架和第二操作系统的处理器框架对处理器硬核资源池进行配置实现,例如,Linux系统的SMP(Symmetrical Multi-Processing,对称多处理器)框架,这里,在一个计算机上汇集了一组处理器(多CPU),各CPU之间共享内存子系统以及总线结构,SMP调度就是将进程安排/迁移到合适的CPU中去,保持各CPU负载均衡的过程。
以Linux系统为例,对于一个操作系统,其CPU调度的方式如下:Linux系统中的任务(即,业务)一般由任务队列进行维护,由进程调度器决定队列中的哪些进程(与任务对应)能够被CPU执行,同时,Linux系 统中的分派程序模块把CPU的控制权交给由进程调度器选出来的进程。而被选中的CPU则来自Linux系统中的CPU资源池(即,前述可用资源池),相当于Linux系统能调度资源池中的这些CPU参与进程的实际运行。
进程调度器可以暂停一个正在运行的进程,并将这个进程转到running queue(即,运行队列)中,转而开始执行另一个进程,它决定了在一个时钟中断、I/O(Input/Output,输入/输出)中断、系统调用其他种类信号之后,哪一个正处于就绪队列中且在主存中的进程能被CPU执行(将CPU控制权交给这个进程)。
通过本实施例,通过将调度的处理资源合并到对应操作系统的可用资源池,可以方便进行处理资源的调度,提高处理资源调度的效率。
在一个示例性实施例中,上述方法还包括:
S232,在处理器所在的芯片上电之后,通过引导加载程序在第一初始处理资源上引导运行第一操作系统,以及通过引导加载程序在第二初始处理资源上引导运行第二操作系统,其中,第一初始处理资源是处理器的处理资源中与第一操作系统对应的初始处理资源,第二初始处理资源是处理器的处理资源中与第二操作系统对应的初始处理资源。
整个系统按照工作时段可以划分为两个阶段,即,初始启动阶段和实时运行阶段,前述处理资源的动态调度等过程是在实时运行阶段执行的。对于初始启动阶段,初始启动阶段起于系统上电,即,处理器所在的芯片上电,系统上电后会唤醒一个核心去执行操作系统的引导动作,其余核心暂时处于休眠状态。上电后系统将首先执行一个预置的核心调度策略(启动引导策略),即,由处理器的一个核心执行核心调度策略,核心调度策略存储在SOC片上的RAM或Norflash(非易失闪存)中,该调度策略可以根据不同的设计需求进行灵活配置,其主要功能包括:指定不同操作系统需要运行的初始处理资源(例如,指定第一操作系统与第二操作系统需要运行的初始核心),确定异构操作系统的引导过程。
处理器的处理资源中,与第一操作系统对应的初始处理资源为第一初始处理资源,与第二操作系统对应的初始处理资源为第二初始处理资源。在系统上电之后,可以通过引导加载程序在第一初始处理资源上引导运行第一操作系统,以及通过引导加载程序在第二初始处理资源上引导运行第二操作系统。这里,引导加载程序(boot loader),位于电脑或其他计算机应用上,是指引导操作系统加载的程序。
这里,芯片可以是BMC(Baseboard Management Controller,基板管理控制器,服务器平台中的管理控制芯片)芯片,是指基于ARM多核架构的SOC芯片,集成多种外围硬件IP(Intelligent Peripheral,智能外设),BMC芯片在主板(服务器母板)上放置,芯片上电是指SOC芯片层面的上电。
在系统上电之后,可以首先唤醒处理器的指定处理器核心,由该指定处理器核心通过引导加载程序引导各个操作系统在对应的初始处理资源上启动。引导加载程序是用于引导操作系统加载的程序,例如,Bootrom(CPU片上的ROM)里的固有程序,固有程序指的是引导操作系统启动的代码,属于BootLoader程序。
通过本实施例,在初始启动阶段,通过引导加载程序在各个操作系统对应的初始处理资源上引导各个操作系统启动,可以提高操作系统启动的成功率,同时为实时运行阶段做准备。
在一个示例性实施例中,第一初始处理资源为处理器的处理器核心中的一个指定处理器核心,第二初始处理资源为处理器的处理器核心中除了指定处理器核心以外的其他处理器核心。
在本实施例中,初始处理资源可以包括初始处理器核心,第一初始处理资源可以为处理器的处理器核心中的至少一个处理器核心,第二初始处理资源可以是除了第一初始处理资源以外的其他处理器核心的至少部分处理器核心。可选地,为了保证系统启动的效率,第一初始处理资源可以是处理器的处理器核心中的一个指定的处理器核心,而第二初始处理资源为处理器的处理器核心中除了指定处理器核心以外的其他处理器核心。
例如,对于八核处理器(CPU0~CPU7),指定处理器核心可以是CPU0(或者其他某一处理器核心),即,第一操作系统的初始处理资源为CPU0,第二操作系统的初始处理资源为CPU1~CPU7。
通过本实施例,通过指定某一操作系统的初始处理资源为一个指定的处理器核心,而将处理器的其他处理器核心作为另一操作系统的初始处理资源,可以提高启动引导的便捷性。
在一个示例性实施例中,通过引导加载程序在第一初始处理资源上引导运行第一操作系统,包括:
S241,通过二级程序加载器在第一初始处理资源上引导运行第一操作系统。
在本实施例中,可以通过二级程序加载器(Second Program Loader,简称为SPL)进行操作系统的启动引导,SPL属于uboot第一阶段执行的代码,可以搬移uboot第二阶段代码到内存中运行,主要负责装载操作系统到RAM中的程序代码。这里,uboot是一种用于嵌入式系统的引导加载程序,主要用于嵌入式系统的引导加载程序,可以支持多种不同的计算机系统结构,例如,PPC、ARM、AVR32、MIPS、x86、68k、Nios与MicroBlaze等。
通过本实施例,通过二级程序加载器在初始处理资源上引导运行对应的操作系统,可以兼容于已有的系统启动流程,提高了系统启动的效率。
在一个示例性实施例中,上述方法还包括:
S251,通过固化在设备主板上的启动芯片内的预设程序对二级程序加载器的代码进行安全启动检查,其中,二级程序加载器是在安全启动检查的检查结果正常之后执行的。
在使用二级程序加载器引导操作系统运行之前,为了提高操作系统启动的成功率,可以固化在设备主板上的启动芯片内的预设程序对二级程序加载器的代码进行安全启动检查,以确定二级程序加载器是否正常,如果二级程序加载器安全启动检查的结果为正常,则可以通过二级程序加载器引导操作系统运行,如果二级程序加载器安全启动检查的结果为异常,则进行异常提示,并中止操作系统的引导过程。
例如,系统上电后,配置部分核心引导Bootrom里的固有程序,通过Bootrom程序(一组固化在设备主板上ROM芯片中的程序)对SPL部分的代码进行安全启动检查,检查结果正常则执行SPL代码。
通过本实施例,通过对二级程序加载器进行安全启动检查,可以提高操作系统启动的安全性。
在一个示例性实施例中,通过引导加载程序在第二初始处理资源上引导运行第二操作系统,包括:
S261,通过二级程序加载器唤醒第二初始处理资源,并引导执行通用引导加载程序,以引导运行第二操作系统。
在引导运行第二操作系统时,可以通过二级程序加载器首先唤醒第二初始处理资源,然后引导执行通用加载程序,以引导运行第二操作系统。例如,SPL一方面在部分核心(例如,核心1,CPU0)上引导运行第一操作系统,另一方面唤醒其他部分核心(例如,核心2~核心M+N,CPU1~CPU M+N-1)引导执行uboot代码(一个主要用于嵌入式系统的引导加载程序)进而引导运行第二操作系统。通过该阶段,服务器管理控制单元BMC系统将能够实现第一操作系统与第二操作系统各自基于一个或多个处理器核心的正常引导,为实时运行阶段做准备。
通过本实施例,通过首先唤醒初始处理资源,并引导执行通用引导加载程序,以引导运行对应的操作系统,可以提高系统引导运行的效率。
下面结合可选示例对本实施例中的嵌入式系统的运行方法进行解释说明。在本可选示例中,第一操作系统为RTOS系统,第二操作系统为Linux系统(也可以是其他非实时操作系统),处理资源为处理器核心。
为实现嵌入式系统中各种类型业务正常运行,同时提升处理器核心的利用率,并将服务器硬件成本控制于合理范围,本可选示例提供了一种嵌入式异构多系统间处理器资源动态均衡调度的方法,基于多核处理器硬核,根据核心自适应调度(即,资源自适应调度)方法将不同业务类型调度到不同核心组执行;同时,融入业务管理、负载均衡、资源动态分配以及核间通信接口等系统架构设计,实现了实时与非实时嵌入式异构操作系统在同一处理器多个核心上并行运行效果,可以提高处理器核心的整体利用率,大大减小了为应对实时性业务而引入的硬件加速资源方面的投入,同时,处理器多核心采用高速的内部总线,通信性能大幅提高,可以显著缩减设计成本、提高计算性能的目标。
以服务器平台(用到多核SOC的嵌入式产品均适用,比如手机、平板、机顶盒等同样使用)中的BMC管理单元为例,本可选示例中的嵌入式系统的运行方法可以分为两个阶段,即,初始启动阶段和实时运行阶段,参 见图7所示的嵌入式异构多系统间处理器资源动态均衡调度的实现架构,其中,初始启动阶段中CPU均衡调度过程可以如图8所示,上述过程可以包括以下步骤:
步骤S802,配置部分核心引导Bootrom里的固有程序;
步骤S804,通过Bootrom程序(即,前述固有程序)对SPL(保存在Norflash中)进行安全启动检查(安全启动检查主要是对将要引导的uboot、Linux、RTOS镜像进行哈希校验,得到的结果与存储的结果进行比对,比对一致则正常引导,不一致则启动失败;SPL通过对部分CPU寄存器进行配置,选择唤醒哪些核心,从哪个地址加载系统镜像);
步骤S806,判断安全检查是否通过,如果安全检查通过,执行步骤S808,如果安全检查不通过,执行步骤S810;
步骤S808,执行SPL代码,SPL一方面在部分核心上引导运行RTOS系统,另一方面唤醒其他部分核心引导执行uboot代码,进而引导运行Linux系统;
步骤S810,结束。
当异构操作系统引导起来后,系统进入实时运行阶段。参见图7,实时运行阶段由负载均衡策略、业务管理、资源动态分配、核心自适应调度(即,资源自适应调度)、核心抢占与释放、以及核间通信等功能模块协作完成。结合图7和图9,在实时运行阶段,本可选示例中的嵌入式系统的运行方法的流程可以包括以下步骤:
步骤S902,业务管理模块根据负载均衡策略模块的输出,执行待分配业务的实际分类,产生包含实时业务的列表与非实时业务的列表。
负载均衡策略模块为业务管理模块提供策略指导,包括系统中运行的各种业务(或进程)分类方法、实时性等级评估原则等。在RTOS系统和Linux系统引导启动之后,业务管理模块根据负载均衡策略模块的输出,执行待分配业务的实际分类,产生包含实时业务的列表和包含非实时业务的列表。负载均衡策略模块输出的两个列表用于表示业务与操作系统之间的对应关系。
对于BMC应用而言,为实现对服务器平台强大而全面的管理,服务器平台上需要运行大量的业务进程,此时,业务管理模块实现对这些业务的合理分类。一种可行的分类方式为:将服务器健康状态监控、IPMI(Intelligent Platform Management Interface,智能平台管理接口)交互、部件监控、串口重定向、资产信息管理、Web访问等业务划分为非实时业务;而将风扇控制、PECI(Platform Environment Control Interface,平台环境式控制接口)通信等业务划分为实时业务。
步骤S904,资源动态分配模块根据业务管理模块的输出结果,对处理器资源(包括处理器硬核与控制器逻辑单元等)进行动态调整,形成不同业务与实际硬件资源的资源映射表。
资源动态分配模块所形成的映射表为业务与处理器资源的资源映射表,即包括了已分配给各个操作系统的处理器资源,也包括未分配给任一操作系统的处理器资源,在进行业务与实际硬件资源之间的映射时,优先为实时业务分配与RTOS系统的处理器核心,如果RTOS系统的处理器核心均已分配了一个或多个业务,再考虑为实时业务分配未分配的处理器核心;为非实时业务分配与Linux系统的处理器核心,如果Linux系统的处理器核心均已分配了一个或多个业务,再考虑为实时业务分配未分配的处理器核心。因此,存在为实时业务或者非实时业务分配未分配的处理器核心的情况。
实际应用中,将BMC的处理器核心及外设控制器等硬件资源与BMC实际业务进行动态映射,如服务器开机后BMC中的核心1运行RTOS系统,控制PWM(Pulse Width Modulation,脉冲宽度调制)及PECI外设控制器实现风扇调速和故障诊断业务,而将核心2~N运行Linux系统控制I2C(Inter-Integrated Circuit,集成电路总线)等控制器实现部件监控业务。在系统运行过程中,根据系统负载等情况动态生成BMC资源的动态分配表,为下一步核心自适应调度过程做准备。
这里,输出的资源映射表可以是:实时业务X个核心及xxx控制器(某些类型的控制器),非实时业务Y 个核心及xxxx控制器(某些类型的控制器)。有些业务不止依赖于计算资源(对应处理器核心),还依托与特定的硬件接口(对应SOC上的控制器)。例如,需要用到网口的业务就需要把该业务与对应的网络控制器划分到同一个操作系统中(RTOS系统或Linux系统)。
步骤S906,核心自适应调度模块根据硬件资源动态分配的结果,完成对处理器硬核资源的实际调度动作。
核心自适应调度模块根据业务管理模块的输出结果和资源动态分配模块的输出结果进行处理器硬核资源的实际调度,比如,调度一部分处理器硬核执行实时性业务,如图6中的核心组1的M个核心;调度其余的处理器硬核运行非实时性业务,如图6中的核心组2的N个核心。在整个调度过程由Linux系统主导,具体可配合Linux的SMP框架对处理器硬核资源池进行配置实现。这里,处理器的可用总核心数为M+N,其中,M≥1,N≥1。
步骤S908,在系统实时运行过程中,核心抢占与释放模块在异构操作系统间执行动态地对处理器核心进行抢占与释放。
抢占与释放过程取决于异构操作系统实时负载情况,以达到最大化处理器资源利用率的目标。例如,当远程访问BMC的用户数量从1增加到20时,使得BMC的Web访问业务量急剧上升,这将导致Linux系统需要更多处理器硬核支撑。这种情况下,Linux系统将通过IPI向RTOS系统发出核心抢占请求,如果RTOS系统此时处于空闲状态(即,无任务调度),它将释放核心资源给Linux系统,此时,Linux系统核心抢占成功,即,Linux获得了更多的处理器资源,以应对新增的业务需求。通过核心抢占与释放机制,使得服务器远程管理方面的用户体验得到显著提升。
核心抢占与释放过程是一个动态循环往复的过程,每次核心抢占与释放都伴随着处理器硬核资源的调整,如图6所示,经过一次抢占与释放,核心组X的核心数变成了P,核心组Y的核心数变成了M+N-P。此外,核心抢占与释放过程需要协同负载均衡策略、业务管理、核心自适应调整等模块来共同决定最终的核心调整结果。
上述循环往复是指:系统正常运行的过程中,在RTOS系统与Linux系统中不断地会出现因一方资源不足而进行资源抢占与释放的行为,该循环运转的过程会涉及到“业务管理(业务管理是动态划分的过程)-硬件资源动态分配-核心自适应调度”等模块的协同运作。上述多个模块均是在非实时系统下(Linux系统),考虑是大部分主要业务都在Linux系统下,可以更方便的获取和感知到更多的信息和状态。
上述多个模块共同决定核心调整结果是指:某系统需要抢占更多核心资源时,最终的抢占成功与否需要负载均衡策略、业务管理、核心自适应调整等模块共同决定。例如,一种可能的情况,当Linux系统需要更多资源时,而RTOS系统虽然此时处于休眠空闲状态,但由于RTOS系统很快要唤醒并运行一个重要的业务线程,且该线程运行时也需要很多的资源,这时RTOS系统就不能释放核心资源给Linux系统。上述资源调度过程涉及判断业务重要性的标准、及最终资源不分配给Linux系统的操作等均会涉及到负载均衡策略、业务管理、核心自适应调整等模块的参与。这些模块各自的策略又包含开放性的特点,这就决定了他们共同决定出的最终核心调整结果也是由这些策略共同作用的结果。
这里,RTOS系统休眠后完全不占用CPU核心资源,当它被唤醒时(比如,外设或唤醒定时器产生中断触发唤醒动作),会通过核间中断重新获取指定核心资源(例如,核心0)的控制权。上述从休眠状态到重新获取核心控制权期间,RTOS系统都不需要核心的参与。
下面以八核处理器(核心1~核心8)为例对嵌入式异构多系统间处理器资源动态均衡调度的方式进行解释说明,假定实时操作系统与非实时操作系统分别为RTOS系统与Linux系统,处理器资源动态均衡调度流程可以包括以下步骤:
步骤1,系统上电,运行预置的启动引导策略,基于核心1(CPU0)引导RTOS系统,核心8(CPU7)引导Linux系统。
步骤2,Linux系统的业务管理模块基于负载均衡策略模块实现对系统业务实时性等级划分,获得实时性业务与非实时性业务列表,假设总共有20个业务,其中实时性业务为业务1和业务2,非实时性业务为业务3至业务20。
步骤3,根据业务管理模块输出的业务列表启动资源动态分配模块与核心自适应调度模块,通过Linux系统的SMP框架将8个处理器核心分成处理器核心组1(假设包含核心1和2)和核心组2(假设包含核心3至8),此时,系统将核心组1的资源分给RTOS操作系统并执行业务1和业务2,同时将核心组2的资源分给Linux系统并执行业务3至业务20。
步骤4,在系统运行过程中,RTOS操作系统与Linux操作系统均会监控各自的负载情况,当某一方业务负载过重时,其将通过核间通信接口发起核心抢占动作;另一方收到核心抢占请求时,会根据自身负载情况判断是否释放硬核资源给对方。
例如,Linux系统在某一时刻监控到自身负载急剧增加,在自身计算资源耗尽前通过核间通信接口向RTOS系统发起核心抢占中断请求(对应表1中断号为9的SGI中断)。RTOS系统收到核心抢占中断请求后检查自身占用的核心忙闲状态,如果发现此时存在空闲核心(例如,核心2空闲)则释放核心2,并通过核间通信接口发送核心释放中断响应信号(对应表1中断号为10的SGI中断)给Linux系统,Linux系统收到中断响应信号后通过SMP框架将核心2合并至可用资源池中,此时,处理器硬核实现了一次新的调整,即RTOS系统占用核心1,其余7个核心由Linux系统占用。
步骤5,更新系统负载情况,返回步骤2。
与相关技术中的多核单系统以及多核固定式多系统(各核心固定运行某特定操作系统)不同,本可选示例中所提供的方法根据实际业务需求,将不同的硬件处理器核心动态地分配给实时操作系统和非实时操作系统,从软硬件系统架构层面实现基于处理器硬核的嵌入式异构多系统间处理器资源动态调度设计。由于处理器硬核具有动态可分配性,使得系统中并存的异构操作系统能够根据自身业务负载情况获得合理的处理器计算资源,一方面增强了处理器对实时业务的处理能力,同时全面提升了处理器核心的利用率,提高了计算性能,达到节省硬件成本的目的。
在一个可选的应用场景中,下面结合两个操作系统交替对同一设备(即,目标设备)的运行状态进行控制的应用场景对本实施例中的嵌入式系统的运行方法进行解释说明,其中,第一操作系统的处理系统包括处理器的第一处理器核心,第二操作系统的处理资源包括处理器的第二处理器核心。在本实施方式中,提供了一种操作系统的启动控制过程,该过程包括如下步骤:
步骤A,通过处理器的第一处理器核心上运行的第一操作系统经由第二总线对目标设备的硬件控制器进行控制,以对目标设备的运行状态进行控制。
对于如服务器、个人电脑、工控机等设备,可以配备一些特定设备执行与设备运行相关的操作。相关技术中,通常在系统上电后,这些特定设备就开始工作。而由于系统上电后,运行在处理器上的操作系统会经过一段时间才能正常接管特定设备,进行特定设备的运行状态控制,而在操作系统启动的过程中,特定设备是不可控的。
例如,在系统上电后风扇就开始工作,由于系统上电后跑在CPU上的操作系统会经过一段时间才能正常接管风扇,进行风扇转速的设置,所以在操作系统启动过程中风扇是不可控的。
例如,为了实现在操作系统启动的过程中对风扇可以控制,服务器通过采用BMC结合CPLD的控制方式,个人电脑采用EC芯片的控制方式(EC芯片根据温度调整风扇转速的功能),工控机采用定制芯片的控制方式,在服务器、个人电脑、工控机操作系统启动过程中,CPLD、EC芯片、定制芯片就会介入控制风扇的转速,等待操作系统完全启动后,风扇的控制权就会交给操作系统中的应用程序进行控制。
为了至少部分解决上述技术问题,可以采用多核多系统(例如,多核双系统)的启动控制方式,在处理器的不同处理器核心上运行嵌入式系统的不同操作系统,不同的操作系统的响应速度不同,对于第二操作系统未 启动、重启或者其他无法对特定设备的运行状态进行控制的情况,可以由响应速度高于第二操作系统的第一操作系统对特定设备的运行状态进行控制,可以降低特定设备的运行状态不可控的情况,同时,由于不需要增加额外的成本,此外还具有很好的可扩展性。
在本实施方式中,在第二操作系统未启动、重启或者其他无法对目标设备的运行状态进行控制的情况下,可以通过第一操作系统经由第二总线对目标设备的硬件控制器进行控制,以对目标设备的运行状态进行控制。这里的目标设备可以是风扇,或者其他需要在系统启动是运行的设备,对于风扇,其对应的硬件控制器为风扇控制器,例如,PWM(Pulse Width Modulation,脉冲宽度调制)控制器、FanTach(风扇转速)控制器。这里,使用第一操作系统(例如,RTOS系统)代替传统的CPLD、EC芯片、定制芯片,一方面节省硬件成本,另一方面由于设备控制是由软件实现的,可扩展性较高。
例如,基于BMC双核实现双系统,RTOS系统和Linux系统,基于多核双系统实现风扇,利用RTOS系统实时性高的特性,在Linux系统启动的过程中,可以由RTOS系统代替CPLD、EC芯片、定制芯片控制风扇,即,接管风扇控制权,以足够快的速度对风扇的运行状态进行控制。
步骤B,引导在处理器的第二处理器核心上启动第二操作系统。
在系统上电时或者第二操作系统重启时,可以引导在处理器的第二处理器核心上启动第二操作系统,以使得第二操作系统在第二处理器核心上运行。这里,在第二处理器核心上启动第二操作系统是指将第二处理器核心调度给第二操作系统,操作系统的系统文件或者镜像文件可以存储在处理器所在芯片上或者芯片以外的存储器内,例如,外部RAM内。
步骤C,在第二操作系统启动之后,通过第二操作系统经由第二总线接管硬件控制器,以接管目标设备的控制权。
在第二操作系统启动完成之后,可以一直由第一操作系统对目标设备的运行状态进行控制,考虑到在多核处理器上运行多个操作系统需要在多个操作系统之间进行数据交互,以及方便由一个操作系统进行设备的总体控制,也可以由第二操作系统接管目标设备的控制权。例如,可以通过第二操作系统经由第二总线接管硬件控制器。第二操作系统接管目标设备的控制权的方式可以是:在第二操作系统启动之后,由第二操作系统向第一操作系统发送设备接管请求,例如,通过第一总线发送中断请求,以请求接管目标设备的硬件控制器。第一操作系统可以接收第二操作系统发送的设备接管请求,将目标设备的控制权转交给第二操作系统,还可以执行与目标设备的控制权交接相关的操作,例如,停止运行用于对目标设备的运行状态进行控制的业务(进程)。
例如,等到Linux系统完全启动后,RTOS系统将风扇的控制权转交给Linux系统,由Linux系统对风扇进行控制。上述过程可以是在系统上电之后执行的,即,采用多核双系统的启动方式,先启动RTOS系统,利于更早介入风扇控制,而等到Linux系统完全启动之后,RTOS系统将风扇的控制权转交给Linux系统进行控制。
在一个示例性实施例中,通过处理器的第一处理器核心上运行的第一操作系统经由第二总线对目标设备的硬件控制器进行控制之前,还包括:在处理器所在的芯片上电之后,通过处理器唤醒第一处理器核心;通过第一处理器核心运行第一操作系统的引导加载程序,以引导第一操作系统在第一处理器核心上启动。
整个系统按照工作时段可以划分为两个阶段,初始启动阶段和实时运行阶段,本实施例中的启动控制方法可以是在初始启动阶段或者实时运行阶段执行的。对于初始启动阶段,初始启动阶段起于系统上电,即,处理器所在的芯片上电,系统上电后会唤醒一个核心去执行操作系统的引导动作,其余核心暂时处于休眠状态,被唤醒的核心可以是第一处理器核心。
可选地,上电后系统将首先执行一个预置的核心调度策略(启动引导策略),即,由处理器的一个处理器核心执行核心调度策略,核心调度策略可以存储在SOC片上的RAM或Norflash(非易失闪存)中,该调度策略可以根据不同的设计需求进行灵活配置,其主要功能包括:指定不同操作系统需要运行的初始处理资源(处理器核心),确定异构操作系统的引导过程,芯片上电可以是指SOC芯片层面的上电。
在第一处理器核心唤醒后,可以通过引导加载程序在第一处理器核心上引导运行第一操作系统:可以,由第一处理器核心通过引导加载程序引导第一操作系统在第一处理器核心上启动。引导加载(BootLoader)程序可以位于电脑或其他计算机应用上,其是指用于引导操作系统加载的程序,例如,BootRom里的固有程序,固有程序指的是引导操作系统启动的代码,属于BootLoader程序,BootRom是CPU片上的嵌入处理器芯片内的一小块掩模ROM(Read-Only Memory,只读存储器)或者写保护闪存。
在初始启动阶段,通过引导加载程序引导操作系统对应的处理器核心上启动,可以提高操作系统启动的成功率,同时为实时运行阶段做准备。
在一个示例性实施例中,通过处理器的第一处理器核心上运行的第一操作系统经由第二总线对目标设备的硬件控制器进行控制,包括:在第一处理器核心上执行第一操作系统的第一控制任务,其中,第一控制任务用于对硬件控制器进行控制;通过第一处理器核心读取与目标设备对应的指定传感器的传感器数据;通过第一控制任务根据指定传感器的传感器数据经由第二总线向硬件控制器发送设备控制指令,以由硬件控制器按照设备控制指令对目标设备的运行状态进行控制。
操作系统对目标设备的硬件控制器进行控制可以是由在该操作系统所运行的处理器核心上的控制任务(业务)对硬件控制器进行控制执行的,这里的控制任务可以指对应的控制任务。对于目标设备的硬件控制器,可以在第一处理器核心上执行第一操作系统的第一控制任务(第一控制进程),由第一控制任务对硬件控制器进行控制。
对硬件控制器进行控制可以是基于传感器的传感器数据进行的,对于不同的目标设备,影响其运行的参数可以是不同的,对应地,所需获取的传感器数据也可以存在区别。对于目标设备,其可以是在芯片上电以后即运行的设备,与其对应的传感器为指定传感器。指定传感器的类型可以有多种,可以包括但不限于以下至少之一:温度传感器,湿度传感器,噪音传感器等。由于第一控制任务运行在第一处理器核心上,因此,可以通过第一处理器核心读取指定传感器的传感器数据。指定传感器的传感器数据可以存储在指定传感器内的存储空间中,与可以由指定传感器传输到指定的存储空间内,本实施例中对于指定传感器的传感器数据的读取位置不做限定。
读取的指定传感器的传感器数据可以是在一个时间周期内的传感器数据,也可以是自目标设备启动之后的全部传感器数据,还可以是满足其他时间限制条件的传感器数据。在获取到指定传感器的传感器数据之后,第一控制任务可以根据指定传感器的传感器数据对目标设备的运行状态进行控制。对目标设备的运行状态进行控制可以是通过以下方式实现的:通过第一控制任务向目标设备的硬件控制器发送设备控制指令,以由硬件控制器按照设备控制指令对目标设备的运行状态进行控制。
可选地,第一控制任务可以基于指定传感器的传感器数据确定出目标设备预期的运行状态;在目标设备当前的运行状态与预期的运行状态不同的情况下,可以生成上述设备控制指令,设备控制指令可以控制将目标设备的运行状态调整为预期的运行状态。上述设备控制指令可以是经由第二总线发送给目标设备的硬件控制器的。第二总线与前述实施例中类似,在此不做赘述。
通过读取指定传感器的传感器数据,并根据传感器数据对目标设备进行控制,控制其运行状态,提高了资源的利用率。
在一个示例性实施例中,通过第一控制任务根据指定传感器的传感器数据经由第二总线向硬件控制器发送设备控制指令,包括:通过第一控制任务根据指定传感器的传感器数据确定目标设备的设备运行参数的目标参数值,其中,设备运行参数为控制目标设备的运行状态的参数;通过第一控制任务将携带有目标参数值的设备控制指令经由第二总线发送给硬件控制器。
第一控制任务可以根据指定传感器的传感器数据,确定出目标设备预期的运行状态。预期的运行状态可以是通过设备运行参数的参数值进行表示的,设备运行参数可以是控制目标设备的运行状态的参数,对于不同类型的设备,其对应的设备运行参数可以是不同的。例如,对于风扇,其对应的设备运行参数可以是转速,对于 其他类型的设备,设备运行参数可以是其他的运行参数。预期的运行状态可以对应于目标设备的设备运行参数的目标参数值。
在确定出目标设备的设备运行参数的目标参数值之后,可以将目标参数值携带在上述的设备控制指令中,即,通过第一控制任务将携带有目标参数值的设备控制指令发送给硬件控制器,向硬件控制器发送设备控制指令的方式可以与前述实施例中类似,在此不做赘述。
根据传感器数据确定目标设备的设备运行参数的参数值,并将确定的参数值携带在设备控制指令中,可以提高设备控制的精准度。
在一个示例性实施例中,通过第一控制任务根据指定传感器的传感器数据确定目标设备的设备运行参数的目标参数值,包括:在目标设备为风扇的情况下,通过第一控制任务根据指定传感器的传感器数据确定风扇的风扇运行参数的目标参数值。
目标设备可以是风扇,其可以是用于对所在的服务器或者其他设备进行散热的风扇,即,散热风扇。在此情况下,设备运行参数可以是风扇运行参数,风扇运行参数可以包括一种或多种,可以包括但不限于以下至少之一:转速,转动周期,周期切换时间,还可以是其他的运行参数。本实施例中对此不做限定。
对应地,通过第一控制任务根据指定传感器的传感器数据确定目标设备的设备运行参数的目标参数值可以是:通过第一控制任务根据指定传感器的传感器数据确定风扇的风扇运行参数的目标参数值。在得到目标参数值之后,第一控制任务将携带有目标参数值的设备控制指令经由第二总线发送给风扇的硬件控制器,从而对风扇的运行状态进行控制。
通过对风扇的运行状态进行控制,可以在如系统上电、系统重启或者其他场景下,快速对风扇的运行状态进行控制,提高风扇控制的及时性。
在一个示例性实施例中,在目标设备为风扇的情况下,通过第一控制任务根据指定传感器的传感器数据确定风扇的风扇运行参数的目标参数值,包括:在目标设备为风扇、且指定传感器为温度传感器的情况下,通过第一控制任务根据温度传感器的传感器数据确定风扇的转速的目标转速值,其中,风扇的转速与温度传感器所检测到的温度正相关。
对于目标设备为风扇的场景,指定传感器可以是温度传感器,该温度传感器的数量可以为一个或多个,温度传感器的设置位置可以根据需要进行配置,不同的温度传感器可以设置在不同的位置上。可选地,温度传感器的传感器数据用于表示温度传感器所检测到的温度,对此,第一控制任务可以根据温度传感器的传感器数据确定风扇的转速的目标转速值,这里,风扇的转速与温度传感器所检测到的温度正相关。
在温度传感器的数量为多个的情况下,可以根据每个温度传感器的传感器数据,确定多个温度传感器所检测到的最高温度,风扇的转速可以是根据多个温度传感器所检测到的最高温度确定的,相对于根据多个温度传感器所检测到的平均温度确定风扇的转速,可以保证设备运行的安全性。对于风扇的数量为多个的场景,也可以基于与每个风扇匹配的温度传感器所检测到的最高温度或者平均温度,确定每个风扇的转速。
例如,可以利用第一操作系统(例如,RTOS系统)代替CPLD、EC芯片、定制芯片等处理单元来控制风扇转速(可以是实时进行BMC风扇控制)。在系统刚上电时,可以唤醒第一处理器核心(例如,CPU0,第一处理器核心可以是被硬件唤醒的),第一处理器核心运行引导加载程序(例如,BootRom中的指定程序),加载第一操作系统启动,第一处理器核心将读取各种和温度相关的传感器(Sensor)数据,进行风扇控制(例如,风扇转速控制),完全模拟上述处理单元完成风扇调控的功能。在进行风扇转速控制时,第一操作系统可以根据温度传感器计算PWM值,继而风扇的转速进行调整。通过上述方式,可以在第二操作系统启动的过程中,由第一操作系统对风扇的转速进行控制。
在一个示例性实施例中,引导在处理器的第二处理器核心上启动第二操作系统,包括:通过第一处理器核心执行二级程序加载器,以由二级程序加载器唤醒第二处理器核心;通过第二处理器核心运行第二操作系统的通用引导加载器,以引导第二操作系统在第一处理器核心上启动。
在本实施方式中,在进行操作系统启动时,可以将二级程序加载器加载到内部内存中,例如,SOC内部的静态随机存取存储器(Static RAM,SRAM),而SPL可以负责将通用引导加载程序(Universal Boot Loader,简称为U-Boot)加载到随机存取存储器中,二级程序加载器可以引导加载第二操作系统,还可以引导加载第一操作系统。
对于第二操作系统,可以通过第一处理器核心执行二级程序加载器,以由二级程序加载器唤醒第二处理器核心;通过第二处理器核心,可以运行第二操作系统的通用引导加载器(通用引导加载程序),从而引导第二操作系统在第一处理器核心上启动。这里,通过二级程序加载器引导加载第二操作系统的引导程序,第二操作系统的引导程序可以包括通用引导加载器。
需要说明的是,二级程序加载器为通用引导加载程序第一阶段执行的代码,可负责搬运通用引导加载程序第二阶段的代码到系统内存(System RAM,也叫片外内存)中运行。通用引导加载程序是一个遵循GPL(General Public License,通用公共许可协议)协议的开源软件,可以看作是一个裸机综合例程。
例如,系统上电后,处理器首先会唤醒CPU0核,以便可以让RTOS系统尽可能快地运行起来;然后利用BootRom中的程序引导RTOS系统启动;RTOS系统启动的过程中,会继续通过SPL加载U-Boot,由U-Boot引导在CPU1上启动第二操作系统直到Linux系统正常启动。
需要说明的是,Boot Rom是芯片(例如,SOC芯片)内部ROM固化程序,其是uboot的引导代码。Boot Rom读硬件的启动信息(例如,拨码开关设置),从指定启动介质(例如,SD、MMC等)中读取uboot-spl代码(即,SPL),SPL主要负责初始化外部RAM和环境,加载真正的uboot镜像到外部RAM中来执行,外部RAM可以是DDR(Double Data Rate Synchronous Dynamic RAM,双倍速率的同步动态随机存取内存),也可以是其他的RAM。
通过二级程序加载器唤醒第二处理器核心,再由第二处理器核心运行通用引导加载程序,从而引导在对应的处理器核心上第二操作系统,可以提高操作系统启动的便捷性和成功率。
作为一种可选示例,下面以RTOS系统和Linux系统为例对多核双系统的启动过程进行解释说明。
为了尽快接管风扇管理,可以尽可能使RTOS系统启动,在Linux系统启动完成之后,由在Linux系统接管风扇的控制权。多核双系统的启动过程可以包括以下步骤:
步骤1,在系统刚上电时,唤醒CPU0;
步骤2,CPU0运行BootRom中的指定程序,加载RTOS系统启动;
步骤3,在RTOS系统启动的过程中,唤醒CPU1去引导u-boot,并启动第一操作系统中的风扇控制程序(FanCtrl_RTOS_APP);
步骤4,CPU1引导u-boot可以包括SPL阶段和Uboot阶段,通过调用SPL进入到SPL阶段;
步骤5,在SPL阶段,SPL引导Uboot启动;
步骤6,在Uboot阶段,加载Linux核心(CPU1~CPUN),并启动BMC业务程序以及第二操作系统中的风扇控制程序(FanCtrl_Linux_APP)。
通过本可选示例,在双系统启动及运行的过程中,通过首先启动RTOS系统对风扇进行控制,并在Linux系统启动之后,由第二操作系统接管风扇的控制权,可以保证在系统上电时快速对风扇进行控制,提高风扇控制的效率。
在一个示例性实施例中,在通过第二操作系统经由第二总线接管硬件控制器之后,还包括:在第二操作系统待重启的情况下,通过第二操作系统经由第一总线唤醒第一操作系统,并由第一操作系统经由第二总线接管硬件控制器,以接管目标设备的控制权;控制第二操作系统进行系统重启。
在由于系统崩溃、接收到reboot(重加载)命令等原因需要重启时,第二操作系统可以首先唤醒第一操作系统,由第一操作系统接管硬件控制器,以接管目标设备的控制权。唤醒第一操作系统可以是经由第一总线执行的,第一操作系统接管硬件控制器可以是经由第二总线执行的。
在第二操作系统发生重启时,通过唤醒第一操作系统接管目标设备的控制权,可以提高设备控制的可靠性。
在一个示例性实施例中,在第二操作系统待重启的情况下,通过第二操作系统经由第一总线唤醒第一操作系统,包括:在第二操作系统待重启的情况下,通过第二操作系统经由第一总线向第一操作系统发起系统唤醒中断,其中,系统唤醒中断用于唤醒第一操作系统。
唤醒第一操作系统可以是通过核间中断实现的。如果第二操作系统待重启(例如,系统崩溃、接收到reboot命令),第二操作系统可以向第一操作系统发起系统唤醒中断,以唤醒第一操作系统。该系统唤醒中断可以是主动唤醒中断。在第一操作系统接管硬件控制器之后,可以控制第二操作系统进行系统重启,而在第二操作系统重启之后,可以重新接管硬件控制器,接管硬件控制器的过程与前述实施例中类似,在此不做赘述。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例的方法。
根据本申请实施例的另一个方面,还提供了一种用于实施上述嵌入式系统的运行方法的嵌入式系统,上述嵌入式系统可以运行于上述BMC芯片上,其中,上述嵌入式系统可以包括:
第一操作系统和第二操作系统,第一操作系统和第二操作系统运行于处理器上,第一操作系统的响应速度高于第二操作系统;
业务管理模块,用于根据资源动态分配规则将一组待分配业务分配给对应的操作系统,其中,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率;
资源动态分配模块,用于确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源,处理器的处理资源包括处理器核心;
资源自适应调度模块,用于根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统。
在本实施例中,第一操作系统和第二操作系统可以与前述实施例中类似,在此不做赘述,业务管理模块、资源动态分配模块和资源自适应调度模块可以是运行在第一操作系统或者第二操作系统下的软件模组,通过进行上述模块划分,可以方便进行不同功能模块的开发与维护,同时,对于资源动态分配规则,通过对资源动态分配规则进行灵活设置,提高资源分配的灵活性。
通过上述嵌入式系统,该嵌入式系统包括:第一操作系统和第二操作系统,第一操作系统和第二操作系统运行于处理器上,第一操作系统的响应速度高于第二操作系统;业务管理模块,用于根据资源动态分配规则将一组待分配业务分配给对应的操作系统,其中,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率;资源动态分配模块,用于确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源,处理器的处理资源包括处理器核心;资源自适应调度模块,用于根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统,解决了相关技术中存在由于多核处理器多数的处理资源处于空闲状态导致的核心资源的整体利用率较低的问题,提高了处理资源的利用率。
在一个示例性实施例中,嵌入式系统还包括:
负载均衡策略模块,用于通过读取规则配置文件,生成规则结构体,其中,规则结构体用于记录资源动态分配规则。
本实施例中的负载均衡策略模块与前述实施例中类似,在此不做赘述。这里,负载均衡策略模块可以是第 一操作系统或第二操作系统下的软件模组,通过将负载均衡策略配置为由单独的软件模组进行存储,可以方便对负载均衡策略进行灵活调整。
在一个示例性实施例中,负载均衡策略模块,还用于
通过第二操作系统的对外接口获取规则更新配置文件,其中,规则更新配置文件用于更新已配置的资源动态分配规则;使用规则更新配置文件更新规则结构体,以更新规则结构体所记录的资源动态分配规则。
在本实施例中,负载均衡策略模块中存储的资源动态分配规则可以通过第二操作系统的对外接口进行灵活配置,配置的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块用于通过执行以下步骤实现根据资源动态分配规则中与业务响应速度对应的分配规则将一组待分配业务分配给对应的操作系统:
将一组待分配业务中业务响应速度要求大于或者等于设定响应速度阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务中业务响应速度要求小于设定响应速度阈值的待分配业务分配给第二操作系统。
在本实施例中,业务管理模块根据业务响应速度进行待分配业务分配的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块用于通过执行以下步骤实现根据资源动态分配规则中与业务资源占用率对应的分配规则将一组待分配业务分配给对应的操作系统:
将一组待分配业务中业务资源占用率小于第一占用率阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务资源占用率大于或者等于第一占用率阈值的待分配业务分配给第二操作系统。
在本实施例中,业务管理模块根据业务资源占用率进行待分配业务分配的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块还用于通过执行以下至少之一的步骤实现将一组待分配业务分配给对应的操作系统:
将一组待分配业务中与第一操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,分配给第一操作系统;
将一组待分配业务中与第二操作系统的已分配业务的业务耦合度大于或者等于第二耦合度阈值的待分配业务,分配给第二操作系统。
在本实施例中,业务管理模块根据业务耦合度进行待分配业务分配的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块还用于通过执行以下步骤实现将一组待分配业务分配给对应的操作系统:
将一组待分配业务中包含敏感信息的待分配业务,分配给目标操作系统,其中,目标操作系统是第一操作系统和第二操作系统中,与使用对象交互频率低的操作系统。
在本实施例中,业务管理模块将包含敏感信息的待分配业务分配给第一操作系统的方式与前述实施例中类似,在此不做赘述。
需要说明的是,业务管理模块基于业务响应速度和业务资源占用率进行待分配业务分配是基于负载均衡策略模块中所存储的资源动态分配规则执行的,而基于业务耦合度和业务重要性(例如,是否包含敏感信息)进行待分配业务分配可以是业务管理模块基于其上预置的配置信息执行的,由于基于业务耦合度和业务重要性的处理资源分配规则通常是稳定的,而业务响应速度和业务资源占用率可以基于需求进行灵活配置,通过单独的软件模组存储根据业务响应速度和业务资源占用率中的至少之一进行资源动态分配的资源动态分配规则,可以兼顾规则配置的灵活性和简洁性。
在一个示例性实施例中,资源动态分配模块用于通过执行以下步骤实现确定与一组待分配业务对应的资源分配结果:
根据业务管理模块的分配结果,结合第一操作系统的处理资源的资源利用情况和第二操作系统的处理资源的资源利用情况,生成一组待分配业务与处理器的处理资源的资源映射表。
在本实施例中,资源动态分配模块生成一组待分配业务与处理器的处理资源的资源映射表的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源动态分配模块以处理器核心为单位将处理器的处理资源分配给第一操作系统和第二操作系统。
在一个示例性实施例中,资源自适应调度模块用于通过执行以下步骤实现根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统:
在根据资源分配结果确定处理器的处理资源中的未分配处理资源存在对应的待分配业务的情况下,将未分配处理资源分配给与未分配处理资源对应的待分配业务所分配给的操作系统。
在本实施例中,资源自适应调度模块将未分配处理资源分配给操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还包括:
资源抢占与释放模块,用于在第一操作系统和第二操作系统之间进行处理资源的抢占和释放。
在本实施例中,资源抢占与释放模块在不同操作系统之间进行处理资源的抢占和释放与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下步骤实现通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放:
通过核间通信接口将第一操作系统的第一交互请求传输至第二操作系统,其中,第一交互请求用于请求与第二操作系统进行资源交互,资源交互包括以下之一:资源抢占,资源释放;
通过核间通信接口获取第二操作系统响应第一交互请求返回的第一交互响应,其中,第一交互响应用于指示第一操作系统根据第一交互响应与第二操作系统进行资源交互。
在本实施例中,资源抢占与释放模块通过核间通信接口进行第一操作系统和第二操作系统之间的资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还包括:
第一系统控制模块,用于检测第一操作系统的处理资源的资源利用率,在根据第一操作系统的处理资源的资源利用率,确定第一操作系统待与第二操作系统进行资源交互的情况下,触发资源抢占与释放模块通过核间通信接口将第一交互请求传输至第二操作系统。
在本实施例中,第一系统控制模块基于第一操作系统的处理资源的资源利用率触发进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一系统控制模块,还用于执行以下至少之一的步骤:在第一操作系统的处理资源的资源利用率大于或者等于第一利用率阈值的情况下,确定第一操作系统待抢占第二操作系统的处理资源;在第一操作系统的处理资源处于空闲状态且不存在待第一操作系统执行的业务的情况下,确定第一操作系统待释放处理资源给第二操作系统。
在本实施例中,第一系统控制模块确定第一操作系统待进行的资源交互类型的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一系统控制模块,还用于在第一操作系统没有业务调度、且没有待分配给第一操作系统的业务的情况下,控制第一操作系统进入休眠状态。
在本实施例中,第一系统控制模块控制第一操作系统进入休眠状态的方式与前述实施例中类似,在此不做 赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过核间通信接口将第一操作系统的第一交互请求传输至第二操作系统:
通过核间通信接口将中断号为第一中断号的第一抢占请求传输至第二操作系统,其中,第一抢占请求用于请求抢占第二操作系统的处理资源;
通过核间通信接口将中断号为第二中断号的资源释放请求传输至第二操作系统,其中,资源释放请求用于请求将第一操作系统所占用的处理资源释放给第二操作系统。
在本实施例中,资源抢占与释放模块通过核间中断进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下步骤实现通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放:
通过核间通信接口将第二操作系统的第二交互请求传输至第一操作系统,其中,第二交互请求用于请求抢占第一操作系统的处理资源;
通过核间通信接口获取第一操作系统响应第二交互请求返回的第二交互响应,其中,第二交互响应用于指示第一操作系统是否允许第二操作系统抢占第一操作系统的处理资源。
在本实施例中,资源抢占与释放模块通过核间通信接口进行第一操作系统和第二操作系统之间的资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还包括:
第二系统控制模块,用于检测第二操作系统的处理资源的资源利用率,在根据第二操作系统的处理资源的资源利用率,确定第二操作系统待抢占第一操作系统的处理资源的情况下,触发资源抢占与释放模块通过核间通信接口将第二交互请求传输至第一操作系统。
在本实施例中,第二系统控制模块基于第二操作系统的处理资源的资源利用率触发进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第二系统控制模块,还用于执行以下至少之一的步骤:
在第二操作系统的处理资源当前的资源利用率大于或者等于第二利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源;
在根据第二操作系统的执行中业务和第二操作系统的待执行业务确定第二操作系统的处理资源的资源利用率大于或者等于第三利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源。
在本实施例中,第二系统控制模块确定第二操作系统待进行的资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一操作系统还用于在第一操作系统的执行中业务的业务优先级不低于第二操作系统的待执行业务的业务优先级的情况下,确定第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源;在第一操作系统的执行中业务的业务优先级低于第二操作系统的待执行业务的业务优先级的情况下,确定第一操作系统允许第二操作系统抢占第一操作系统的处理资源。
在本实施例中,嵌入式系统确定第一操作系统是否允许第二操作系统其占用的处理资源的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下步骤实现通过核间通信接口将第二操作系统的第二交互请求传输至第一操作系统:
通过核间通信接口将中断号为第三中断号的第二抢占请求传输至第一操作系统,其中,第二抢占请求用于请求抢占第一操作系统的处理资源。
在本实施例中,资源抢占与释放模块通过核间中断进行资源交互的方式与前述实施例中类似,在此不做赘 述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过核间通信接口获取第一操作系统响应第二交互请求返回的第二交互响应:
通过核间通信接口将中断号为第四中断号的允许资源释放响应传输至第二操作系统,其中,允许资源释放响应用于指示第一操作系统允许第二操作系统抢占第一操作系统的处理资源;
通过核间通信接口将中断号为第五中断号的拒绝资源释放响应传输至第二操作系统,其中,拒绝资源释放响应用于指示第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源。
在本实施例中,资源抢占与释放模块通过核间中断进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源自适应调度模块,还用于执行以下至少之一的步骤:将第一操作系统抢占的第二操作系统的处理资源合并到第一操作系统的可用资源池中;将第二操作系统抢占的第一操作系统的处理资源或者第一操作系统主动释放给第二操作系统的处理资源合并到第二操作系统的可用资源池中。
在本实施例中,资源自适应调度模块在不同操作系统之间进行处理资源调度的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还包括:
系统启动模块,用于在处理器所在的芯片上电之后,通过引导加载程序在第一初始处理资源上引导运行第一操作系统,以及通过引导加载程序在第二初始处理资源上引导运行第二操作系统,其中,第一初始处理资源是处理器的处理资源中与第一操作系统对应的初始处理资源,第二初始处理资源是处理器的处理资源中与第二操作系统对应的初始处理资源。
在本实施例中,系统启动模块通过引导加载程序在对应的初始处理资源上引导运行各个操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一初始处理资源为处理器的处理器核心中的一个指定处理器核心,第二初始处理资源为处理器的处理器核心中除了指定处理器核心以外的其他处理器核心。
在一个示例性实施例中,系统启动模块用于通过执行以下步骤实现通过引导加载程序在第一初始处理资源上引导运行第一操作系统:
通过二级程序加载器在第一初始处理资源上引导运行第一操作系统。
在本实施例中,系统启动模块通过二级程序加载器在初始处理资源上引导运行操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,系统启动模块,还用于通过固化在设备主板上的启动芯片内的预设程序对二级程序加载器的代码进行安全启动检查,其中,二级程序加载器是在安全启动检查的检查结果正常之后执行的。
在本实施例中,系统启动模块对二级程序加载器的代码进行安全启动检查的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,系统启动模块用于通过执行以下步骤实现通过引导加载程序在第二初始处理资源上引导运行第二操作系统:
通过二级程序加载器唤醒第二初始处理资源,并引导执行通用引导加载程序,以引导运行第二操作系统。
在本实施例中,系统启动模块通过二级程序加载器引导运行第二操作系统的方式与前述实施例中类似,在此不做赘述。
根据本申请实施例的另一个方面,还提供了一种用于实施上述嵌入式系统的运行方法的嵌入式系统,上述嵌入式系统可以运行于上述BMC芯片上,其中,上述嵌入式系统可以包括:
第一操作系统和第二操作系统,第一操作系统和第二操作系统运行于处理器上,第一操作系统的响应速度高于第二操作系统;
业务管理模块,用于根据资源动态分配规则将一组待分配业务分配给对应的操作系统,其中,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率;
资源动态分配模块,用于确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源,处理器的处理资源包括处理器核心;
资源自适应调度模块,用于根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统。
在本实施例中,第一操作系统和第二操作系统可以与前述实施例中类似,在此不做赘述,业务管理模块、资源动态分配模块和资源自适应调度模块可以是运行在第一操作系统或者第二操作系统下的软件模组,通过进行上述模块划分,可以方便进行不同功能模块的开发与维护,同时,对于资源动态分配规则,通过对资源动态分配规则进行灵活设置,提高资源分配的灵活性。
通过上述嵌入式系统,该嵌入式系统包括:第一操作系统和第二操作系统,第一操作系统和第二操作系统运行于处理器上,第一操作系统的响应速度高于第二操作系统;业务管理模块,用于根据资源动态分配规则将一组待分配业务分配给对应的操作系统,其中,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率;资源动态分配模块,用于确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源,处理器的处理资源包括处理器核心;资源自适应调度模块,用于根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统,解决了相关技术中存在由于多核处理器多数的处理资源处于空闲状态导致的核心资源的整体利用率较低的问题,提高了处理资源的利用率。
在一个示例性实施例中,嵌入式系统还包括:
负载均衡策略模块,用于通过读取规则配置文件,生成规则结构体,其中,规则结构体用于记录资源动态分配规则。
本实施例中的负载均衡策略模块与前述实施例中类似,在此不做赘述。这里,负载均衡策略模块可以是第一操作系统或第二操作系统下的软件模组,通过将负载均衡策略配置为由单独的软件模组进行存储,可以方便对负载均衡策略进行灵活调整。
在一个示例性实施例中,负载均衡策略模块,还用于
通过第二操作系统的对外接口获取规则更新配置文件,其中,规则更新配置文件用于更新已配置的资源动态分配规则;使用规则更新配置文件更新规则结构体,以更新规则结构体所记录的资源动态分配规则。
在本实施例中,负载均衡策略模块中存储的资源动态分配规则可以通过第二操作系统的对外接口进行灵活配置,配置的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块用于通过执行以下步骤实现根据资源动态分配规则中与业务响应速度对应的分配规则将一组待分配业务分配给对应的操作系统:
将一组待分配业务中业务响应速度要求大于或者等于设定响应速度阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务中业务响应速度要求小于设定响应速度阈值的待分配业务分配给第二操作系统。
在本实施例中,业务管理模块根据业务响应速度进行待分配业务分配的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块用于通过执行以下步骤实现根据资源动态分配规则中与业务资源占用率对应的分配规则将一组待分配业务分配给对应的操作系统:
将一组待分配业务中业务资源占用率小于第一占用率阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务资源占用率大于或者等于第一占用率阈值的待分配业务分配给第二操作系统。
在本实施例中,业务管理模块根据业务资源占用率进行待分配业务分配的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块还用于通过执行以下至少之一的步骤实现将一组待分配业务分配给对应的操作系统:
将一组待分配业务中与第一操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,分配给第一操作系统;
将一组待分配业务中与第二操作系统的已分配业务的业务耦合度大于或者等于第二耦合度阈值的待分配业务,分配给第二操作系统。
在本实施例中,业务管理模块根据业务耦合度进行待分配业务分配的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块还用于通过执行以下步骤实现将一组待分配业务分配给对应的操作系统:
将一组待分配业务中包含敏感信息的待分配业务,分配给目标操作系统,其中,目标操作系统是第一操作系统和第二操作系统中,与使用对象交互频率低的操作系统。
在本实施例中,业务管理模块将包含敏感信息的待分配业务分配给第一操作系统的方式与前述实施例中类似,在此不做赘述。
需要说明的是,业务管理模块基于业务响应速度和业务资源占用率进行待分配业务分配是基于负载均衡策略模块中所存储的资源动态分配规则执行的,而基于业务耦合度和业务重要性(例如,是否包含敏感信息)进行待分配业务分配可以是业务管理模块基于其上预置的配置信息执行的,由于基于业务耦合度和业务重要性的处理资源分配规则通常是稳定的,而业务响应速度和业务资源占用率可以基于需求进行灵活配置,通过单独的软件模组存储根据业务响应速度和业务资源占用率中的至少之一进行资源动态分配的资源动态分配规则,可以兼顾规则配置的灵活性和简洁性。
在一个示例性实施例中,资源动态分配模块用于通过执行以下步骤实现确定与一组待分配业务对应的资源分配结果:
根据业务管理模块的分配结果,结合第一操作系统的处理资源的资源利用情况和第二操作系统的处理资源的资源利用情况,生成一组待分配业务与处理器的处理资源的资源映射表。
在本实施例中,资源动态分配模块生成一组待分配业务与处理器的处理资源的资源映射表的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源动态分配模块以处理器核心为单位将处理器的处理资源分配给第一操作系统和第二操作系统。
在一个示例性实施例中,资源自适应调度模块用于通过执行以下步骤实现根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统:
在根据资源分配结果确定处理器的处理资源中的未分配处理资源存在对应的待分配业务的情况下,将未分配处理资源分配给与未分配处理资源对应的待分配业务所分配给的操作系统。
在本实施例中,资源自适应调度模块将未分配处理资源分配给操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还包括:
资源抢占与释放模块,用于在第一操作系统和第二操作系统之间进行处理资源的抢占和释放。
在本实施例中,资源抢占与释放模块在不同操作系统之间进行处理资源的抢占和释放与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下步骤实现通过核间通信接口在第一操作系 统和第二操作系统之间进行处理资源的抢占和释放:
通过核间通信接口将第一操作系统的第一交互请求传输至第二操作系统,其中,第一交互请求用于请求与第二操作系统进行资源交互,资源交互包括以下之一:资源抢占,资源释放;
通过核间通信接口获取第二操作系统响应第一交互请求返回的第一交互响应,其中,第一交互响应用于指示第一操作系统根据第一交互响应与第二操作系统进行资源交互。
在本实施例中,资源抢占与释放模块通过核间通信接口进行第一操作系统和第二操作系统之间的资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还包括:
第一系统控制模块,用于检测第一操作系统的处理资源的资源利用率,在根据第一操作系统的处理资源的资源利用率,确定第一操作系统待与第二操作系统进行资源交互的情况下,触发资源抢占与释放模块通过核间通信接口将第一交互请求传输至第二操作系统。
在本实施例中,第一系统控制模块基于第一操作系统的处理资源的资源利用率触发进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一系统控制模块,还用于执行以下至少之一的步骤:在第一操作系统的处理资源的资源利用率大于或者等于第一利用率阈值的情况下,确定第一操作系统待抢占第二操作系统的处理资源;在第一操作系统的处理资源处于空闲状态且不存在待第一操作系统执行的业务的情况下,确定第一操作系统待释放处理资源给第二操作系统。
在本实施例中,第一系统控制模块确定第一操作系统待进行的资源交互类型的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一系统控制模块,还用于在第一操作系统没有业务调度、且没有待分配给第一操作系统的业务的情况下,控制第一操作系统进入休眠状态。
在本实施例中,第一系统控制模块控制第一操作系统进入休眠状态的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过核间通信接口将第一操作系统的第一交互请求传输至第二操作系统:
通过核间通信接口将中断号为第一中断号的第一抢占请求传输至第二操作系统,其中,第一抢占请求用于请求抢占第二操作系统的处理资源;
通过核间通信接口将中断号为第二中断号的资源释放请求传输至第二操作系统,其中,资源释放请求用于请求将第一操作系统所占用的处理资源释放给第二操作系统。
在本实施例中,资源抢占与释放模块通过核间中断进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下步骤实现通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放:
通过核间通信接口将第二操作系统的第二交互请求传输至第一操作系统,其中,第二交互请求用于请求抢占第一操作系统的处理资源;
通过核间通信接口获取第一操作系统响应第二交互请求返回的第二交互响应,其中,第二交互响应用于指示第一操作系统是否允许第二操作系统抢占第一操作系统的处理资源。
在本实施例中,资源抢占与释放模块通过核间通信接口进行第一操作系统和第二操作系统之间的资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还包括:
第二系统控制模块,用于检测第二操作系统的处理资源的资源利用率,在根据第二操作系统的处理资源的 资源利用率,确定第二操作系统待抢占第一操作系统的处理资源的情况下,触发资源抢占与释放模块通过核间通信接口将第二交互请求传输至第一操作系统。
在本实施例中,第二系统控制模块基于第二操作系统的处理资源的资源利用率触发进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第二系统控制模块,还用于执行以下至少之一的步骤:
在第二操作系统的处理资源当前的资源利用率大于或者等于第二利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源;
在根据第二操作系统的执行中业务和第二操作系统的待执行业务确定第二操作系统的处理资源的资源利用率大于或者等于第三利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源。
在本实施例中,第二系统控制模块确定第二操作系统待进行的资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还用于在第一操作系统的执行中业务的业务优先级不低于第二操作系统的待执行业务的业务优先级的情况下,确定第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源;在第一操作系统的执行中业务的业务优先级低于第二操作系统的待执行业务的业务优先级的情况下,确定第一操作系统允许第二操作系统抢占第一操作系统的处理资源。
在本实施例中,嵌入式系统确定第一操作系统是否允许第二操作系统其占用的处理资源的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下步骤实现通过核间通信接口将第二操作系统的第二交互请求传输至第一操作系统:
通过核间通信接口将中断号为第三中断号的第二抢占请求传输至第一操作系统,其中,第二抢占请求用于请求抢占第一操作系统的处理资源。
在本实施例中,资源抢占与释放模块通过核间中断进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过核间通信接口获取第一操作系统响应第二交互请求返回的第二交互响应:
通过核间通信接口将中断号为第四中断号的允许资源释放响应传输至第二操作系统,其中,允许资源释放响应用于指示第一操作系统允许第二操作系统抢占第一操作系统的处理资源;
通过核间通信接口将中断号为第五中断号的拒绝资源释放响应传输至第二操作系统,其中,拒绝资源释放响应用于指示第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源。
在本实施例中,资源抢占与释放模块通过核间中断进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源自适应调度模块,还用于执行以下至少之一的步骤:将第一操作系统抢占的第二操作系统的处理资源合并到第一操作系统的可用资源池中;将第二操作系统抢占的第一操作系统的处理资源或者第一操作系统主动释放给第二操作系统的处理资源合并到第二操作系统的可用资源池中。
在本实施例中,资源自适应调度模块在不同操作系统之间进行处理资源调度的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还包括:
系统启动模块,用于在处理器所在的芯片上电之后,通过引导加载程序在第一初始处理资源上引导运行第一操作系统,以及通过引导加载程序在第二初始处理资源上引导运行第二操作系统,其中,第一初始处理资源是处理器的处理资源中与第一操作系统对应的初始处理资源,第二初始处理资源是处理器的处理资源中与第二操作系统对应的初始处理资源。
在本实施例中,系统启动模块通过引导加载程序在对应的初始处理资源上引导运行各个操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一初始处理资源为处理器的处理器核心中的一个指定处理器核心,第二初始处理资源为处理器的处理器核心中除了指定处理器核心以外的其他处理器核心。
在一个示例性实施例中,系统启动模块用于通过执行以下步骤实现通过引导加载程序在第一初始处理资源上引导运行第一操作系统:
通过二级程序加载器在第一初始处理资源上引导运行第一操作系统。
在本实施例中,系统启动模块通过二级程序加载器在初始处理资源上引导运行操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,系统启动模块,还用于通过固化在设备主板上的启动芯片内的预设程序对二级程序加载器的代码进行安全启动检查,其中,二级程序加载器是在安全启动检查的检查结果正常之后执行的。
在本实施例中,系统启动模块对二级程序加载器的代码进行安全启动检查的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,系统启动模块用于通过执行以下步骤实现通过引导加载程序在第二初始处理资源上引导运行第二操作系统:
通过二级程序加载器唤醒第二初始处理资源,并引导执行通用引导加载程序,以引导运行第二操作系统。
在本实施例中,系统启动模块通过二级程序加载器引导运行第二操作系统的方式与前述实施例中类似,在此不做赘述。
根据本申请实施例的又一个方面,还提供了一种用于实施上述嵌入式系统的运行方法的嵌入式系统,图10是根据本申请实施例的一种可选的嵌入式系统的示意图,上述嵌入式系统可以包括:
芯片和至少两个操作系统,其中,
芯片包括处理器1002、硬件控制器1004、第一总线1006和第二总线1008,其中,
第一总线1006的带宽高于第二总线1008带宽,且第一总线1006被配置为多主多从模式,第二总线1008被配置为一主多从模式;
至少两个操作系统基于处理器1002运行,其中,处理器的处理资源被动态分配给至少两个操作系统,处理器的处理资源包括处理器核心;
至少两个操作系统通过第一总线1006进行通信;
至少两个操作系统通过第二总线1008实现对硬件控制器的控制。
其中,上述芯片可以是前述BMC芯片;上述处理器可以是前述多核处理器,上述硬件控制器可以用于控制连接到对应的对外接口的外部设备;上述第一总线被配置为多主多从模式,其可以是处理器的多个处理器核心之间进行通信所使用的总线,例如,AHB(Advanced High Performance Bus,高级高性能总线),上述第二总线被配置为一主多从模式,其可以是处理器对硬件控制器之间控制所使用的总线,例如,APB(Advanced Peripheral Bus,外围总线),第一总线的带宽高于第二总线带宽。
这里,第一总线被配置为多主多从模式是指:第一总线可以用于在多个主设备(Master)和多个从设备(Slave)之间进行数据通信,即,该第一总线可以连接有多个主设备和多个从设备,主设备与主设备之间、主设备与从设备之间均可使用该第一总线进行数据通信。整个第一总线上的数据传输都由主设备发出,由从设备负责回应。第二总线被配置为一主多从模式是指:第二总线可以用于在一个主设备和多个从设备之间进行数据通信,即,该第二总线可以连接有一个主设备和多个从设备,主设备与从设备之间可使用该第二总线进行数据通信。数据请求只能由主设备发向从设备,从设备收到请求后返回相应的响应数据给主设备,此过程可以实现一对多的访问。
需要说明的是,通过在操作系统之间使用多主多从模式的总线进行数据通信,可以方便各个操作系统基于需求主动发起数据请求,而硬件控制器主要是基于操作系统的控制对相应的硬件进行控制,因此,在操作系统和硬件控制器之间使用一主多从模式的总线进行通信,数据请求均由操作系统发向硬件控制器,可以提高硬件控制器控制的效率。
前述的AHB总线在AMBA(Advanced Microcontroller Bus Architecture,高级微控制器总线架构)2中就已经定义,AHB总线主要是作为系统高速总线使用,适用于高性能、低功耗的系统设计,其可用于高性能模块之间的连接,作为SoC的片上系统总线,高性能模块可以是CPU、DMA(Direct Memory Access,直接内存访问)和DSP(Digital Signal Processing,数字信号处理器)等。在AMBA协议中,AHB主要面向系统级高带宽高性能的系统互联设计,它包括以下一些特性:单个时钟边沿操作;非三态的实现方式;支持突发传输;支持分段传输;支持多master,多slave的互联模式;可配置32位″128位总线宽度;支持字节、半字节和字的传输。AHB系统包括以下三部分:主模块(即,主设备),从模块(即,从设备)和基础结构(Infrastructure),整个AHB总线上的传输都由主模块发出,由从模块负责回应。基础结构则包括仲裁器(arbiter)、主模块到从模块的多路器、从模块到主模块的多路器、译码器(decoder)、虚拟从模块(dummy Slave)和虚拟主模块(dummy Master)。
APB主要用于低带宽的周边外设之间的连接,例如UART、1284等,它的总线架构不像AHB支持多个主模块,在APB里面唯一的主模块就是APB桥。其特点包括:
①可工作在高频下;
②协议简单:无复杂的时序;
③同步总线:总线上所有的transaction(读写操作)都依赖于时钟的上升沿;
④一主多从:一般情况下,APB挂在AHB总线系统下,通过AHB-APB Bridge将事务在AHB总线系统之间进行转化,此时Bridge即为APB的master,其他的外围设备均为slave;
⑤接口简单:相对应AXI、AHB来说,接口比较简单;
⑥低功耗;
⑦可连接多种外围设备,例如,通过前述硬件控制器可控制的外围设备。
对于APB总线,数据请求只能由Master发向slave,slave收到请求后返回相应的响应数据给master,此过程可以实现一对多的访问,且访问不涉及AHB总线中的仲裁和Decoder解析操作。这里,AHB总线具有高带宽特性,用于系统中高性能模块(CPU、DMA等)间的互联,APB总线带宽较低,用于系统中周边外设(UART、I2C等)之间的连接。AHB总线逻辑电路和总线协议复杂,APB总线接口电路和总线协议相对简单。
嵌入式系统可以包括至少两个操作系统,至少两个操作系统基于处理器运行,而处理器的处理资源被动态分配给至少两个操作系统,处理器的处理资源包括处理器核心,至少两个操作系统通过第一总线进行通信,至少两个操作系统通过第二总线实现对硬件控制器的控制。
可选地,硬件控制器可以包括一种或多种,可以包括但不限于以下至少之一的芯片外设对应的控制器:I2C,USB(Universal Serial Bus,通用串行总线),UART,ADC(Analog to Digital Converter,模拟数字转换器),JTAG(Joint Test Action Group,联合测试工作组),RTC(Real_Time Clock,实时时钟),GPIO(General Purpose Input/0utput,通用输入输出),WDT(Watch Dog Timer,看门狗),虚拟UART(Virtual UART),超级I/0(Super I/0),SGPIO(Serial General Purpose Input/0utput,串行通用输入输出),PWM(Pulse Width Modulation,脉冲宽度调制),FanTach(风扇调速),Timer(时钟),PECI(Platform Environment Control Interface,平台环境式控制接口),邮箱(MailBox),还可以包括其他类型的控制器。对外接口可以包括一种或多种,可以包括但不限于与上述任一控制器对应的对外接口。
例如,BMC芯片的一个示例可以如图11所示,BMC芯片的硬件可以但不限于包括SOC子模块和BMC带外子模块,其中,SOC子模块主要包含ARM核心(ARM Core 1,ARM Core 2,...,ARM Core X),其还可以但不限 于包括DDR(Double Data Rate,双倍速率)4控制器(内存控制器)、MAC(Media Access Control Address,媒体访问控制地址)控制器(网络控制器)、SD(Secure Digital,安全数字)Card/eMMC(Embedded Multi Media Card,嵌入式多媒体卡)控制器(存储控制器)、PCIe RC(Root Complex,根复合体)控制器、SRAM(Static Random-Access Memory,静态随机存取存储器)及SPI控制器。
上述核心与各控制器通过第一总线互连,实现核心与各控制器间的交互。同时,ARM核心间连接至第一总线(比如:可以通过AXI(Advanced eXtensible Interface,高级可扩展接口)桥(Bridge)连接),核心间的通信通过第一总线实现。此外,SOC子模块中还实现了第一总线与第二总线的互连互通(比如:通过APB桥(APB Bridge)的转换实现),这样为SOC子模块访问第二总线上的外设提供一条物理通路。
DDR4控制器可以通过DDR4PHY(Physical Layer,物理层)接口与其他部件或者设备相连,MAC控制器通过RGMII(Reduced Gigabit Media Independent Interface,吉比特介质独立接口)与其他部件或者设备相连,SD卡/eMMC控制器通过SD接口与其他部件或者设备相连,PCIe RC控制器通过PCIe PHY接口与其他部件或者设备相连。
BMC带外子模块主要包含PWM、GPIO、FanTech(风扇调速)、mailbox(邮箱)等芯片外设对应的控制器,通过这些控制器能够实现对BMC的PECI通信(比如使用GPIO模拟PECI)、风扇调控等带外管理功能。由图12可知,该BMC带外子模块可以但不限于通过第二总线实现与SOC子模块的交互。
BMC芯片通过第一与第二总线实现片内ARM核、存储单元及控制器硬件资源间的互连。处理器资源的动态均衡调度主要涉及BMC芯片的ARM核心资源调度,核间通信指ARM核之间进行的通信。以Linux系统抢占RTOS系统核心为例,Linux系统首先在核2~N的某个核上通过片上第一总线向核1发送核间中断(中断号9)。如果此时RTOS系统处于空闲状态允许抢占,核1通过第一总线回复核间中断(中断号10),并释放当前核1映射的外设控制器资源(如,PWM/PECI),Linux系统收到核间中断10,发起抢占流程,把核1加入Linux SMP调度中,同时获得PWM/PECI外设的控制权,可以通过第二总线对其进行控制。
一方面,至少两个操作系统包括第一操作系统和第二操作系统,其中,芯片将通信值装载至第一总线,第一总线将携带有通信值的通信信号发送至第二操作系统对应的通信寄存器,以实现第一操作系统和第二操作系统之间的通信,其中,通信值用于指示第一操作系统和第二操作系统之间的通信内容。
另一方面,芯片将控制值装载至第二总线,第二总线将携带有控制值的控制信号发送至硬件控制器对应的寄存器,以实现操作系统对硬件控制器的控制,其中,控制值用于指示操作系统对硬件控制器的控制内容。
操作系统通过访问(比如执行读操作与写操作)各硬件控制器的寄存器来控制硬件控制器,操作系统访问硬件控制器的寄存器的方式可以但不限于是通过对各硬件控制器的寄存器地址进行读或写,而这些寄存器的地址可以但不限于是在芯片设计时唯一且确定的。例如,操作系统向特定的地址(即上述通信寄存器或者硬件控制器对应的寄存器)写特定的值(即上述通信值或者控制值)就能实现特定的功能(比如上述操作系统之间的通信功能或者操作系统对硬件控制器的控制功能)。也就是说,不同功能对应了不同的控制值,芯片中维护了硬件控制器的功能与控制值之间的对应关系,比如:控制值00表示空调加速一档,控制值01表示空调减速一档等等。
各个操作系统之间,操作系统与硬件控制器之间可以但不限于通过总线进行通信,控制等等的交互。上述操作系统对各硬件控制器的寄存器的读写操作最终会转换为第一总线(或第二总线)对该硬件控制器的控制信号,这部分转换工作及第一总线(或第二总线)对硬件控制器的控制过程可以但不限于是由芯片内部硬件自动实现的。其实现过程遵循总线规范。其中,第一总线(或第二总线)的操作过程中一方面可以传输控制与总线协议相关的物理信号,另一方面还可以通过其物理数据通道传输有效数据至各硬件控制器。
通过上述嵌入式系统,该嵌入式系统包括:芯片和至少两个操作系统,其中,芯片包括处理器、硬件控制器、第一总线和第二总线,其中,第一总线的带宽高于第二总线带宽,且第一总线被配置为多主多从模式,第二总线被配置为一主多从模式;至少两个操作系统基于处理器运行,其中,处理器的处理资源被动态分配给至 少两个操作系统,处理器的处理资源包括处理器核心;至少两个操作系统通过第一总线进行通信;至少两个操作系统通过第二总线实现对硬件控制器的控制,解决了相关技术中存在由于多核处理器多数的处理资源处于空闲状态导致的核心资源的整体利用率较低的问题,提高了处理资源的利用率。
在一个示例性实施例中,至少两个操作系统包括运行于处理器的至少一个处理器核心上的第一操作系统和至少一个处理器核心上的第二操作系统,第一操作系统的响应速度高于第二操作系统;其中,第二操作系统包括:
业务管理模块,用于根据资源动态分配规则将一组待分配业务分配给对应的操作系统,其中,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率;
资源动态分配模块,用于确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源;
资源自适应调度模块,用于根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统。
在本实施例中,至少两个操作系统包括第一操作系统和第二操作系统,每个操作系统至少运行于一个处理器核心上。第一操作系统和第二操作系统可以与前述实施例中类似,本实施例中对此不做赘述。
在一个示例性实施例中,第二操作系统还包括:
负载均衡策略模块,用于通过读取规则配置文件,生成规则结构体,其中,规则结构体用于记录资源动态分配规则。
在本实施例中,负载均衡策略模块生成规则结构体的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,负载均衡策略模块,还用于通过第二操作系统的对外接口获取规则更新配置文件,其中,规则更新配置文件用于更新已配置的资源动态分配规则;使用规则更新配置文件更新规则结构体,以更新规则结构体所记录的资源动态分配规则。
在本实施例中,负载均衡策略模块中存储的资源动态分配规则可以通过第二操作系统的对外接口进行灵活配置,配置的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块用于通过执行以下步骤实现根据资源动态分配规则中与业务响应速度对应的分配规则将一组待分配业务分配给对应的操作系统:
将一组待分配业务中业务响应速度要求大于或者等于设定响应速度阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务中业务响应速度要求小于设定响应速度阈值的待分配业务分配给第二操作系统。
在本实施例中,业务管理模块根据业务响应速度进行待分配业务分配的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块用于通过执行以下步骤实现根据资源动态分配规则中与业务资源占用率对应的分配规则将一组待分配业务分配给对应的操作系统:
将一组待分配业务中业务资源占用率小于第一占用率阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务资源占用率大于或者等于第一占用率阈值的待分配业务分配给第二操作系统。
在本实施例中,业务管理模块根据业务资源占用率进行待分配业务分配的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块还用于通过执行以下至少之一的步骤实现将一组待分配业务分配给对应的操作系统:
将一组待分配业务中与第一操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,分配给第一操作系统;
将一组待分配业务中与第二操作系统的已分配业务的业务耦合度大于或者等于第二耦合度阈值的待分配业务,分配给第二操作系统。
在本实施例中,业务管理模块根据业务耦合度进行待分配业务分配的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,业务管理模块还用于通过执行以下步骤实现将一组待分配业务分配给对应的操作系统:
将一组待分配业务中包含敏感信息的待分配业务,分配给目标操作系统,其中,目标操作系统是第一操作系统和第二操作系统中,与使用对象交互频率低的操作系统。
在本实施例中,业务管理模块将包含敏感信息的待分配业务分配给第一操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源动态分配模块用于通过执行以下步骤实现确定与一组待分配业务对应的资源分配结果:
根据业务管理模块的分配结果,结合第一操作系统的处理资源的资源利用情况和第二操作系统的处理资源的资源利用情况,生成一组待分配业务与处理器的处理资源的资源映射表。
在本实施例中,资源动态分配模块生成一组待分配业务与处理器的处理资源的资源映射表的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源动态分配模块以处理器核心为单位将处理器的处理资源分配给第一操作系统和第二操作系统。
在一个示例性实施例中,资源自适应调度模块用于通过执行以下步骤实现根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统:
在根据资源分配结果确定处理器的处理资源中的未分配处理资源存在对应的待分配业务的情况下,将未分配处理资源分配给与未分配处理资源对应的待分配业务所分配给的操作系统。
在本实施例中,资源自适应调度模块将未分配处理资源分配给操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,嵌入式系统还包括:
资源抢占与释放模块,用于在第一操作系统和第二操作系统之间进行处理资源的抢占和释放。
在本实施例中,资源抢占与释放模块在不同操作系统之间进行处理资源的抢占和释放与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块通过第一总线在第一操作系统和第二操作系统之间进行处理资源的抢占和释放,第一总线是处理器的不同处理器核心之间进行通信的总线。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下步骤实现通过第一总线在第一操作系统和第二操作系统之间进行处理资源的抢占和释放:
通过第一总线将第一操作系统的第一交互请求传输至第二操作系统,其中,第一交互请求用于请求与第二操作系统进行资源交互,资源交互包括以下之一:资源抢占,资源释放;
通过第一总线获取第二操作系统响应第一交互请求返回的第一交互响应,其中,第一交互响应用于指示第一操作系统根据第一交互响应与第二操作系统进行资源交互。
在本实施例中,资源抢占与释放模块通过核间通信接口进行第一操作系统和第二操作系统之间的资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一操作系统包括:
第一系统控制模块,用于检测第一操作系统的处理资源的资源利用率,在根据第一操作系统的处理资源的资源利用率,确定第一操作系统待与第二操作系统进行资源交互的情况下,触发资源抢占与释放模块通过第一总线将第一交互请求传输至第二操作系统。
在本实施例中,第一系统控制模块基于第一操作系统的处理资源的资源利用率触发进行资源交互的方式与 前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一系统控制模块,还用于执行以下至少之一的步骤:在第一操作系统的处理资源的资源利用率大于或者等于第一利用率阈值的情况下,确定第一操作系统待抢占第二操作系统的处理资源;在第一操作系统的处理资源处于空闲状态且不存在待第一操作系统执行的业务的情况下,确定第一操作系统待释放处理资源给第二操作系统。
在本实施例中,第一系统控制模块确定第一操作系统待进行的资源交互类型的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一系统控制模块,还用于在第一操作系统没有业务调度、且没有待分配给第一操作系统的业务的情况下,控制第一操作系统进入休眠状态。
在本实施例中,第一系统控制模块控制第一操作系统进入休眠状态的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过第一总线将第一操作系统的第一交互请求传输至第二操作系统:
通过第一总线将中断号为第一中断号的第一抢占请求传输至第二操作系统,其中,第一抢占请求用于请求抢占第二操作系统的处理资源;
通过第一总线将中断号为第二中断号的资源释放请求传输至第二操作系统,其中,资源释放请求用于请求将第一操作系统所占用的处理资源释放给第二操作系统。
在本实施例中,资源抢占与释放模块通过核间中断进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下步骤实现通过第一总线在第一操作系统和第二操作系统之间进行处理资源的抢占和释放:
通过第一总线将第二操作系统的第二交互请求传输至第一操作系统,其中,第二交互请求用于请求抢占第一操作系统的处理资源;
通过第一总线获取第一操作系统响应第二交互请求返回的第二交互响应,其中,第二交互响应用于指示第一操作系统是否允许第二操作系统抢占第一操作系统的处理资源。
在本实施例中,资源抢占与释放模块通过核间通信接口进行第一操作系统和第二操作系统之间的资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第二操作系统包括:
第二系统控制模块,用于检测第二操作系统的处理资源的资源利用率,在根据第二操作系统的处理资源的资源利用率,确定第二操作系统待抢占第一操作系统的处理资源的情况下,触发资源抢占与释放模块通过第一总线将第二交互请求传输至第一操作系统。
在本实施例中,第二系统控制模块基于第二操作系统的处理资源的资源利用率触发进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第二系统控制模块,还用于执行以下至少之一的步骤:
在第二操作系统的处理资源当前的资源利用率大于或者等于第二利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源;
在根据第二操作系统的执行中业务和第二操作系统的待执行业务确定第二操作系统的处理资源的资源利用率大于或者等于第三利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源。
在本实施例中,第二系统控制模块确定第二操作系统待进行的资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一操作系统还用于在第一操作系统的执行中业务的业务优先级不低于第二操作 系统的待执行业务的业务优先级的情况下,确定第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源;在第一操作系统的执行中业务的业务优先级低于第二操作系统的待执行业务的业务优先级的情况下,确定第一操作系统允许第二操作系统抢占第一操作系统的处理资源。
在本实施例中,第一操作系统确定是否允许第二操作系统其占用的处理资源的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下步骤实现通过第一总线将第二操作系统的第二交互请求传输至第一操作系统:
通过第一总线将中断号为第三中断号的第二抢占请求传输至第一操作系统,其中,第二抢占请求用于请求抢占第一操作系统的处理资源。
在本实施例中,资源抢占与释放模块通过第一总线进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过第一总线获取第一操作系统响应第二交互请求返回的第二交互响应:
通过第一总线将中断号为第四中断号的允许资源释放响应传输至第二操作系统,其中,允许资源释放响应用于指示第一操作系统允许第二操作系统抢占第一操作系统的处理资源;
通过第一总线将中断号为第五中断号的拒绝资源释放响应传输至第二操作系统,其中,拒绝资源释放响应用于指示第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源。
在本实施例中,资源抢占与释放模块通过第一总线进行资源交互的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,资源自适应调度模块,还用于执行以下至少之一的步骤:将第一操作系统抢占的第二操作系统的处理资源合并到第一操作系统的可用资源池中;将第二操作系统抢占的第一操作系统的处理资源或者第一操作系统主动释放给第二操作系统的处理资源合并到第二操作系统的可用资源池中。
在本实施例中,资源自适应调度模块在不同操作系统之间进行处理资源调度的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,处理器,用于在芯片上电之后,通过引导加载程序在第一初始处理资源上引导运行第一操作系统,以及通过引导加载程序在第二初始处理资源上引导运行第二操作系统,其中,第一初始处理资源是处理器的处理资源中与第一操作系统对应的初始处理资源,第二初始处理资源是处理器的处理资源中与第二操作系统对应的初始处理资源。
在本实施例中,处理器通过引导加载程序在对应的初始处理资源上引导运行各个操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,第一初始处理资源为处理器的处理器核心中的一个指定处理器核心,第二初始处理资源为处理器的处理器核心中除了指定处理器核心以外的其他处理器核心。
在一个示例性实施例中,处理器用于通过执行以下步骤实现通过引导加载程序在第一初始处理资源上引导运行第一操作系统:
通过二级程序加载器在第一初始处理资源上引导运行第一操作系统。
在本实施例中,处理器通过二级程序加载器在初始处理资源上引导运行操作系统的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,处理器,还用于通过固化在设备主板上的启动芯片内的预设程序对二级程序加载器的代码进行安全启动检查,其中,二级程序加载器是在安全启动检查的检查结果正常之后执行的。
在本实施例中,处理器对二级程序加载器的代码进行安全启动检查的方式与前述实施例中类似,在此不做赘述。
在一个示例性实施例中,处理器用于通过执行以下步骤实现通过引导加载程序在第二初始处理资源上引导运行第二操作系统:
通过二级程序加载器唤醒第二初始处理资源,并引导执行通用引导加载程序,以引导运行第二操作系统。
在本实施例中,处理器通过二级程序加载器引导运行第二操作系统的方式与前述实施例中类似,在此不做赘述。
根据本申请实施例的又一个方面,还提供了一种用于实施上述嵌入式系统的运行方法的嵌入式系统的运行装置。图12是根据本申请实施例的一种可选的嵌入式系统的运行装置的结构框图,如图12所示,上述装置可以包括:
第一分配单元1202,用于根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统,其中,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,嵌入式系统包括第一操作系统和第二操作系统,第一操作系统和第二操作系统运行于处理器上,第一操作系统的响应速度高于第二操作系统;
第一确定单元1204,与第一分配单元1202相连,用于确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源,处理器的处理资源包括处理器核心;
第二分配单元1206,与第一确定单元1204相连,用于根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统。
需要说明的是,该实施例中的第一分配单元1202可以用于执行上述步骤S202,该实施例中的第一确定单元1204可以用于执行上述步骤S204,该实施例中的第二分配单元1206可以用于执行上述步骤S206。
通过上述模块,根据资源动态分配规则将一组待分配业务分配给嵌入式系统中对应的操作系统,其中,资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,嵌入式系统包括第一操作系统和第二操作系统,第一操作系统和第二操作系统运行于处理器上,第一操作系统的响应速度高于第二操作系统;确定与一组待分配业务对应的资源分配结果,其中,资源分配结果用于指示处理器的处理资源中与一组待分配业务中的每个待分配业务对应的处理资源,处理器的处理资源包括处理器核心;根据与每个待分配业务对应的操作系统以及资源分配结果,将处理器的处理资源分配给第一操作系统和第二操作系统,解决了相关技术中存在由于多核处理器多数的处理资源处于空闲状态导致的核心资源的整体利用率较低的问题,提高了处理资源的利用率。
在一个示例性实施例中,上述装置还包括:
生成单元,用于通过读取规则配置文件,生成规则结构体,其中,规则结构体用于记录资源动态分配规则。
在一个示例性实施例中,上述装置还包括:
获取单元,用于通过第二操作系统的对外接口获取规则更新配置文件,其中,规则更新配置文件用于更新已配置的资源动态分配规则;
更新单元,用于使用规则更新配置文件更新规则结构体,以更新规则结构体所记录的资源动态分配规则。
在一个示例性实施例中,第一分配单元包括以下至少之一:
第一分配模块,用于将一组待分配业务中业务响应速度要求大于或者等于设定响应速度阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务中业务响应速度要求小于设定响应速度阈值的待分配业务分配给第二操作系统。
第二分配模块,用于将一组待分配业务中业务资源占用率小于第一占用率阈值的待分配业务分配给第一操作系统,以及,将一组待分配业务资源占用率大于或者等于第一占用率阈值的待分配业务分配给第二操作系 统;
第三分配模块,用于将一组待分配业务中包含敏感信息的待分配业务,分配给目标操作系统,其中,目标操作系统是第一操作系统和第二操作系统中,与使用对象交互频率低的操作系统。
在一个示例性实施例中,第一分配单元包括以下至少之一:
第四分配模块,用于将一组待分配业务中与第一操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,分配给第一操作系统;
第五分配模块,用于将一组待分配业务中与第二操作系统的已分配业务的业务耦合度大于或者等于第二耦合度阈值的待分配业务,分配给第二操作系统。
在一个示例性实施例中,第一确定单元包括:
生成模块,用于根据一组待分配业务的分配结果,结合第一操作系统的处理资源的资源利用情况和第二操作系统的处理资源的资源利用情况,生成一组待分配业务与处理器的处理资源的资源映射表。
在一个示例性实施例中,处理器的处理资源以处理器核心为单位被分配给第一操作系统和第二操作系统。
在一个示例性实施例中,第二分配单元包括:
第六分配模块,用于在根据资源分配结果确定处理器的处理资源中的未分配处理资源存在对应的待分配业务的情况下,将未分配处理资源分配给与未分配处理资源对应的待分配业务所分配给的操作系统。
在一个示例性实施例中,上述装置还包括:
第一执行单元,用于在第一操作系统和第二操作系统之间进行处理资源的抢占和释放。
在一个示例性实施例中,第一执行单元包括:
执行模块,用于通过核间通信接口在第一操作系统和第二操作系统之间进行处理资源的抢占和释放。
在一个示例性实施例中,执行模块包括:
第一传输子模块,用于通过核间通信接口将第一操作系统的第一交互请求传输至第二操作系统,其中,第一交互请求用于请求与第二操作系统进行资源交互,资源交互包括以下之一:资源抢占,资源释放;
第一获取子模块,用于通过核间通信接口获取第二操作系统响应第一交互请求返回的第一交互响应,其中,第一交互响应用于指示第一操作系统根据第一交互响应与第二操作系统进行资源交互。
在一个示例性实施例中,上述装置还包括:
第一检测单元,用于检测第一操作系统的处理资源的资源利用率;
第二确定单元,用于在根据第一操作系统的处理资源的资源利用率,确定第一操作系统待与第二操作系统进行资源交互的情况下,触发通过核间通信接口将第一交互请求传输至第二操作系统。
在一个示例性实施例中,上述装置还包括以下至少之一:
第三确定单元,用于在第一操作系统的处理资源的资源利用率大于或者等于第一利用率阈值的情况下,确定第一操作系统待抢占第二操作系统的处理资源;
第四确定单元,用于在第一操作系统的处理资源处于空闲状态且不存在待第一操作系统执行的业务的情况下,确定第一操作系统待释放处理资源给第二操作系统。
在一个示例性实施例中,上述装置还包括:
控制单元,用于在第一操作系统没有业务调度、且没有待分配给第一操作系统的业务的情况下,控制第一操作系统进入休眠状态。
在一个示例性实施例中,第一传输子模块包括:
第一传输子单元,用于通过核间通信接口将中断号为第一中断号的第一抢占请求传输至第二操作系统,其中,第一抢占请求用于请求抢占第二操作系统的处理资源;
第二传输子单元,用于通过核间通信接口将中断号为第二中断号的资源释放请求传输至第二操作系统,其中,资源释放请求用于请求将第一操作系统所占用的处理资源释放给第二操作系统。
在一个示例性实施例中,执行模块包括:
第二传输子模块,用于通过核间通信接口将第二操作系统的第二交互请求传输至第一操作系统,其中,第二交互请求用于请求抢占第一操作系统的处理资源;
第二获取子模块,用于通过核间通信接口获取第一操作系统响应第二交互请求返回的第二交互响应,其中,第二交互响应用于指示第一操作系统是否允许第二操作系统抢占第一操作系统的处理资源。
在一个示例性实施例中,上述装置还包括:
第二检测单元,用于检测第二操作系统的处理资源的资源利用率;
第五确定单元,用于在根据第二操作系统的处理资源的资源利用率,确定第二操作系统待抢占第一操作系统的处理资源的情况下,触发通过核间通信接口将第二交互请求传输至第一操作系统。
在一个示例性实施例中,上述装置还包括以下至少之一:
第六确定单元,用于在第二操作系统的处理资源当前的资源利用率大于或者等于第二利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源;
第七确定单元,用于在根据第二操作系统的执行中业务和第二操作系统的待执行业务确定第二操作系统的处理资源的资源利用率大于或者等于第三利用率阈值的情况下,确定第二操作系统待抢占第二操作系统的处理资源。
在一个示例性实施例中,上述装置还包括:
第八确定单元,用于在第一操作系统的执行中业务的业务优先级不低于第二操作系统的待执行业务的业务优先级的情况下,确定第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源;
第九确定单元,用于在第一操作系统的执行中业务的业务优先级低于第二操作系统的待执行业务的业务优先级的情况下,确定第一操作系统允许第二操作系统抢占第一操作系统的处理资源。
在一个示例性实施例中,第二传输子模块包括:
第三传输子单元,用于通过核间通信接口将中断号为第三中断号的第二抢占请求传输至第一操作系统,其中,第二抢占请求用于请求抢占第一操作系统的处理资源。
在一个示例性实施例中,第二获取子模块包括:
第四传输子单元,用于通过核间通信接口将中断号为第四中断号的允许资源释放响应传输至第二操作系统,其中,允许资源释放响应用于指示第一操作系统允许第二操作系统抢占第一操作系统的处理资源;
第五传输子单元,用于通过核间通信接口将中断号为第五中断号的拒绝资源释放响应传输至第二操作系统,其中,拒绝资源释放响应用于指示第一操作系统拒绝第二操作系统抢占第一操作系统的处理资源。
在一个示例性实施例中,上述装置还包括以下至少之一:
第二执行单元,用于将第一操作系统抢占的第二操作系统的处理资源合并到第一操作系统的可用资源池中;
第三执行单元,用于将第二操作系统抢占的第一操作系统的处理资源或者第一操作系统主动释放给第二操作系统的处理资源合并到第二操作系统的可用资源池中。
在一个示例性实施例中,上述装置还包括:
引导单元,用于在处理器所在的芯片上电之后,通过引导加载程序在第一初始处理资源上引导运行第一操作系统,以及通过引导加载程序在第二初始处理资源上引导运行第二操作系统,其中,第一初始处理资源是处理器的处理资源中与第一操作系统对应的初始处理资源,第二初始处理资源是处理器的处理资源中与第二操作系统对应的初始处理资源。
在一个示例性实施例中,第一初始处理资源为处理器的处理器核心中的一个指定处理器核心,第二初始处理资源为处理器的处理器核心中除了指定处理器核心以外的其他处理器核心。
在一个示例性实施例中,引导单元包括:
引导模块,用于通过二级程序加载器在第一初始处理资源上引导运行第一操作系统。
在一个示例性实施例中,上述装置还包括:
检查单元,用于通过固化在设备主板上的启动芯片内的预设程序对二级程序加载器的代码进行安全启动检查,其中,二级程序加载器是在安全启动检查的检查结果正常之后执行的。
在一个示例性实施例中,引导单元还包括:
执行模块,用于通过二级程序加载器唤醒第二初始处理资源,并引导执行通用引导加载程序,以引导运行第二操作系统。
需要说明的是,上述各个模块是可以通过软件或硬件来实现的,对于后者,可以通过以下方式实现,但不限于此:上述模块均位于同一处理器中;或者,上述各个模块以任意组合的形式分别位于不同的处理器中。
本申请的实施例还提供了一种芯片,其中,该芯片包括可编程逻辑电路以及可执行指令中的至少之一,该芯片在电子设备中运行,用于实现上述任一项方法实施例中的步骤。
本申请的实施例还提供了一种BMC芯片,其中,该BMC芯片可以包括:存储单元以及与存储单元连接的处理单元。存储单元用于存储程序,而处理单元用于运行该程序,以执行上述任一项方法实施例中的步骤。
本申请的实施例还提供了一种主板,其中,该主板包括:至少一个处理器;至少一个存储器,用于存储至少一个程序;当至少一个程序被至少一个处理器执行,使得至少一个处理器实现上述任一项方法实施例中的步骤。
本申请的实施例还提供了一种服务器,其中,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信,存储器,用于存放计算机程序;处理器,用于执行存储器上所存放的程序时,实现上述任一项方法实施例中的步骤,以达到相同的技术效果。
上述服务器的通信总线可以是PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(Extended Industry Standard Architecture,扩展工业标准结构)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。通信接口用于上述服务器与其他设备之间的通信。
存储器可以包括RAM,也可以包括NVM(Non-Volatile Memory,非易失性存储器),例如至少一个磁盘存储器。可选地,存储器还可以是至少一个位于远离前述处理器的存储装置。上述的处理器可以是通用处理器,包括CPU、NP(Network Processor,网络处理器)等;还可以是DSP、ASIC、FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。
本申请的实施例还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。
在一个示例性实施例中,上述计算机可读存储介质可以包括但不限于:U盘、ROM、RAM、移动硬盘、磁碟或者光盘等各种可以存储计算机程序的介质。
本申请的实施例还提供了一种电子设备,包括存储器和处理器,该存储器中存储有计算机程序,该处理器被设置为运行计算机程序以执行上述任一项方法实施例中的步骤。
在一个示例性实施例中,上述电子设备还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。
本实施例中的具体示例可以参考上述实施例及示例性实施方式中所描述的示例,本实施例在此不再赘述。
显然,本领域的技术人员应该明白,上述的本申请的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本申请不限制于任何特定的硬件和软件结合。
以上所述仅为本申请的优选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (77)

  1. 一种嵌入式系统,其特征在于,包括:
    第一操作系统和第二操作系统,所述第一操作系统和所述第二操作系统运行于处理器上,所述第一操作系统的响应速度高于所述第二操作系统;
    业务管理模块,用于根据资源动态分配规则将一组待分配业务分配给对应的操作系统,其中,所述资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率;
    资源动态分配模块,用于确定与所述一组待分配业务对应的资源分配结果,其中,所述资源分配结果用于指示所述处理器的处理资源中与所述一组待分配业务中的每个待分配业务对应的处理资源,所述处理器的处理资源包括处理器核心;
    资源自适应调度模块,用于根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统。
  2. 根据权利要求1所述的嵌入式系统,其特征在于,所述嵌入式系统还包括:
    负载均衡策略模块,用于通过读取规则配置文件,生成规则结构体,其中,所述规则结构体用于记录所述资源动态分配规则。
  3. 根据权利要求2所述的嵌入式系统,其特征在于,所述负载均衡策略模块,还用于通过所述第二操作系统的对外接口获取规则更新配置文件,其中,所述规则更新配置文件用于更新已配置的所述资源动态分配规则;使用所述规则更新配置文件更新所述规则结构体,以更新所述规则结构体所记录的所述资源动态分配规则。
  4. 根据权利要求1所述的嵌入式系统,其特征在于,所述业务管理模块用于通过执行以下至少之一的步骤实现根据所述资源动态分配规则中与业务响应速度对应的分配规则将所述一组待分配业务分配给对应的操作系统:
    将所述一组待分配业务中业务响应速度要求大于或者等于设定响应速度阈值的待分配业务分配给所述第一操作系统,以及,将所述一组待分配业务中业务响应速度要求小于设定响应速度阈值的待分配业务分配给所述第二操作系统;
    将所述一组待分配业务中业务资源占用率小于第一占用率阈值的待分配业务分配给所述第一操作系统,以及,将所述一组待分配业务资源占用率大于或者等于第一占用率阈值的待分配业务分配给所述第二操作系统;
    将所述一组待分配业务中包含敏感信息的待分配业务,分配给目标操作系统,其中,所述目标操作系统是所述第一操作系统和所述第二操作系统中,与使用对象交互频率低的操作系统。
  5. 根据权利要求1所述的嵌入式系统,其特征在于,所述业务管理模块还用于通过执行以下至少之一的步骤实现将所述一组待分配业务分配给对应的操作系统:
    将所述一组待分配业务中与所述第一操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,分配给所述第一操作系统;
    将所述一组待分配业务中与所述第二操作系统的已分配业务的业务耦合度大于或者等于第二耦合度阈值的待分配业务,分配给所述第二操作系统。
  6. 根据权利要求1所述的嵌入式系统,其特征在于,所述资源动态分配模块用于通过执行以下步骤实现确定与所述一组待分配业务对应的资源分配结果:
    根据所述业务管理模块的分配结果,结合所述第一操作系统的处理资源的资源利用情况和所述第二操作系统的处理资源的资源利用情况,生成所述一组待分配业务与所述处理器的处理资源的资源映射表。
  7. 根据权利要求1所述的嵌入式系统,其特征在于,所述资源动态分配模块以处理器核心为单位将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统。
  8. 根据权利要求1所述的嵌入式系统,其特征在于,所述资源自适应调度模块用于通过执行以下步骤 实现根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统:
    在根据所述资源分配结果确定所述处理器的处理资源中的未分配处理资源存在对应的待分配业务的情况下,将所述未分配处理资源分配给与所述未分配处理资源对应的待分配业务所分配给的操作系统。
  9. 根据权利要求1所述的嵌入式系统,其特征在于,所述嵌入式系统还包括:
    资源抢占与释放模块,用于在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放。
  10. 根据权利要求9所述的嵌入式系统,其特征在于,所述资源抢占与释放模块通过核间通信接口在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放。
  11. 根据权利要求10所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下步骤实现通过核间通信接口在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放:
    通过核间通信接口将所述第一操作系统的第一交互请求传输至所述第二操作系统,其中,所述第一交互请求用于请求与所述第二操作系统进行资源交互,所述资源交互包括以下之一:资源抢占,资源释放;
    通过所述核间通信接口获取所述第二操作系统响应所述第一交互请求返回的第一交互响应,其中,所述第一交互响应用于指示所述第一操作系统根据所述第一交互响应与所述第二操作系统进行所述资源交互。
  12. 根据权利要求11所述的嵌入式系统,其特征在于,所述嵌入式系统还包括:
    第一系统控制模块,用于检测所述第一操作系统的处理资源的资源利用率,在根据所述第一操作系统的处理资源的资源利用率,确定所述第一操作系统待与所述第二操作系统进行所述资源交互的情况下,触发所述资源抢占与释放模块通过所述核间通信接口将所述第一交互请求传输至所述第二操作系统。
  13. 根据权利要求12所述的嵌入式系统,其特征在于,所述第一系统控制模块,还用于执行以下至少之一的步骤:在所述第一操作系统的处理资源的资源利用率大于或者等于第一利用率阈值的情况下,确定所述第一操作系统待抢占所述第二操作系统的处理资源;在所述第一操作系统的处理资源处于空闲状态且不存在待所述第一操作系统执行的业务的情况下,确定所述第一操作系统待释放处理资源给所述第二操作系统。
  14. 根据权利要求12所述的嵌入式系统,其特征在于,所述第一系统控制模块,还用于在所述第一操作系统没有业务调度、且没有待分配给所述第一操作系统的业务的情况下,控制所述第一操作系统进入休眠状态。
  15. 根据权利要求11所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过核间通信接口将所述第一操作系统的第一交互请求传输至所述第二操作系统:
    通过核间通信接口将中断号为第一中断号的第一抢占请求传输至所述第二操作系统,其中,所述第一抢占请求用于请求抢占所述第二操作系统的处理资源;
    通过核间通信接口将中断号为第二中断号的资源释放请求传输至所述第二操作系统,其中,所述资源释放请求用于请求将所述第一操作系统所占用的处理资源释放给所述第二操作系统。
  16. 根据权利要求10所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下步骤实现通过核间通信接口在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放:
    通过核间通信接口将所述第二操作系统的第二交互请求传输至所述第一操作系统,其中,所述第二交互请求用于请求抢占所述第一操作系统的处理资源;
    通过所述核间通信接口获取所述第一操作系统响应所述第二交互请求返回的第二交互响应,其中,所述第二交互响应用于指示所述第一操作系统是否允许所述第二操作系统抢占所述第一操作系统的处理资源。
  17. 根据权利要求16所述的嵌入式系统,其特征在于,所述嵌入式系统还包括:
    第二系统控制模块,用于检测所述第二操作系统的处理资源的资源利用率,在根据所述第二操作系统的处理资源的资源利用率,确定所述第二操作系统待抢占所述第一操作系统的处理资源的情况下,触发所述资源抢占与释放模块通过所述核间通信接口将所述第二交互请求传输至所述第一操作系统。
  18. 根据权利要求17所述的嵌入式系统,其特征在于,所述第二系统控制模块,还用于执行以下至少之一的步骤:
    在所述第二操作系统的处理资源当前的资源利用率大于或者等于第二利用率阈值的情况下,确定所述第二操作系统待抢占所述第二操作系统的处理资源;
    在根据所述第二操作系统的执行中业务和所述第二操作系统的待执行业务确定所述第二操作系统的处理资源的资源利用率大于或者等于第三利用率阈值的情况下,确定所述第二操作系统待抢占所述第二操作系统的处理资源。
  19. 根据权利要求18所述的嵌入式系统,其特征在于,所述嵌入式系统还用于在所述第一操作系统的执行中业务的业务优先级不低于所述第二操作系统的待执行业务的业务优先级的情况下,确定所述第一操作系统拒绝所述第二操作系统抢占所述第一操作系统的处理资源;在所述第一操作系统的执行中业务的业务优先级低于所述第二操作系统的待执行业务的业务优先级的情况下,确定所述第一操作系统允许所述第二操作系统抢占所述第一操作系统的处理资源。
  20. 根据权利要求16所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下步骤实现通过核间通信接口将所述第二操作系统的第二交互请求传输至所述第一操作系统:
    通过核间通信接口将中断号为第三中断号的第二抢占请求传输至所述第一操作系统,其中,所述第二抢占请求用于请求抢占所述第一操作系统的处理资源。
  21. 根据权利要求16所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过所述核间通信接口获取所述第一操作系统响应所述第二交互请求返回的第二交互响应:
    通过核间通信接口将中断号为第四中断号的允许资源释放响应传输至所述第二操作系统,其中,所述允许资源释放响应用于指示所述第一操作系统允许所述第二操作系统抢占所述第一操作系统的处理资源;
    通过核间通信接口将中断号为第五中断号的拒绝资源释放响应传输至所述第二操作系统,其中,所述拒绝资源释放响应用于指示所述第一操作系统拒绝所述第二操作系统抢占所述第一操作系统的处理资源。
  22. 根据权利要求9所述的嵌入式系统,其特征在于,资源自适应调度模块,还用于执行以下至少之一的步骤:将所述第一操作系统抢占的所述第二操作系统的处理资源合并到所述第一操作系统的可用资源池中;将所述第二操作系统抢占的所述第一操作系统的处理资源或者所述第一操作系统主动释放给所述第二操作系统的处理资源合并到所述第二操作系统的可用资源池中。
  23. 根据权利要求1至22中任一项所述的嵌入式系统,其特征在于,所述嵌入式系统还包括:
    系统启动模块,用于在所述处理器所在的芯片上电之后,通过引导加载程序在第一初始处理资源上引导运行所述第一操作系统,以及通过所述引导加载程序在第二初始处理资源上引导运行所述第二操作系统,其中,所述第一初始处理资源是所述处理器的处理资源中与所述第一操作系统对应的初始处理资源,所述第二初始处理资源是所述处理器的处理资源中与所述第二操作系统对应的初始处理资源。
  24. 根据权利要求23所述的嵌入式系统,其特征在于,所述第一初始处理资源为所述处理器的处理器核心中的一个指定处理器核心,所述第二初始处理资源为所述处理器的处理器核心中除了所述指定处理器核心以外的其他处理器核心。
  25. 根据权利要求23所述的嵌入式系统,其特征在于,所述系统启动模块用于通过执行以下步骤实现通过引导加载程序在第一初始处理资源上引导运行所述第一操作系统:
    通过二级程序加载器在第一初始处理资源上引导运行所述第一操作系统。
  26. 根据权利要求25所述的嵌入式系统,其特征在于,所述系统启动模块,还用于通过固化在设备主 板上的启动芯片内的预设程序对所述二级程序加载器的代码进行安全启动检查,其中,所述二级程序加载器是在安全启动检查的检查结果正常之后执行的。
  27. 根据权利要求25所述的嵌入式系统,其特征在于,所述系统启动模块用于通过执行以下步骤实现通过引导加载程序在所述第二初始处理资源上引导运行所述第二操作系统:
    通过所述二级程序加载器唤醒所述第二初始处理资源,并引导执行通用引导加载程序,以引导运行所述第二操作系统。
  28. 一种嵌入式系统,其特征在于,包括:芯片和至少两个操作系统,其中,
    所述芯片包括处理器、硬件控制器、第一总线和第二总线,其中,
    所述第一总线的带宽高于所述第二总线带宽,且所述第一总线被配置为多主多从模式,所述第二总线被配置为一主多从模式;
    所述至少两个操作系统基于所述处理器运行,其中,所述处理器的处理资源被动态分配给所述至少两个操作系统,所述处理器的处理资源包括处理器核心;
    所述至少两个操作系统通过所述第一总线进行通信;
    所述至少两个操作系统通过所述第二总线实现对所述硬件控制器的控制。
  29. 根据权利要求28所述的嵌入式系统,其特征在于,所述至少两个操作系统包括运行于所述处理器的至少一个处理器核心上的第一操作系统和至少一个处理器核心上的第二操作系统,所述第一操作系统的响应速度高于所述第二操作系统;其中,所述第二操作系统包括:
    业务管理模块,用于根据资源动态分配规则将一组待分配业务分配给对应的操作系统,其中,所述资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率;
    资源动态分配模块,用于确定与所述一组待分配业务对应的资源分配结果,其中,所述资源分配结果用于指示所述处理器的处理资源中与所述一组待分配业务中的每个待分配业务对应的处理资源;
    资源自适应调度模块,用于根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统。
  30. 根据权利要求29所述的嵌入式系统,其特征在于,所述第二操作系统还包括:
    负载均衡策略模块,用于通过读取规则配置文件,生成规则结构体,其中,所述规则结构体用于记录所述资源动态分配规则。
  31. 根据权利要求30所述的嵌入式系统,其特征在于,所述负载均衡策略模块,还用于通过所述第二操作系统的对外接口获取规则更新配置文件,其中,所述规则更新配置文件用于更新已配置的所述资源动态分配规则;使用所述规则更新配置文件更新所述规则结构体,以更新所述规则结构体所记录的所述资源动态分配规则。
  32. 根据权利要求29所述的嵌入式系统,其特征在于,所述业务管理模块用于通过执行以下至少之一的步骤实现根据所述资源动态分配规则中与业务响应速度对应的分配规则将所述一组待分配业务分配给对应的操作系统:
    将所述一组待分配业务中业务响应速度要求大于或者等于设定响应速度阈值的待分配业务分配给所述第一操作系统,以及,将所述一组待分配业务中业务响应速度要求小于设定响应速度阈值的待分配业务分配给所述第二操作系统;
    将所述一组待分配业务中业务资源占用率小于第一占用率阈值的待分配业务分配给所述第一操作系统,以及,将所述一组待分配业务资源占用率大于或者等于第一占用率阈值的待分配业务分配给所述第二操作系统;
    将所述一组待分配业务中包含敏感信息的待分配业务,分配给目标操作系统,其中,所述目标操作系统是所述第一操作系统和所述第二操作系统中,与使用对象交互频率低的操作系统。
  33. 根据权利要求29所述的嵌入式系统,其特征在于,所述业务管理模块还用于通过执行以下至少之 一的步骤实现将所述一组待分配业务分配给对应的操作系统:
    将所述一组待分配业务中与所述第一操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,分配给所述第一操作系统;
    将所述一组待分配业务中与所述第二操作系统的已分配业务的业务耦合度大于或者等于第二耦合度阈值的待分配业务,分配给所述第二操作系统。
  34. 根据权利要求29所述的嵌入式系统,其特征在于,所述资源动态分配模块用于通过执行以下步骤实现确定与所述一组待分配业务对应的资源分配结果:
    根据所述业务管理模块的分配结果,结合所述第一操作系统的处理资源的资源利用情况和所述第二操作系统的处理资源的资源利用情况,生成所述一组待分配业务与所述处理器的处理资源的资源映射表。
  35. 根据权利要求29所述的嵌入式系统,其特征在于,所述资源动态分配模块以处理器核心为单位将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统。
  36. 根据权利要求29所述的嵌入式系统,其特征在于,所述资源自适应调度模块用于通过执行以下步骤实现根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统:
    在根据所述资源分配结果确定所述处理器的处理资源中的未分配处理资源存在对应的待分配业务的情况下,将所述未分配处理资源分配给与所述未分配处理资源对应的待分配业务所分配给的操作系统。
  37. 根据权利要求29所述的嵌入式系统,其特征在于,所述嵌入式系统还包括:
    资源抢占与释放模块,用于在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放。
  38. 根据权利要求37所述的嵌入式系统,其特征在于,所述资源抢占与释放模块通过所述第一总线在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放,所述第一总线是所述处理器的不同处理器核心之间进行通信的总线。
  39. 根据权利要求38所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下步骤实现通过所述第一总线在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放:
    通过所述第一总线将所述第一操作系统的第一交互请求传输至所述第二操作系统,其中,所述第一交互请求用于请求与所述第二操作系统进行资源交互,所述资源交互包括以下之一:资源抢占,资源释放;
    通过所述第一总线获取所述第二操作系统响应所述第一交互请求返回的第一交互响应,其中,所述第一交互响应用于指示所述第一操作系统根据所述第一交互响应与所述第二操作系统进行所述资源交互。
  40. 根据权利要求39所述的嵌入式系统,其特征在于,所述第一操作系统包括:
    第一系统控制模块,用于检测所述第一操作系统的处理资源的资源利用率,在根据所述第一操作系统的处理资源的资源利用率,确定所述第一操作系统待与所述第二操作系统进行所述资源交互的情况下,触发所述资源抢占与释放模块通过所述第一总线将所述第一交互请求传输至所述第二操作系统。
  41. 根据权利要求40所述的嵌入式系统,其特征在于,所述第一系统控制模块,还用于执行以下至少之一的步骤:在所述第一操作系统的处理资源的资源利用率大于或者等于第一利用率阈值的情况下,确定所述第一操作系统待抢占所述第二操作系统的处理资源;在所述第一操作系统的处理资源处于空闲状态且不存在待所述第一操作系统执行的业务的情况下,确定所述第一操作系统待释放处理资源给所述第二操作系统。
  42. 根据权利要求40所述的嵌入式系统,其特征在于,所述第一系统控制模块,还用于在所述第一操作系统没有业务调度、且没有待分配给所述第一操作系统的业务的情况下,控制所述第一操作系统进入休眠状态。
  43. 根据权利要求39所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过所述第一总线将所述第一操作系统的第一交互请求传输至所述第二操作系统:
    通过所述第一总线将中断号为第一中断号的第一抢占请求传输至所述第二操作系统,其中,所述第一抢占请求用于请求抢占所述第二操作系统的处理资源;
    通过所述第一总线将中断号为第二中断号的资源释放请求传输至所述第二操作系统,其中,所述资源释放请求用于请求将所述第一操作系统所占用的处理资源释放给所述第二操作系统。
  44. 根据权利要求39所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下步骤实现通过所述第一总线在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放:
    通过所述第一总线将所述第二操作系统的第二交互请求传输至所述第一操作系统,其中,所述第二交互请求用于请求抢占所述第一操作系统的处理资源;
    通过所述第一总线获取所述第一操作系统响应所述第二交互请求返回的第二交互响应,其中,所述第二交互响应用于指示所述第一操作系统是否允许所述第二操作系统抢占所述第一操作系统的处理资源。
  45. 根据权利要求44所述的嵌入式系统,其特征在于,所述第二操作系统包括:
    第二系统控制模块,用于检测所述第二操作系统的处理资源的资源利用率,在根据所述第二操作系统的处理资源的资源利用率,确定所述第二操作系统待抢占所述第一操作系统的处理资源的情况下,触发所述资源抢占与释放模块通过所述第一总线将所述第二交互请求传输至所述第一操作系统。
  46. 根据权利要求45所述的嵌入式系统,其特征在于,所述第二系统控制模块,还用于执行以下至少之一的步骤:
    在所述第二操作系统的处理资源当前的资源利用率大于或者等于第二利用率阈值的情况下,确定所述第二操作系统待抢占所述第二操作系统的处理资源;
    在根据所述第二操作系统的执行中业务和所述第二操作系统的待执行业务确定所述第二操作系统的处理资源的资源利用率大于或者等于第三利用率阈值的情况下,确定所述第二操作系统待抢占所述第二操作系统的处理资源。
  47. 根据权利要求46所述的嵌入式系统,其特征在于,所述第一操作系统还用于在所述第一操作系统的执行中业务的业务优先级不低于所述第二操作系统的待执行业务的业务优先级的情况下,确定所述第一操作系统拒绝所述第二操作系统抢占所述第一操作系统的处理资源;在所述第一操作系统的执行中业务的业务优先级低于所述第二操作系统的待执行业务的业务优先级的情况下,确定所述第一操作系统允许所述第二操作系统抢占所述第一操作系统的处理资源。
  48. 根据权利要求46所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下步骤实现通过所述第一总线将所述第二操作系统的第二交互请求传输至所述第一操作系统:
    通过所述第一总线将中断号为第三中断号的第二抢占请求传输至所述第一操作系统,其中,所述第二抢占请求用于请求抢占所述第一操作系统的处理资源。
  49. 根据权利要求44所述的嵌入式系统,其特征在于,所述资源抢占与释放模块用于通过执行以下至少之一的步骤实现通过所述第一总线获取所述第一操作系统响应所述第二交互请求返回的第二交互响应:
    通过所述第一总线将中断号为第四中断号的允许资源释放响应传输至所述第二操作系统,其中,所述允许资源释放响应用于指示所述第一操作系统允许所述第二操作系统抢占所述第一操作系统的处理资源;
    通过所述第一总线将中断号为第五中断号的拒绝资源释放响应传输至所述第二操作系统,其中,所述拒绝资源释放响应用于指示所述第一操作系统拒绝所述第二操作系统抢占所述第一操作系统的处理资源。
  50. 根据权利要求37所述的嵌入式系统,其特征在于,资源自适应调度模块,还用于执行以下至少之一的步骤:将所述第一操作系统抢占的所述第二操作系统的处理资源合并到所述第一操作系统的可用资源池中;将所述第二操作系统抢占的所述第一操作系统的处理资源或者所述第一操作系统主动释放给所述第二操作系统的处理资源合并到所述第二操作系统的可用资源池中。
  51. 根据权利要求29至50中任一项所述的嵌入式系统,其特征在于,所述处理器,用于在所述芯片上电之后,通过引导加载程序在第一初始处理资源上引导运行所述第一操作系统,以及通过所述引导加载程 序在第二初始处理资源上引导运行所述第二操作系统,其中,所述第一初始处理资源是所述处理器的处理资源中与所述第一操作系统对应的初始处理资源,所述第二初始处理资源是所述处理器的处理资源中与所述第二操作系统对应的初始处理资源。
  52. 根据权利要求51所述的嵌入式系统,其特征在于,所述第一初始处理资源为所述处理器的处理器核心中的一个指定处理器核心,所述第二初始处理资源为所述处理器的处理器核心中除了所述指定处理器核心以外的其他处理器核心。
  53. 根据权利要求51所述的嵌入式系统,其特征在于,所述处理器用于通过执行以下步骤实现通过引导加载程序在第一初始处理资源上引导运行所述第一操作系统:
    通过二级程序加载器在第一初始处理资源上引导运行所述第一操作系统。
  54. 根据权利要求53所述的嵌入式系统,其特征在于,所述处理器,还用于通过固化在设备主板上的启动芯片内的预设程序对所述二级程序加载器的代码进行安全启动检查,其中,所述二级程序加载器是在安全启动检查的检查结果正常之后执行的。
  55. 根据权利要求53所述的嵌入式系统,其特征在于,所述处理器用于通过执行以下步骤实现通过所述引导加载程序在所述第二初始处理资源上引导运行所述第二操作系统:
    通过所述二级程序加载器唤醒所述第二初始处理资源,并引导执行通用引导加载程序,以引导运行所述第二操作系统。
  56. 根据权利要求29至50中任一项所述的嵌入式系统,其特征在于,所述至少两个操作系统包括第一操作系统和第二操作系统,其中,
    所述芯片,还用于将通信值装载至所述第一总线;
    所述第一总线,用于将携带有所述通信值的通信信号发送至所述第二操作系统对应的通信寄存器,以实现所述第一操作系统和所述第二操作系统之间的通信,其中,所述通信值用于指示所述第一操作系统和所述第二操作系统之间的通信内容。
  57. 根据权利要求29至50中任一项所述的嵌入式系统,其特征在于,
    所述芯片,还用于将控制值装载至所述第二总线;
    所述第二总线,用于将携带有所述控制值的控制信号发送至所述硬件控制器对应的寄存器,以实现操作系统对所述硬件控制器的控制,其中,所述控制值用于指示操作系统对所述硬件控制器的控制内容。
  58. 一种嵌入式系统的运行方法,其特征在于,包括:
    根据资源动态分配规则将一组待分配业务分配给所述嵌入式系统中对应的操作系统,其中,所述资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,所述嵌入式系统包括第一操作系统和第二操作系统,所述第一操作系统和所述第二操作系统运行于处理器上,所述第一操作系统的响应速度高于所述第二操作系统;
    确定与所述一组待分配业务对应的资源分配结果,其中,所述资源分配结果用于指示所述处理器的处理资源中与所述一组待分配业务中的每个待分配业务对应的处理资源,所述处理器的处理资源包括处理器核心;
    根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统。
  59. 根据权利要求58所述的方法,其特征在于,所述方法还包括:
    通过读取规则配置文件,生成规则结构体,其中,所述规则结构体用于记录所述资源动态分配规则。
  60. 根据权利要求58所述的方法,其特征在于,所述根据资源动态分配规则将一组待分配业务分配给所述嵌入式系统中对应的操作系统,包括以下至少之一:
    将所述一组待分配业务中业务响应速度要求大于或者等于设定响应速度阈值的待分配业务分配给所述第一操作系统,以及,将所述一组待分配业务中业务响应速度要求小于设定响应速度阈值的待分配业务分 配给所述第二操作系统;
    将所述一组待分配业务中业务资源占用率小于第一占用率阈值的待分配业务分配给所述第一操作系统,以及,将所述一组待分配业务资源占用率大于或者等于第一占用率阈值的待分配业务分配给所述第二操作系统;
    将所述一组待分配业务中包含敏感信息的待分配业务,分配给目标操作系统,其中,所述目标操作系统是所述第一操作系统和所述第二操作系统中,与使用对象交互频率低的操作系统。
  61. 根据权利要求58所述的方法,其特征在于,所述根据资源动态分配规则将一组待分配业务分配给所述嵌入式系统中对应的操作系统,包括以下至少之一:
    将所述一组待分配业务中与所述第一操作系统的已分配业务的业务耦合度大于或者等于第一耦合度阈值的待分配业务,分配给所述第一操作系统;
    将所述一组待分配业务中与所述第二操作系统的已分配业务的业务耦合度大于或者等于第二耦合度阈值的待分配业务,分配给所述第二操作系统。
  62. 根据权利要求58所述的方法,其特征在于,所述确定与所述一组待分配业务对应的资源分配结果,包括:
    根据所述一组待分配业务的分配结果,结合所述第一操作系统的处理资源的资源利用情况和所述第二操作系统的处理资源的资源利用情况,生成所述一组待分配业务与所述处理器的处理资源的资源映射表。
  63. 根据权利要求58所述的方法,其特征在于,所述根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统,包括:
    在根据所述资源分配结果确定所述处理器的处理资源中的未分配处理资源存在对应的待分配业务的情况下,将所述未分配处理资源分配给与所述未分配处理资源对应的待分配业务所分配给的操作系统。
  64. 根据权利要求58所述的方法,其特征在于,所述方法还包括:
    通过核间通信接口在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放。
  65. 根据权利要求64所述的方法,其特征在于,所述通过核间通信接口在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放,包括:
    通过核间通信接口将所述第一操作系统的第一交互请求传输至所述第二操作系统,其中,所述第一交互请求用于请求与所述第二操作系统进行资源交互,所述资源交互包括以下之一:资源抢占,资源释放;
    通过所述核间通信接口获取所述第二操作系统响应所述第一交互请求返回的第一交互响应,其中,所述第一交互响应用于指示所述第一操作系统根据所述第一交互响应与所述第二操作系统进行所述资源交互。
  66. 根据权利要求64所述的方法,其特征在于,所述通过核间通信接口在所述第一操作系统和所述第二操作系统之间进行处理资源的抢占和释放,包括:
    通过核间通信接口将所述第二操作系统的第二交互请求传输至所述第一操作系统,其中,所述第二交互请求用于请求抢占所述第一操作系统的处理资源;
    通过所述核间通信接口获取所述第一操作系统响应所述第二交互请求返回的第二交互响应,其中,所述第二交互响应用于指示所述第一操作系统是否允许所述第二操作系统抢占所述第一操作系统的处理资源。
  67. 根据权利要求66所述的方法,其特征在于,所述方法还包括:
    检测所述第二操作系统的处理资源的资源利用率;
    在根据所述第二操作系统的处理资源的资源利用率,确定所述第二操作系统待抢占所述第一操作系统的处理资源的情况下,触发通过所述核间通信接口将所述第二交互请求传输至所述第一操作系统。
  68. 根据权利要求67所述的方法,其特征在于,所述方法还包括以下至少之一:
    在所述第二操作系统的处理资源当前的资源利用率大于或者等于第二利用率阈值的情况下,确定所述 第二操作系统待抢占所述第二操作系统的处理资源;
    在根据所述第二操作系统的执行中业务和所述第二操作系统的待执行业务确定所述第二操作系统的处理资源的资源利用率大于或者等于第三利用率阈值的情况下,确定所述第二操作系统待抢占所述第二操作系统的处理资源。
  69. 根据权利要求68所述的方法,其特征在于,所述方法还包括:
    在所述第一操作系统的待执行业务的业务优先级不低于所述第二操作系统的待分配业务的业务优先级的情况下,确定所述第一操作系统拒绝所述第二操作系统抢占所述第一操作系统的处理资源;
    在所述第一操作系统的待执行业务的业务优先级低于所述第二操作系统的待执行业务的业务优先级的情况下,确定所述第一操作系统允许所述第二操作系统抢占所述第一操作系统的处理资源。
  70. 根据权利要求58至69中任一项所述的方法,其特征在于,所述方法还包括:
    在所述处理器所在的芯片上电之后,通过引导加载程序在第一初始处理资源上引导运行所述第一操作系统,以及通过所述引导加载程序在第二初始处理资源上引导运行所述第二操作系统,其中,所述第一初始处理资源是所述处理器的处理资源中与所述第一操作系统对应的初始处理资源,所述第二初始处理资源是所述处理器的处理资源中与所述第二操作系统对应的初始处理资源。
  71. 一种嵌入式系统的运行装置,其特征在于,包括:
    第一分配单元,用于根据资源动态分配规则将一组待分配业务分配给所述嵌入式系统中对应的操作系统,其中,所述资源动态分配规则包括根据以下至少之一进行资源动态分配:业务响应速度,业务资源占用率,业务耦合度,业务重要性,所述嵌入式系统包括第一操作系统和第二操作系统,所述第一操作系统和所述第二操作系统运行于处理器上,所述第一操作系统的响应速度高于所述第二操作系统;
    第一确定单元,用于确定与所述一组待分配业务对应的资源分配结果,其中,所述资源分配结果用于指示所述处理器的处理资源中与所述一组待分配业务中的每个待分配业务对应的处理资源,所述处理器的处理资源包括处理器核心;
    第二分配单元,用于根据与所述每个待分配业务对应的操作系统以及所述资源分配结果,将所述处理器的处理资源分配给所述第一操作系统和所述第二操作系统。
  72. 一种芯片,其特征在于,所述芯片包括可编程逻辑电路以及可执行指令中的至少之一,所述芯片在电子设备中运行,用于实现权利要求58至70中任一项所述的方法。
  73. 一种BMC芯片,其特征在于,包括:存储单元以及与所述存储单元连接的处理单元,所述存储单元用于存储程序,所述处理单元用于运行所述程序,以执行如权利要求58至70中任一项所述的方法。
  74. 一种主板,其特征在于,包括:
    至少一个处理器;
    至少一个存储器,用于存储至少一个程序;
    当所述至少一个程序被所述至少一个处理器执行,使得所述至少一个处理器实现如权利要求58至70中任一项所述的方法。
  75. 一种服务器,其特征在于,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;
    存储器,用于存放计算机程序;
    处理器,用于执行存储器上所存放的程序时,实现权利要求58至70中任一项所述的方法。
  76. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,其中,所述计算机程序被处理器执行时实现所述权利要求58至70中任一项中所述的方法的步骤。
  77. 一种电子设备,包括存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现所述权利要求58至70中任一项中所述的方法的步骤。
PCT/CN2023/091876 2023-04-28 2023-04-28 嵌入式系统的运行方法和装置、嵌入式系统及芯片 Ceased WO2024221468A1 (zh)

Priority Applications (9)

Application Number Priority Date Filing Date Title
EP23825349.6A EP4474989B1 (en) 2023-04-28 2023-04-28 Method and device for operating embedded system, embedded system, and chip
KR1020257006679A KR20250035609A (ko) 2023-04-28 2023-04-28 임베디드 시스템의 실행 방법 및 장치, 임베디드 시스템 및 칩
US18/574,657 US12293238B2 (en) 2023-04-28 2023-04-28 Embedded system running method and apparatus, and embedded system and chip
KR1020237045014A KR102776397B1 (ko) 2023-04-28 2023-04-28 임베디드 시스템의 실행 방법 및 장치, 임베디드 시스템 및 칩
PCT/CN2023/091876 WO2024221468A1 (zh) 2023-04-28 2023-04-28 嵌入式系统的运行方法和装置、嵌入式系统及芯片
JP2023580598A JP7776542B2 (ja) 2023-04-28 2023-04-28 組み込みシステムの動作方法及び装置、組み込みシステム及びチップ
CN202380009072.XA CN116868170A (zh) 2023-04-28 2023-04-28 嵌入式系统的运行方法和装置、嵌入式系统及芯片
US19/169,568 US20250278312A1 (en) 2023-04-28 2025-04-03 Embedded system running method and apparatus, and embedded system and chip
US19/169,499 US20250278311A1 (en) 2023-04-28 2025-04-03 Embedded system running method and apparatus, and embedded system and chip

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2023/091876 WO2024221468A1 (zh) 2023-04-28 2023-04-28 嵌入式系统的运行方法和装置、嵌入式系统及芯片

Related Child Applications (3)

Application Number Title Priority Date Filing Date
US18/574,657 A-371-Of-International US12293238B2 (en) 2023-04-28 2023-04-28 Embedded system running method and apparatus, and embedded system and chip
US19/169,568 Division US20250278312A1 (en) 2023-04-28 2025-04-03 Embedded system running method and apparatus, and embedded system and chip
US19/169,499 Division US20250278311A1 (en) 2023-04-28 2025-04-03 Embedded system running method and apparatus, and embedded system and chip

Publications (1)

Publication Number Publication Date
WO2024221468A1 true WO2024221468A1 (zh) 2024-10-31

Family

ID=88223857

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/091876 Ceased WO2024221468A1 (zh) 2023-04-28 2023-04-28 嵌入式系统的运行方法和装置、嵌入式系统及芯片

Country Status (6)

Country Link
US (3) US12293238B2 (zh)
EP (1) EP4474989B1 (zh)
JP (1) JP7776542B2 (zh)
KR (2) KR102776397B1 (zh)
CN (1) CN116868170A (zh)
WO (1) WO2024221468A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116643892B (zh) * 2023-07-25 2023-10-27 北京芯驰半导体科技有限公司 内存管理方法、装置、芯片及交通设备
CN117319716B (zh) * 2023-11-28 2024-02-27 苏州元脑智能科技有限公司 基板管理控制芯片的资源调度方法及基板管理控制芯片
CN118277033A (zh) * 2024-04-11 2024-07-02 北京经纬恒润科技股份有限公司 一种仿真调度方法、装置、设备及介质
CN118444645B (zh) * 2024-05-09 2025-11-25 中国核动力研究设计院 核安全级dcs现场控制站的仿真装置、仿真方法及存储介质
CN119806630A (zh) * 2024-11-21 2025-04-11 南方电网数字电网科技(广东)有限公司 基于核心板的多平台操作系统兼容系统
CN119602480A (zh) * 2024-11-29 2025-03-11 中国南方电网有限责任公司 一种低压配电轻量级控制芯片
CN119201255B (zh) * 2024-11-29 2026-04-17 浪潮电子信息产业股份有限公司 命令处理方法、装置、基板管理控制器、程序产品和介质
CN119322684B (zh) * 2024-12-19 2025-05-06 杭州宇泛智能科技股份有限公司 芯片平台资源动态调度方法
CN121029256B (zh) * 2025-10-27 2026-01-30 浪潮计算机科技有限公司 一种ai服务器的bmc优化方法、系统、电子设备及存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106469283A (zh) * 2016-08-30 2017-03-01 乐视控股(北京)有限公司 一种车载系统
CN115413337A (zh) * 2021-03-29 2022-11-29 华为技术有限公司 电子装置、系统级芯片和物理核分配方法
CN115421871A (zh) * 2022-09-26 2022-12-02 科东(广州)软件科技有限公司 一种对系统的硬件资源动态分配的方法、装置及计算设备

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101557995B1 (ko) * 2008-10-08 2015-10-19 엘지전자 주식회사 다중 운영체제를 지원하는 단말기 및 그 단말기에 대한시스템 자원 할당 방법
KR20130104958A (ko) * 2012-03-16 2013-09-25 삼성전자주식회사 다중 운영체제들을 실행하는 장치 및 방법
KR101934293B1 (ko) * 2012-08-03 2019-01-02 엘지전자 주식회사 이동 단말기의 이동 단말기 및 그의 nfc결제 방법
KR20140076185A (ko) * 2012-12-12 2014-06-20 (주)한국산업정보기술 복수의 운영체제 동시구동이 가능한 모바일 디바이스와 그 구동방법
CN105988872B (zh) * 2015-02-03 2020-02-18 阿里巴巴集团控股有限公司 一种cpu资源分配的方法、装置及电子设备
CN113391821B (zh) * 2021-05-11 2023-03-10 中国电力科学研究院有限公司 一种非对称多处理器嵌入式操作系统
CN115964150A (zh) * 2022-12-30 2023-04-14 济南浪潮数据技术有限公司 一种基于双实时内核的业务处理方法、系统、设备及介质

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106469283A (zh) * 2016-08-30 2017-03-01 乐视控股(北京)有限公司 一种车载系统
CN115413337A (zh) * 2021-03-29 2022-11-29 华为技术有限公司 电子装置、系统级芯片和物理核分配方法
CN115421871A (zh) * 2022-09-26 2022-12-02 科东(广州)软件科技有限公司 一种对系统的硬件资源动态分配的方法、装置及计算设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4474989A4 *

Also Published As

Publication number Publication date
CN116868170A (zh) 2023-10-10
US12293238B2 (en) 2025-05-06
EP4474989A4 (en) 2024-12-11
US20250278311A1 (en) 2025-09-04
JP7776542B2 (ja) 2025-11-26
US20250278312A1 (en) 2025-09-04
JP2025518991A (ja) 2025-06-24
US20240362083A1 (en) 2024-10-31
KR102776397B1 (ko) 2025-03-04
KR20240159790A (ko) 2024-11-06
KR20250035609A (ko) 2025-03-12
EP4474989B1 (en) 2026-04-22
EP4474989A1 (en) 2024-12-11

Similar Documents

Publication Publication Date Title
EP4481563B1 (en) Start control method and apparatus for embedded system, and storage medium and electronic device
EP4474989B1 (en) Method and device for operating embedded system, embedded system, and chip
JP7813305B2 (ja) オペレーティングシステムの実行制御方法、装置、組み込みシステム及びチップ
CN116541227B (zh) 故障诊断方法、装置、存储介质、电子装置及bmc芯片
CN116243995B (zh) 通信方法、装置、计算机可读存储介质以及电子设备
CN116244229B (zh) 硬件控制器的访问方法、装置、存储介质和电子设备
CN116257364B (zh) 系统间的资源占用方法、装置、存储介质及电子装置
US20260037466A1 (en) Method and apparatus for generating hardware interface signal, and electronic device
CN116627520A (zh) 基板管理控制器的系统运行方法以及基板管理控制器
CN116302617A (zh) 共享内存的方法、通信方法、嵌入式系统以及电子设备
CN118885307A (zh) 共享资源的访问控制方法及装置、存储介质及电子设备
CN117149471B (zh) 通信方法、装置、嵌入式系统、存储介质以及电子设备

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 2023580598

Country of ref document: JP

ENP Entry into the national phase

Ref document number: 2023825349

Country of ref document: EP

Effective date: 20231228

WWD Wipo information: divisional of initial pct application

Ref document number: 1020257006679

Country of ref document: KR

WWP Wipo information: published in national office

Ref document number: 1020257006679

Country of ref document: KR

WWG Wipo information: grant in national office

Ref document number: 18574657

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

WWG Wipo information: grant in national office

Ref document number: 2023825349

Country of ref document: EP