WO2023093134A1 - Method and apparatus for generating system resource allocation code, and electronic device and medium - Google Patents

Method and apparatus for generating system resource allocation code, and electronic device and medium Download PDF

Info

Publication number
WO2023093134A1
WO2023093134A1 PCT/CN2022/112144 CN2022112144W WO2023093134A1 WO 2023093134 A1 WO2023093134 A1 WO 2023093134A1 CN 2022112144 W CN2022112144 W CN 2022112144W WO 2023093134 A1 WO2023093134 A1 WO 2023093134A1
Authority
WO
WIPO (PCT)
Prior art keywords
component
code
resource allocation
system resource
instantiation
Prior art date
Application number
PCT/CN2022/112144
Other languages
French (fr)
Chinese (zh)
Inventor
李鹏
陈彬
洪坤
王波
薛志宏
李禄财
何剑
李翌
Original Assignee
中兴通讯股份有限公司
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
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2023093134A1 publication Critical patent/WO2023093134A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/436Semantic checking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the embodiments of the present application relate to the technical field of embedded systems, and in particular to a method, device, electronic device and medium for generating system resource allocation codes.
  • the operating system kernel generally refers to the hardware-independent part. When it is actually ported to a specific single-board hardware, it needs to be linked and loaded together with the Board Support Package (Board Support Package, BSP) and user code. It is unacceptable in some critical areas such as aircraft because code errors outside the core of the operating system may cause the collapse of the entire system. Therefore, the operating system currently requires users to provide handwritten initialization codes and initial configurations. However, this method is prone to errors during subsequent system operation due to various reasons such as clerical errors, misunderstandings, and unreasonable configurations, and such errors are generally not The first scene is more difficult to investigate.
  • BSP Board Support Package
  • the first method above requires both the user and the operating system (Operating System) to fill in the configuration according to the same template. If a new resource description is added, the configuration template and related parsing code need to be changed to achieve scalability and flexibility. poor.
  • the AADL in the above-mentioned second method is very large and complex, with 185 grammatical rules and more than 500 semantic rules. It is a design close to a general-purpose programming language, and it does not directly provide semantics related to system resource division. Developers need to design and develop again on the AADL framework, and the learning cost is relatively high.
  • the main purpose of the embodiments of the present application is to provide a method, device, electronic device and medium for generating system resource allocation codes, which can improve the scalability and flexibility of system resource allocation, and have low learning costs.
  • the embodiment of the present application provides a method for generating system resource allocation code, including: according to the predefined metastructure used to describe the components in the operating system, obtain the instance generated by each component during the instantiation process generation information; according to the instantiation information of each component and the preset code template corresponding to the component type, generate the allocation code of each component, and obtain the system resource allocation code.
  • the embodiment of the present application also provides a system resource allocation code generation device, including: an information acquisition module, used to acquire the components in the instance The instantiation information generated in the process of instantiation; the generation module is used to generate the allocation code of each component according to the instantiation information of each component and the preset code template corresponding to the component type, so as to obtain the system resource allocation code.
  • a system resource allocation code generation device including: an information acquisition module, used to acquire the components in the instance The instantiation information generated in the process of instantiation; the generation module is used to generate the allocation code of each component according to the instantiation information of each component and the preset code template corresponding to the component type, so as to obtain the system resource allocation code.
  • an embodiment of the present application further provides an electronic device, including: at least one processor; and a memory connected to the at least one processor in communication; wherein, the memory stores information that can be used by the at least one processor An instruction executed by a processor, the instruction is executed by the at least one processor, so that the at least one processor can execute the above method for generating system resource allocation code.
  • the embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above-mentioned method for generating the system resource allocation code is implemented.
  • FIG. 1 is a flowchart of a method for generating system resource allocation codes according to an embodiment of the present invention
  • Fig. 2 is a flowchart of a method for defining a component metastructure provided according to an embodiment of the present invention
  • Fig. 3 is a working flow diagram of a CDL compiler provided according to an embodiment of the present invention.
  • FIG. 4 is a structural diagram of system resource allocation code generation provided according to an embodiment of the present invention.
  • FIG. 5 is a flowchart of a method for generating system resource allocation codes according to another embodiment of the present invention.
  • FIG. 6 is a schematic diagram of an apparatus for generating system resource allocation codes according to another embodiment of the present invention.
  • Fig. 7 is a schematic structural diagram of an electronic device according to another embodiment of the present invention.
  • An embodiment of the present invention relates to a method for generating system resource allocation codes, which is applied to servers.
  • the specific implementation flowchart of the generation method of the system resource allocation code of the present embodiment is as shown in Figure 1, at least includes the following steps:
  • Step 101 according to the predefined metastructure used to describe the components in the operating system, obtain the instantiation information generated by each component during the instantiation process.
  • step 102 according to the instantiation information of each component and the preset code template corresponding to the component type, the allocation code of each component is generated to obtain the system resource allocation code.
  • the instantiation information generated by each component of the system during the instantiation process is obtained, and then according to the generated instantiation information of each component and the preset
  • the code template corresponding to the component type is used to generate the allocation code of each component of the system, that is, the system resource allocation code is obtained.
  • the meta structure used to describe the components in the operating system and the pre-set code templates corresponding to the component types when adding a description of the resources required by a component, only the meta of the new component needs to be pre-defined
  • the structure and pre-set the code template corresponding to the component type of the new component which improves the scalability and flexibility of system resource allocation, and can automatically generate system resource allocation code without redesigning and developing on the AADL framework, learning The cost is lower.
  • step 101 the server obtains the instantiation information generated by each component during the instantiation process according to the predefined metastructure used to describe the components in the operating system.
  • the accessible address space in the operating system can be used as a global resource, and a special language, namely Component Description Language (CDL), can be designed to describe the metastructure of each component in the operating system, so as to predict Defines the metastructure of components in the operating system. Then instantiate the component. During the instantiation process, the instantiation information of the component will be generated, that is, the relevant information of the metastructure of the component, for example, the ID name of the metastructure of the component, the specific value of the memory space occupied by the component, etc. .
  • CDL Component Description Language
  • the metastructure of the component includes: a unique identifier, component meta properties, initialized fixed properties and runtime variable properties.
  • Fig. 2 is a flowchart of a method for defining a metastructure of a component, specifically including:
  • S201 define an identity identification number (Identity document, ID) of the component.
  • ID is used to describe the unique identification of the component.
  • the component meta-attribute includes: the memory location of the component and/or the occupied memory size.
  • the initialized fixed attributes include one of the following or any combination thereof: the stack used by the system task, the base priority, and the entry address.
  • variable attributes at runtime include: the running priority of the system task.
  • step 102 the server generates allocation codes for each component according to the instantiation information generated during the instantiation process and a preset code template corresponding to the component type to obtain system resource allocation codes.
  • the instantiation information generated during the instantiation process is translated into machine recognition code according to the preset translation rules, and then the preset code template is matched with the component type of the component to obtain the code template, and fill in the machine identification code into the code template corresponding to the component type, and finally generate the allocation code of each component to obtain the system resource allocation code.
  • the code template is a code template provided according to a programming language, such as C language. Since the code template only contains the basic programming language framework and does not contain the instantiation information of the component, it is necessary to translate the instantiation information into the programming language according to the preset translation rules, that is, after the machine recognizes the code, fill in the machine recognition code In the code template of the programming language, the missing information of the code template is supplemented, the allocation code of each component is generated, and the system resource allocation code is obtained.
  • a programming language such as C language. Since the code template only contains the basic programming language framework and does not contain the instantiation information of the component, it is necessary to translate the instantiation information into the programming language according to the preset translation rules, that is, after the machine recognizes the code, fill in the machine recognition code
  • the missing information of the code template is supplemented, the allocation code of each component is generated, and the system resource allocation code is obtained.
  • system resource allocation code needs to be generated to generate a loadable execution image and execute the loadable execution image
  • the resource description of the component that is, the instantiation information of the component is not a kind of machine identification code, so , the instantiation information of each component needs different translation rules to translate it into machine recognition code, and then fill the machine recognition code into the code template corresponding to the component type, wherein the translation rules need to be pre-defined according to the component type.
  • CDL compiler CDLompiler
  • Figure 3 is the workflow diagram of CDLCompiler.
  • the specific implementation process of CDLCompiler includes:
  • the CDLCompiler parses the translation rules.
  • the system resource allocation code is combined with the implementation code of the system component to generate a loadable execution image, that is, a final executable program.
  • the implementation code of the system components includes: the core code of the system and the user code.
  • the structure diagram generated by the system resource allocation code of this embodiment can be shown in Figure 4, wherein component.tr is the translation rule, component.cdl is the instantiation information of the component, and init.c is the system resource allocation Code, the OS component is the implementation code of the system component, (Executable and Linking Format, ELFImage) is the loadable execution image of the system.
  • component.tr is the translation rule
  • component.cdl is the instantiation information of the component
  • init.c is the system resource allocation Code
  • the OS component is the implementation code of the system component
  • ELFImage Executable and Linking Format
  • a tool is used to automatically generate system resource allocation code, avoiding handwritten code An error occurs that affects the health of the system.
  • step division of the above various methods is only for the sake of clarity of description. During implementation, it can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. ; Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but not changing the core design of the algorithm and process are all within the scope of protection of this patent.
  • FIG. 5 is a flow chart of the generation method of the system resource allocation code described in this embodiment, which at least includes the following steps:
  • Step 501 according to the predefined metastructure used to describe the components in the operating system, obtain the instantiation information generated by each component during the instantiation process.
  • step 501 is substantially the same as step 101, and will not be repeated here.
  • Step 502 according to the instantiation information of each component, check the rationality of the instantiation information of each component.
  • the server traverses the resources required by each component according to the acquired instantiation information of each component, and detects the memory space occupied by each component. There is no overlap in the memory space occupied by each component, and If the maximum value and the minimum value of the memory space of each component are within the legal range, the rationality test is passed.
  • the legal range is the range specified by the system. According to the instantiation information of each component, the resources required by each component can be obtained, and then the memory space occupied by each component is detected to obtain the resource allocation of the system, so as to judge whether the allocation is reasonable according to the system regulations.
  • Step 503 after passing the rationality test, execute to generate the distribution code of each component according to the instantiation information of each component and the preset code template corresponding to the component type.
  • the code template corresponding to the component type generates the allocation code of each component, and obtains the system resource allocation code, so as to achieve the purpose of rational allocation of system resources and make the system run normally.
  • system resources are allocated according to the operating status of the system. This way of dynamically allocating system resources will affect the predictability and stability of the system. Allocate resources for each component, that is, statically allocate resources, and rationalize the instantiation information of each component before generating the allocation code of each component according to the instantiation information of each component and the preset code template corresponding to the component type Detection can identify unreasonable resource allocation before the system runs, avoiding the influence of unreasonable system resource allocation on the operating status of the system, and improving the predictability and stability of the system.
  • step division of the above various methods is only for the sake of clarity of description. During implementation, it can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. ; Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but not changing the core design of the algorithm and process are all within the scope of protection of this patent.
  • FIG. 6 is a schematic diagram of a system resource allocation code generation device described in this embodiment, including: an information acquisition module 601 and a generation module 602 .
  • the information acquiring module 601 is configured to acquire the instantiation information generated by each component during the instantiation process according to the predefined metastructure used to describe the components in the operating system.
  • the generating module 602 is configured to generate allocation codes of each component according to the instantiation information of each component and a preset code template corresponding to the component type, so as to obtain the system resource allocation code.
  • the generation module 602 is further configured to translate the instantiation information into machine identification codes according to preset translation rules; and fill the machine identification codes into the code template corresponding to the component type.
  • the generation module 602 is further configured to, after obtaining the system resource allocation code, combine the system resource allocation code with the implementation code of the system component to generate a loadable execution image.
  • the generation module 602 is further configured to generate the distribution code of each component according to the instantiation information of each component and the preset code template corresponding to the component type, The instantiation information of each component is checked for rationality; after passing the reasonableness check, the allocation code of each component is generated according to the instantiation information of each component and the preset code template corresponding to the component type.
  • this embodiment is an apparatus embodiment corresponding to the above method embodiment, and this embodiment can be implemented in cooperation with the above method embodiment.
  • the relevant technical details and technical effects mentioned in the above embodiments are still valid in this embodiment, and will not be repeated here to reduce repetition.
  • the relevant technical details mentioned in this embodiment can also be applied in the above embodiments.
  • modules involved in this embodiment are logical modules.
  • a logical unit can be a physical unit, or a part of a physical unit, or multiple physical units. Combination of units.
  • units that are not closely related to solving the technical problem proposed by the present invention are not introduced in this embodiment, but this does not mean that there are no other units in this embodiment.
  • FIG. 7 Another embodiment of the present invention relates to an electronic device, as shown in FIG. 7 , including: at least one processor 701; and a memory 702 communicatively connected to the at least one processor 701; wherein, the memory 702 stores An instruction that can be executed by the at least one processor 701, the instruction is executed by the at least one processor 701, so that the at least one processor 701 can execute the system resource allocation code method in each of the foregoing embodiments.
  • the memory and the processor are connected by a bus
  • the bus may include any number of interconnected buses and bridges, and the bus connects one or more processors and various circuits of the memory together.
  • the bus may also connect together various other circuits such as peripherals, voltage regulators, and power management circuits, all of which are well known in the art and therefore will not be further described herein.
  • the bus interface provides an interface between the bus and the transceivers.
  • a transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing means for communicating with various other devices over a transmission medium.
  • the data processed by the processor is transmitted on the wireless medium through the antenna, further, the antenna also receives the data and transmits the data to the processor.
  • the processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Instead, memory can be used to store data that the processor uses when performing operations.
  • Another embodiment of the present invention relates to a computer-readable storage medium storing a computer program.
  • the above method embodiments are implemented when the computer program is executed by the processor.
  • a storage medium includes several instructions to make a device ( It may be a single-chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc., which can store program codes. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiments of the present invention relate to the technical field of embedded systems. Disclosed are a method and apparatus for generating a system resource allocation code, and an electronic device and a medium. The method for generating a system resource allocation code comprises: according to a predefined meta-structure for describing components in an operating system, acquiring instantiation information, which is generated by each component during an instantiation process; and according to the instantiation information of each component and a preset code template corresponding to a component type, generating an allocation code for each component, so as to obtain a system resource allocation code.

Description

系统资源分配代码的生成方法、装置、电子设备和介质Method, device, electronic device and medium for generating system resource allocation code 技术领域technical field
本申请实施例涉及嵌入式系统技术领域,特别涉及一种系统资源分配代码的生成方法、装置、电子设备和介质。The embodiments of the present application relate to the technical field of embedded systems, and in particular to a method, device, electronic device and medium for generating system resource allocation codes.
背景技术Background technique
操作系统内核一般指的是硬件无关的部分,在实际移植到某个特定单板硬件时,需要与板级支持包(Board Support Package,BSP)以及用户代码一起进行链接加载。由于操作系统核心以外的代码错误有可能引发整个系统的崩溃,在一些关键领域如航空器上是不可接受的。因此,操作系统目前都会需要用户提供手写的初始化代码和初始配置,然而这种方式容易由于笔误、理解错误、配置不合理等多种原因导致后续系统运行时出现错误,且该类错误一般都不是第一现场,较难排查。The operating system kernel generally refers to the hardware-independent part. When it is actually ported to a specific single-board hardware, it needs to be linked and loaded together with the Board Support Package (Board Support Package, BSP) and user code. It is unacceptable in some critical areas such as aircraft because code errors outside the core of the operating system may cause the collapse of the entire system. Therefore, the operating system currently requires users to provide handwritten initialization codes and initial configurations. However, this method is prone to errors during subsequent system operation due to various reasons such as clerical errors, misunderstandings, and unreasonable configurations, and such errors are generally not The first scene is more difficult to investigate.
目前,业界常见的做法是通过一种约定好的格式,如可扩展标记语言(Extensible Markup Language,XML)来描述系统的配置,生成相关的配置数据,在系统运行时进行配置解析和应用,以实现系统资源的分配;第二种方式是根据系统架构演进(System Architecture Evolution,SAE)提出的架构分析和设计语言(Architecture Analysis and Design Language,AADL)语言来描述系统抽象模型,最终进行系统资源的分配。At present, the common practice in the industry is to describe the configuration of the system through an agreed format, such as Extensible Markup Language (XML), generate relevant configuration data, and analyze and apply the configuration when the system is running. Realize the allocation of system resources; the second way is to describe the abstract model of the system according to the Architecture Analysis and Design Language (AADL) language proposed by System Architecture Evolution (SAE), and finally carry out the allocation of system resources. distribute.
然而,上述第一种方式要求用户和操作系统(Operating System)双方按照同一种模板填写配置,若增加一种新的资源的描述,则需要变动配置模板与相关的解析代码,扩展性和灵活性较差。上述第二种方式中的AADL本身非常庞大和复杂,具有185种语法规则以及500多条语义规则,是一种接近于通用编程语言的设计,其并不直接提供和系统资源划分相关的语义,需要开发者在AADL框架之上再次设计开发,学习成本较高。However, the first method above requires both the user and the operating system (Operating System) to fill in the configuration according to the same template. If a new resource description is added, the configuration template and related parsing code need to be changed to achieve scalability and flexibility. poor. The AADL in the above-mentioned second method is very large and complex, with 185 grammatical rules and more than 500 semantic rules. It is a design close to a general-purpose programming language, and it does not directly provide semantics related to system resource division. Developers need to design and develop again on the AADL framework, and the learning cost is relatively high.
发明内容Contents of the invention
本申请实施例的主要目的在于提出一种系统资源分配代码的生成方法、装置、电子设备和介质,可以提高系统资源分配的扩展性和灵活性,并且学习成本较低。The main purpose of the embodiments of the present application is to provide a method, device, electronic device and medium for generating system resource allocation codes, which can improve the scalability and flexibility of system resource allocation, and have low learning costs.
为实现上述目的,本申请实施例提供了一种系统资源分配代码的生成方法,包括:根据预定义的用于描述操作系统中的组件的元结构,获取各组件在实例化过程中生成的实例化信息;根据所述各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成所述各组件的分配代码,得到系统资源分配代码。In order to achieve the above purpose, the embodiment of the present application provides a method for generating system resource allocation code, including: according to the predefined metastructure used to describe the components in the operating system, obtain the instance generated by each component during the instantiation process generation information; according to the instantiation information of each component and the preset code template corresponding to the component type, generate the allocation code of each component, and obtain the system resource allocation code.
为实现上述目的,本申请实施例还提供一种系统资源分配代码的生成装置,包括:信息获取模块,用于根据预定义的用于描述操作系统中的组件的元结构,获取各组件在实例化过程中生成的实例化信息;生成模块,用于根据所述各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成所述各组件的分配代码,得到系统资源分配代码。In order to achieve the above purpose, the embodiment of the present application also provides a system resource allocation code generation device, including: an information acquisition module, used to acquire the components in the instance The instantiation information generated in the process of instantiation; the generation module is used to generate the allocation code of each component according to the instantiation information of each component and the preset code template corresponding to the component type, so as to obtain the system resource allocation code.
为实现上述目的,本申请实施例还提供了一种电子设备,包括:至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述的系统资源分配代码的生成方法。To achieve the above purpose, an embodiment of the present application further provides an electronic device, including: at least one processor; and a memory connected to the at least one processor in communication; wherein, the memory stores information that can be used by the at least one processor An instruction executed by a processor, the instruction is executed by the at least one processor, so that the at least one processor can execute the above method for generating system resource allocation code.
为实现上述目的,本申请实施例还提供了一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时实现上述的系统资源分配代码的生成方法。To achieve the above purpose, the embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above-mentioned method for generating the system resource allocation code is implemented.
附图说明Description of drawings
一个或多个实施例通过与之对应的附图中的图片进行示例性说明,这些示例性说明并不构成对实施例的限定,附图中具有相同参考数字标识的元件表示为类似的元件,除非有特别的申明,附图中的图不构成比例限制。One or more embodiments are exemplified by corresponding pictures in the drawings, and these exemplifications do not constitute a limitation to the embodiments, and elements with the same reference numerals in the drawings represent similar elements, Unless otherwise stated, the drawings in the drawings are not limited to scale.
图1是根据本发明一个实施例提供的一种系统资源分配代码的生成方法流程图;FIG. 1 is a flowchart of a method for generating system resource allocation codes according to an embodiment of the present invention;
图2是根据本发明一个实施例提供的一种组件元结构的定义方法的流程图;Fig. 2 is a flowchart of a method for defining a component metastructure provided according to an embodiment of the present invention;
图3是根据本发明一个实施例提供的一种CDL编译器的工作流程图;Fig. 3 is a working flow diagram of a CDL compiler provided according to an embodiment of the present invention;
图4是根据本发明一个实施例提供的一种系统资源分配代码生成的结构图;FIG. 4 is a structural diagram of system resource allocation code generation provided according to an embodiment of the present invention;
图5是根据本发明另一个实施例提供的一种系统资源分配代码的生成方法流程图;FIG. 5 is a flowchart of a method for generating system resource allocation codes according to another embodiment of the present invention;
图6是根据本发明另一个实施例提供的一种系统资源分配代码的生成装置的示意图;FIG. 6 is a schematic diagram of an apparatus for generating system resource allocation codes according to another embodiment of the present invention;
图7是根据本发明另一个实施例的电子设备的结构示意图。Fig. 7 is a schematic structural diagram of an electronic device according to another embodiment of the present invention.
具体实施方式Detailed ways
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请的各实施例进行详细的阐述。然而,本领域的普通技术人员可以理解,在本申请各实施例中,为了使读者更好地理解本申请而提出了许多技术细节。但是,即使没有这些技术细节和基于以下各实施例的种种变化和修改,也可以实现本申请所要求保护的技术方案。以下各个实施例的划分是为了描述方便,不应对本申请的具体实现方式构成任何限定,各个实施例在不矛盾的前提下可以相互结合相互引用。In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below with reference to the accompanying drawings. However, those of ordinary skill in the art can understand that in each embodiment of the application, many technical details are provided for readers to better understand the application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in this application can also be realized. The division of the following embodiments is for the convenience of description, and should not constitute any limitation to the specific implementation of the present application, and the embodiments can be combined and referred to each other on the premise of no contradiction.
本发明的一个实施例涉及一种系统资源分配代码的生成方法,应用于服务器。本实施 例的系统资源分配代码的生成方法的具体实现流程图如图1所示,至少包括以下步骤:An embodiment of the present invention relates to a method for generating system resource allocation codes, which is applied to servers. The specific implementation flowchart of the generation method of the system resource allocation code of the present embodiment is as shown in Figure 1, at least includes the following steps:
步骤101,根据预定义的用于描述操作系统中的组件的元结构,获取各组件在实例化过程中生成的实例化信息。 Step 101, according to the predefined metastructure used to describe the components in the operating system, obtain the instantiation information generated by each component during the instantiation process.
步骤102,根据各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成各组件的分配代码,得到系统资源分配代码。In step 102, according to the instantiation information of each component and the preset code template corresponding to the component type, the allocation code of each component is generated to obtain the system resource allocation code.
本实施例中,根据预定义的用于描述操作系统中的组件的元结构,获取系统的各组件在实例化过程中生成的实例化信息,然后根据生成的各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成系统的各组件的分配代码,即得到系统资源分配代码。通过预定义用于描述操作系统中的组件的元结构和预先设置的与组件类型对应的代码模板,使得在新增一种组件所需资源的描述时,只需要预先定义该新增组件的元结构和预先设置与该新增组件的组件类型对应的代码模板,提高了系统资源分配的扩展性和灵活性,并且无需在AADL框架之上再次设计开发,即可自动生成系统资源分配代码,学习成本较低。In this embodiment, according to the predefined metastructure used to describe the components in the operating system, the instantiation information generated by each component of the system during the instantiation process is obtained, and then according to the generated instantiation information of each component and the preset The code template corresponding to the component type is used to generate the allocation code of each component of the system, that is, the system resource allocation code is obtained. By predefining the meta structure used to describe the components in the operating system and the pre-set code templates corresponding to the component types, when adding a description of the resources required by a component, only the meta of the new component needs to be pre-defined The structure and pre-set the code template corresponding to the component type of the new component, which improves the scalability and flexibility of system resource allocation, and can automatically generate system resource allocation code without redesigning and developing on the AADL framework, learning The cost is lower.
下面对本实施例的系统资源分配代码的生成方法的实现细节进行具体的说明,以下内容仅为方便理解提供的实现细节,并非实施本方案的必须。The implementation details of the method for generating system resource allocation codes in this embodiment are described in detail below. The following content is only implementation details provided for easy understanding, and is not necessary for implementing this solution.
在步骤101中,服务器会根据预定义的用于描述操作系统中的组件的元结构,获取各组件在实例化过程中生成的实例化信息。In step 101, the server obtains the instantiation information generated by each component during the instantiation process according to the predefined metastructure used to describe the components in the operating system.
具体地,可以将操作系统中可访问的地址空间作为一种全局资源,设计一种专用语言,即组件描述语言(Component Description Language,CDL),来描述操作系统中各组件的元结构,以预先定义操作系统中各组件的元结构。然后对组件进行实例化,在实例化过程中会产生该组件的实例化信息,即组件的元结构的相关信息,例如,组件的元结构的ID名称,组件所占用的内存空间的具体值等。Specifically, the accessible address space in the operating system can be used as a global resource, and a special language, namely Component Description Language (CDL), can be designed to describe the metastructure of each component in the operating system, so as to predict Defines the metastructure of components in the operating system. Then instantiate the component. During the instantiation process, the instantiation information of the component will be generated, that is, the relevant information of the metastructure of the component, for example, the ID name of the metastructure of the component, the specific value of the memory space occupied by the component, etc. .
其中,组件的元结构包括:唯一标识、组件元属性、初始化的固定属性和运行时的可变属性。图2为组件的元结构的定义方法的流程图,具体包括:Among them, the metastructure of the component includes: a unique identifier, component meta properties, initialized fixed properties and runtime variable properties. Fig. 2 is a flowchart of a method for defining a metastructure of a component, specifically including:
S201,定义组件的身份标识号(Identity document,ID)。S201, define an identity identification number (Identity document, ID) of the component.
其中,ID用以描述组件的唯一标识。Among them, ID is used to describe the unique identification of the component.
S202,定义组件的元属性。S202, defining meta properties of the component.
其中,组件元属性包括:组件所处内存的位置和/或所占用的内存大小。Wherein, the component meta-attribute includes: the memory location of the component and/or the occupied memory size.
S203,定义组件初始化的固定属性。S203, define fixed attributes for component initialization.
其中,初始化的固定属性包括以下之一或其任意组合:系统任务所使用的堆栈,基础优先级,入口地址。Wherein, the initialized fixed attributes include one of the following or any combination thereof: the stack used by the system task, the base priority, and the entry address.
S204,定义组件运行时的可变属性。S204, define variable properties of the component during runtime.
其中,运行时的可变属性包括:系统任务的运行优先级。Wherein, the variable attributes at runtime include: the running priority of the system task.
在具体的计算机实现中,需要按照图2中所示方法定义的组件的元结构进行组件的实例化,即首先实例化组件的唯一标识,然后实例化组件的元属性,接着实例化组件初始化的固定属性,最后实例化组件运行时的可变属性。In a specific computer implementation, it is necessary to instantiate the component according to the metastructure of the component defined in the method shown in Figure 2, that is, first instantiate the unique identifier of the component, then instantiate the meta-property of the component, and then instantiate the initialization of the component Fixed properties, variable properties when the component is finally instantiated at runtime.
在步骤102中,服务器根据实例化过程中生成的实例化信息和预先设置的与组件类型对应的代码模板,生成各组件的分配代码,得到系统资源分配代码。In step 102, the server generates allocation codes for each component according to the instantiation information generated during the instantiation process and a preset code template corresponding to the component type to obtain system resource allocation codes.
具体地,首先根据预设的翻译规则将实例化过程中生成的实例化信息翻译为机器识别代码,然后将预先设置的代码模板与该组件的组件类型进行匹配,得到与该组件的组件类型对应的代码模板,并将机器识别代码填入与组件类型对应的代码模板,最终生成各组件的分配代码,得到系统资源分配代码。Specifically, firstly, the instantiation information generated during the instantiation process is translated into machine recognition code according to the preset translation rules, and then the preset code template is matched with the component type of the component to obtain the code template, and fill in the machine identification code into the code template corresponding to the component type, and finally generate the allocation code of each component to obtain the system resource allocation code.
其中,代码模板是根据一种程序语言,例如C语言,所提供的代码模板。由于代码模板只包含基础的程序语言框架,不包含组件的实例化信息,因此,需要将实例化信息根据预设的翻译规则翻译为该程序语言,即机器识别代码之后,将机器识别代码填入该程序语言的代码模板中,补充代码模板所缺失的信息,生成各组件的分配代码,得到系统资源分配代码。Wherein, the code template is a code template provided according to a programming language, such as C language. Since the code template only contains the basic programming language framework and does not contain the instantiation information of the component, it is necessary to translate the instantiation information into the programming language according to the preset translation rules, that is, after the machine recognizes the code, fill in the machine recognition code In the code template of the programming language, the missing information of the code template is supplemented, the allocation code of each component is generated, and the system resource allocation code is obtained.
在一个例子中,由于需要生成系统资源分配代码,以生成可加载执行镜像,并执行该可加载执行镜像,而对于组件的资源描述,即组件的实例化信息并不是一种机器识别代码,因此,每一种组件的实例化信息需要不同的翻译规则来将其翻译为机器识别代码,然后将机器识别代码填入与组件类型对应的代码模板,其中,翻译规则需要根据组件类型预先定义。In one example, since system resource allocation code needs to be generated to generate a loadable execution image and execute the loadable execution image, the resource description of the component, that is, the instantiation information of the component is not a kind of machine identification code, so , the instantiation information of each component needs different translation rules to translate it into machine recognition code, and then fill the machine recognition code into the code template corresponding to the component type, wherein the translation rules need to be pre-defined according to the component type.
具体实现中,通过CDL编译器(CDLCompiler)工具将实例化信息根据预先为每个组件定义的翻译规则转换为机器识别代码,并将机器识别代码填入与组件类型对应的代码模板,最终生成各组件的分配代码,得到系统资源分配代码。图3为CDLCompiler的工作流程图,CDLCompiler的具体实现流程包括:In the specific implementation, the CDL compiler (CDLCompiler) tool is used to convert the instantiation information into machine identification code according to the translation rules defined in advance for each component, and fill the machine identification code into the code template corresponding to the component type, and finally generate each The allocation code of the component is used to obtain the system resource allocation code. Figure 3 is the workflow diagram of CDLCompiler. The specific implementation process of CDLCompiler includes:
S301,CDLCompiler解析翻译规则。S301. The CDLCompiler parses the translation rules.
其中,解析翻译规则的具体流程为:Among them, the specific process of parsing translation rules is as follows:
(1)对翻译规则进行语法和语义分析;(1) Perform grammatical and semantic analysis on the translation rules;
(2)对翻译规则的类型进行检查,得到中间表达。(2) Check the type of the translation rule to obtain the intermediate expression.
S302,根据翻译规则解释并执行组件的实例化信息,得到机器识别代码。S302. Interpret and execute the instantiation information of the component according to the translation rule to obtain the machine identification code.
S303,根据机器识别代码和与组件类型对应的代码模板,生成各组件的分配代码,得到系统资源分配代码。S303, according to the machine identification code and the code template corresponding to the component type, generate the allocation code of each component, and obtain the system resource allocation code.
在一个例子中,在得到系统资源分配代码后,将系统资源分配代码结合系统组件的实现代码,生成可加载执行镜像,即最终的可运行程序。其中,系统组件的实现代码包括:系统的核心代码与用户代码。通过执行该可加载执行镜像,即可实现系统资源的分配。In one example, after the system resource allocation code is obtained, the system resource allocation code is combined with the implementation code of the system component to generate a loadable execution image, that is, a final executable program. Wherein, the implementation code of the system components includes: the core code of the system and the user code. By executing the loadable execution image, the allocation of system resources can be realized.
在一个例子中,本实施例的系统资源分配代码生成的结构图可以如图4所示,其中,component.tr为翻译规则,component.cdl为组件的实例化信息,init.c为系统资源分配代码,OS组件为系统组件的实现代码,(Executable and Linking Format,ELFImage)为系统的可加载执行镜像。In one example, the structure diagram generated by the system resource allocation code of this embodiment can be shown in Figure 4, wherein component.tr is the translation rule, component.cdl is the instantiation information of the component, and init.c is the system resource allocation Code, the OS component is the implementation code of the system component, (Executable and Linking Format, ELFImage) is the loadable execution image of the system.
需要说明的是,本实施方式中的上述各示例均为方便理解进行的举例说明,并不对本发明的技术方案构成限定。It should be noted that, the above-mentioned examples in this embodiment are illustrations for easy understanding, and do not limit the technical solution of the present invention.
本实施例中,在根据预定义的用于描述操作系统中的组件的元结构,获取各组件在实例化过程中生成的实例化信息之后,采用工具自动生成系统资源分配代码,避免了手写代码时出现错误,从而影响到系统的运行状况。In this embodiment, after obtaining the instantiation information generated by each component during the instantiation process according to the predefined metastructure used to describe the components in the operating system, a tool is used to automatically generate system resource allocation code, avoiding handwritten code An error occurs that affects the health of the system.
上面各种方法的步骤划分,只是为了描述清楚,实现时可以合并为一个步骤或者对某些步骤进行拆分,分解为多个步骤,只要包括相同的逻辑关系,都在本专利的保护范围内;对算法中或者流程中添加无关紧要的修改或者引入无关紧要的设计,但不改变其算法和流程的核心设计都在该专利的保护范围内。The step division of the above various methods is only for the sake of clarity of description. During implementation, it can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. ; Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but not changing the core design of the algorithm and process are all within the scope of protection of this patent.
本发明的另一个实施例涉及一种系统资源分配代码的生成方法,下面对本实施例的系统资源分配代码的生成方法的实现细节进行具体的说明,以下内容仅为方便理解提供的实现细节,并非实施本方案的必须,图5是本实施例所述的系统资源分配代码的生成方法的流程图,至少包括以下步骤:Another embodiment of the present invention relates to a method for generating system resource allocation codes. The implementation details of the method for generating system resource allocation codes in this embodiment are described in detail below. It is necessary to implement this solution, and Fig. 5 is a flow chart of the generation method of the system resource allocation code described in this embodiment, which at least includes the following steps:
步骤501,根据预定义的用于描述操作系统中的组件的元结构,获取各组件在实例化过程中生成的实例化信息。 Step 501, according to the predefined metastructure used to describe the components in the operating system, obtain the instantiation information generated by each component during the instantiation process.
其中,步骤501与步骤101大致相同,此处不再赘述。Wherein, step 501 is substantially the same as step 101, and will not be repeated here.
步骤502,根据各组件的实例化信息,对各组件的实例化信息进行合理性检测。 Step 502, according to the instantiation information of each component, check the rationality of the instantiation information of each component.
具体而言,服务器根据获取的各组件的实例化信息,对各组件所需的资源进行遍历,对各组件所占的内存空间进行检测,在各组件所占的内存空间不存在重叠部分,且各组件的内存空间的最大值和最小值均在合法范围内的情况下,通过所述合理性检测。其中,合法范围为系统所规定的范围。根据各组件的实例化信息可以得到各组件所需的资源,然后 对各组件所占的内存空间进行检测,得到系统的资源分配情况,以根据系统的规定判断该分配情况是否合理。Specifically, the server traverses the resources required by each component according to the acquired instantiation information of each component, and detects the memory space occupied by each component. There is no overlap in the memory space occupied by each component, and If the maximum value and the minimum value of the memory space of each component are within the legal range, the rationality test is passed. Wherein, the legal range is the range specified by the system. According to the instantiation information of each component, the resources required by each component can be obtained, and then the memory space occupied by each component is detected to obtain the resource allocation of the system, so as to judge whether the allocation is reasonable according to the system regulations.
步骤503,通过合理性检测后,执行根据各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成各组件的分配代码。 Step 503 , after passing the rationality test, execute to generate the distribution code of each component according to the instantiation information of each component and the preset code template corresponding to the component type.
具体而言,若各组件的内存空间的最大值和最小值均在合法范围内,则表明各组件的实例化信息通过了合理性检测,因此,会执行根据各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成各组件的分配代码,得到系统资源分配代码,达到合理分配系统资源的目的,使系统可以正常运行。Specifically, if the maximum and minimum values of the memory space of each component are within the legal range, it indicates that the instantiation information of each component has passed the rationality test. The code template corresponding to the component type generates the allocation code of each component, and obtains the system resource allocation code, so as to achieve the purpose of rational allocation of system resources and make the system run normally.
在一个例子中,若各组件的内存空间的最大值和最小值和/或不在合法范围内,则表明各组件的实例化信息没有通过合理性检测,因此,不会执行根据各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成各组件的分配代码的操作,避免系统资源分配不合理。In one example, if the maximum value and the minimum value of the memory space of each component and/or are not within the legal range, it indicates that the instantiation information of each component has not passed the rationality check, therefore, the instantiation information according to each component will not be executed Information and pre-set code templates corresponding to component types generate the operation of the allocation code of each component to avoid unreasonable allocation of system resources.
在相关技术中,根据系统的运行状态进行系统资源的分配,这种动态分配系统资源的方式会影响系统的可预测性和稳定性,而本实施例中,通过在系统运行之前预先为系统的各组件分配资源,即对资源进行静态分配,并且在根据各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成各组件的分配代码之前,对组件的实例化信息进行合理性检测,可以对不合理的资源分配在系统运行之前就识别出,避免了由于系统资源分配不合理影响系统的运行状况,提高了系统的可预测性和稳定性。In related technologies, system resources are allocated according to the operating status of the system. This way of dynamically allocating system resources will affect the predictability and stability of the system. Allocate resources for each component, that is, statically allocate resources, and rationalize the instantiation information of each component before generating the allocation code of each component according to the instantiation information of each component and the preset code template corresponding to the component type Detection can identify unreasonable resource allocation before the system runs, avoiding the influence of unreasonable system resource allocation on the operating status of the system, and improving the predictability and stability of the system.
上面各种方法的步骤划分,只是为了描述清楚,实现时可以合并为一个步骤或者对某些步骤进行拆分,分解为多个步骤,只要包括相同的逻辑关系,都在本专利的保护范围内;对算法中或者流程中添加无关紧要的修改或者引入无关紧要的设计,但不改变其算法和流程的核心设计都在该专利的保护范围内。The step division of the above various methods is only for the sake of clarity of description. During implementation, it can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. ; Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but not changing the core design of the algorithm and process are all within the scope of protection of this patent.
本发明的另一个实施例涉及一种系统资源分配代码的生成装置,下面对本实施例的系统资源分配代码的生成装置的细节进行具体的说明,以下内容仅为方便理解提供的实现细节,并非实施本例的必须,图6是本实施例所述的系统资源分配代码的生成装置的示意图,包括:信息获取模块601和生成模块602。Another embodiment of the present invention relates to a device for generating system resource allocation codes. The details of the device for generating system resource allocation codes in this embodiment are described in detail below. The following content is only implementation details provided for easy understanding, not implementation Needless to this example, FIG. 6 is a schematic diagram of a system resource allocation code generation device described in this embodiment, including: an information acquisition module 601 and a generation module 602 .
具体而言,信息获取模块601,用于根据预定义的用于描述操作系统中的组件的元结构,获取各组件在实例化过程中生成的实例化信息。Specifically, the information acquiring module 601 is configured to acquire the instantiation information generated by each component during the instantiation process according to the predefined metastructure used to describe the components in the operating system.
生成模块602,用于根据各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成各组件的分配代码,得到系统资源分配代码。The generating module 602 is configured to generate allocation codes of each component according to the instantiation information of each component and a preset code template corresponding to the component type, so as to obtain the system resource allocation code.
在一个例子中,生成模块602还用于根据预设的翻译规则,将实例化信息翻译为机器识别代码;将机器识别代码填入与组件类型对应的代码模板。In an example, the generation module 602 is further configured to translate the instantiation information into machine identification codes according to preset translation rules; and fill the machine identification codes into the code template corresponding to the component type.
在一个例子中,生成模块602还用于在得到系统资源分配代码之后,将系统资源分配代码结合系统组件的实现代码,生成可加载执行镜像。In an example, the generation module 602 is further configured to, after obtaining the system resource allocation code, combine the system resource allocation code with the implementation code of the system component to generate a loadable execution image.
在一个例子中,生成模块602还用于在根据各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成各组件的分配代码之前,根据各组件的实例化信息,对各组件的实例化信息进行合理性检测;通过合理性检测后,执行根据各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成各组件的分配代码。In one example, the generation module 602 is further configured to generate the distribution code of each component according to the instantiation information of each component and the preset code template corresponding to the component type, The instantiation information of each component is checked for rationality; after passing the reasonableness check, the allocation code of each component is generated according to the instantiation information of each component and the preset code template corresponding to the component type.
不难发现,本实施例为与上述方法实施例对应的装置实施例,本实施例可以与上述方法实施例互相配合实施。上述实施例中提到的相关技术细节和技术效果在本实施例中依然有效,为了减少重复,这里不再赘述。相应地,本实施例中提到的相关技术细节也可应用在上述实施例中。It is not difficult to find that this embodiment is an apparatus embodiment corresponding to the above method embodiment, and this embodiment can be implemented in cooperation with the above method embodiment. The relevant technical details and technical effects mentioned in the above embodiments are still valid in this embodiment, and will not be repeated here to reduce repetition. Correspondingly, the relevant technical details mentioned in this embodiment can also be applied in the above embodiments.
值得一提的是,本实施例中所涉及到的各模块均为逻辑模块,在实际应用中,一个逻辑单元可以是一个物理单元,也可以是一个物理单元的一部分,还可以以多个物理单元的组合实现。此外,为了突出本发明的创新部分,本实施例中并没有将与解决本发明所提出的技术问题关系不太密切的单元引入,但这并不表明本实施例中不存在其它的单元。It is worth mentioning that all the modules involved in this embodiment are logical modules. In practical applications, a logical unit can be a physical unit, or a part of a physical unit, or multiple physical units. Combination of units. In addition, in order to highlight the innovative part of the present invention, units that are not closely related to solving the technical problem proposed by the present invention are not introduced in this embodiment, but this does not mean that there are no other units in this embodiment.
本发明另一个实施例涉及一种电子设备,如图7所示,包括:至少一个处理器701;以及,与所述至少一个处理器701通信连接的存储器702;其中,所述存储器702存储有可被所述至少一个处理器701执行的指令,所述指令被所述至少一个处理器701执行,以使所述至少一个处理器701能够执行上述各实施例中的系统资源分配代码方法。Another embodiment of the present invention relates to an electronic device, as shown in FIG. 7 , including: at least one processor 701; and a memory 702 communicatively connected to the at least one processor 701; wherein, the memory 702 stores An instruction that can be executed by the at least one processor 701, the instruction is executed by the at least one processor 701, so that the at least one processor 701 can execute the system resource allocation code method in each of the foregoing embodiments.
其中,存储器和处理器采用总线方式连接,总线可以包括任意数量的互联的总线和桥,总线将一个或多个处理器和存储器的各种电路连接在一起。总线还可以将诸如外围设备、稳压器和功率管理电路等之类的各种其他电路连接在一起,这些都是本领域所公知的,因此,本文不再对其进行进一步描述。总线接口在总线和收发机之间提供接口。收发机可以是一个元件,也可以是多个元件,比如多个接收器和发送器,提供用于在传输介质上与各种其他装置通信的单元。经处理器处理的数据通过天线在无线介质上进行传输,进一步,天线还接收数据并将数据传送给处理器。Wherein, the memory and the processor are connected by a bus, and the bus may include any number of interconnected buses and bridges, and the bus connects one or more processors and various circuits of the memory together. The bus may also connect together various other circuits such as peripherals, voltage regulators, and power management circuits, all of which are well known in the art and therefore will not be further described herein. The bus interface provides an interface between the bus and the transceivers. A transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing means for communicating with various other devices over a transmission medium. The data processed by the processor is transmitted on the wireless medium through the antenna, further, the antenna also receives the data and transmits the data to the processor.
处理器负责管理总线和通常的处理,还可以提供各种功能,包括定时,外围接口,电压调节、电源管理以及其他控制功能。而存储器可以被用于存储处理器在执行操作时所使用的数据。The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Instead, memory can be used to store data that the processor uses when performing operations.
本发明另一个实施例涉及一种计算机可读存储介质,存储有计算机程序。计算机程序被处理器执行时实现上述方法实施例。Another embodiment of the present invention relates to a computer-readable storage medium storing a computer program. The above method embodiments are implemented when the computer program is executed by the processor.
即,本领域技术人员可以理解,实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。That is, those skilled in the art can understand that all or part of the steps in the method of the above-mentioned embodiments can be completed by instructing related hardware through a program, the program is stored in a storage medium, and includes several instructions to make a device ( It may be a single-chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc., which can store program codes. .
本领域的普通技术人员可以理解,上述各实施方式是实现本发明的具体实施例,而在实际应用中,可以在形式上和细节上对其作各种改变,而不偏离本发明的精神和范围。Those of ordinary skill in the art can understand that the above-mentioned embodiments are specific examples for realizing the present invention, and in practical applications, various changes can be made to it in form and details without departing from the spirit and spirit of the present invention. scope.

Claims (10)

  1. 一种系统资源分配代码的生成方法,其中,包括:A method for generating system resource allocation codes, including:
    根据预定义的用于描述操作系统中的组件的元结构,获取各组件在实例化过程中生成的实例化信息;Obtain the instantiation information generated by each component during the instantiation process according to the predefined metastructure used to describe the components in the operating system;
    根据所述各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成所述各组件的分配代码,得到系统资源分配代码。According to the instantiation information of each component and the preset code template corresponding to the component type, the allocation code of each component is generated to obtain the system resource allocation code.
  2. 根据权利要求1所述的系统资源分配代码的生成方法,其中,所述根据所述各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成所述各组件的分配代码,包括:The method for generating system resource allocation codes according to claim 1, wherein the generating the allocation codes of the components according to the instantiation information of the components and the preset code template corresponding to the component type includes :
    根据预设的翻译规则,将所述实例化信息翻译为机器识别代码;Translating the instantiated information into machine identification codes according to preset translation rules;
    将所述机器识别代码填入所述与组件类型对应的代码模板。Filling the machine identification code into the code template corresponding to the component type.
  3. 根据权利要求1所述的系统资源分配代码的生成方法,其中,在所述得到系统资源分配代码后,还包括:The method for generating a system resource allocation code according to claim 1, wherein, after said obtaining the system resource allocation code, further comprising:
    将所述系统资源分配代码结合系统组件的实现代码,生成可加载执行镜像。The system resource allocation code is combined with the implementation code of the system component to generate a loadable execution image.
  4. 根据权利要求1至3中任一项所述的系统资源分配代码的生成方法,其中,所述根据所述各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成所述各组件的分配代码,包括:The method for generating system resource allocation codes according to any one of claims 1 to 3, wherein said each component is generated according to the instantiation information of each component and a preset code template corresponding to the component type The component's allocation code, including:
    根据所述各组件的实例化信息,对所述各组件的实例化信息进行合理性检测;Performing a rationality check on the instantiation information of each component according to the instantiation information of each component;
    通过所述合理性检测后,执行所述根据所述各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成所述各组件的分配代码。After passing the rationality check, execute the code template corresponding to the component type according to the instantiation information of each component and the preset code template to generate the allocation code of each component.
  5. 根据权利要求4所述的系统资源分配代码的生成方法,其中,所述对所述各组件的实例化信息进行合理性检测,包括:The method for generating system resource allocation codes according to claim 4, wherein said checking the rationality of the instantiation information of said components comprises:
    根据所述各组件的实例化信息,对所述各组件所需的资源进行遍历;Traversing the resources required by the components according to the instantiation information of the components;
    对所述各组件所占的内存空间进行检测;Detecting the memory space occupied by each component;
    在所述各组件所占的内存空间不存在重叠部分,且所述各组件的内存空间的最大值和最小值均在合法范围内的情况下,通过所述合理性检测。When the memory spaces occupied by the various components do not overlap, and the maximum and minimum values of the memory spaces of the various components are both within a legal range, the rationality test is passed.
  6. 根据权利要求1至3中任一项所述的系统资源分配代码的生成方法,其中,所述组件的元结构包括:The method for generating system resource allocation code according to any one of claims 1 to 3, wherein the metastructure of the component comprises:
    唯一标识、组件元属性、初始化的固定属性和运行时的可变属性。Unique identifiers, component meta properties, fixed properties at initialization, and mutable properties at runtime.
  7. 根据权利要求6所述的系统资源分配代码的生成方法,其中,The generation method of system resource allocation code according to claim 6, wherein,
    所述组件元属性包括:组件所处内存的位置和/或所占用的内存大小;The component meta-attributes include: the memory location of the component and/or the occupied memory size;
    所述初始化的固定属性包括以下至少一种:系统任务所使用的堆栈,基础优先级,入口地址;The fixed attributes of the initialization include at least one of the following: the stack used by the system task, the base priority, and the entry address;
    所述运行时的可变属性包括:系统任务的运行优先级。The variable attributes at runtime include: the running priority of the system task.
  8. 一种系统资源分配代码的生成装置,其中,包括:A device for generating system resource allocation codes, including:
    信息获取模块,用于根据预定义的用于描述操作系统中的组件的元结构,获取各组件在实例化过程中生成的实例化信息;An information acquisition module, configured to acquire instantiation information generated by each component during the instantiation process according to a predefined metastructure used to describe the components in the operating system;
    生成模块,用于根据所述各组件的实例化信息和预先设置的与组件类型对应的代码模板,生成所述各组件的分配代码,得到系统资源分配代码。The generating module is configured to generate the allocation codes of the components according to the instantiation information of the components and the preset code templates corresponding to the component types, so as to obtain the system resource allocation codes.
  9. 一种电子设备,其中,包括:An electronic device, comprising:
    至少一个处理器;以及,at least one processor; and,
    与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如权利要求1至7中任一项所述的系统资源分配代码的生成方法。The memory stores instructions executable by the at least one processor, the instructions are executed by the at least one processor, so that the at least one processor can perform the operation described in any one of claims 1 to 7 The generation method of the system resource allocation code described above.
  10. 一种计算机可读存储介质,存储有计算机程序,其中,所述计算机程序被处理器执行时实现权利要求1至7中任一项所述的系统资源分配代码的生成方法。A computer-readable storage medium storing a computer program, wherein, when the computer program is executed by a processor, the method for generating the system resource allocation code according to any one of claims 1 to 7 is realized.
PCT/CN2022/112144 2021-11-25 2022-08-12 Method and apparatus for generating system resource allocation code, and electronic device and medium WO2023093134A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111417726.1 2021-11-25
CN202111417726.1A CN116166412A (en) 2021-11-25 2021-11-25 Method, device, electronic equipment and medium for generating system resource allocation code

Publications (1)

Publication Number Publication Date
WO2023093134A1 true WO2023093134A1 (en) 2023-06-01

Family

ID=86411957

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/112144 WO2023093134A1 (en) 2021-11-25 2022-08-12 Method and apparatus for generating system resource allocation code, and electronic device and medium

Country Status (2)

Country Link
CN (1) CN116166412A (en)
WO (1) WO2023093134A1 (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102609293A (en) * 2012-01-17 2012-07-25 深圳天源迪科信息技术股份有限公司 Method for instantiating C/C++ dynamically
US8510706B1 (en) * 2009-09-04 2013-08-13 The Mathworks, Inc. Generating comments for code generated from a model
CN104932905A (en) * 2015-07-14 2015-09-23 北京神舟航天软件技术有限公司 Automatic code generation method from AADL to C language
CN105094973A (en) * 2015-07-31 2015-11-25 上海卫星工程研究所 ADA program partition running supporting system based on sensitive instruction substitution
CN109558117A (en) * 2018-10-19 2019-04-02 南京航空航天大学 The C code automatic generation method of the refinement of AADL model and its support towards AEROSPACE APPLICATION
CN112114801A (en) * 2020-09-02 2020-12-22 南京航空航天大学 IMA-oriented AADL multi-paradigm modeling and C code automatic generation method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8510706B1 (en) * 2009-09-04 2013-08-13 The Mathworks, Inc. Generating comments for code generated from a model
CN102609293A (en) * 2012-01-17 2012-07-25 深圳天源迪科信息技术股份有限公司 Method for instantiating C/C++ dynamically
CN104932905A (en) * 2015-07-14 2015-09-23 北京神舟航天软件技术有限公司 Automatic code generation method from AADL to C language
CN105094973A (en) * 2015-07-31 2015-11-25 上海卫星工程研究所 ADA program partition running supporting system based on sensitive instruction substitution
CN109558117A (en) * 2018-10-19 2019-04-02 南京航空航天大学 The C code automatic generation method of the refinement of AADL model and its support towards AEROSPACE APPLICATION
CN112114801A (en) * 2020-09-02 2020-12-22 南京航空航天大学 IMA-oriented AADL multi-paradigm modeling and C code automatic generation method

Also Published As

Publication number Publication date
CN116166412A (en) 2023-05-26

Similar Documents

Publication Publication Date Title
CN106663019B (en) Processing value types
CN107041158B (en) Restrictive access control for modular reflection
US10055208B2 (en) Extending a virtual machine instruction set architecture
US11366643B2 (en) Generating dynamic modular proxies
CN100476721C (en) Methods and apparatus to provide a modular native method invocation system, and system thereof
US8984542B2 (en) Method and system for binding objects in dynamic programming languages using caching techniques
WO2014107540A1 (en) Software interface for a hardware device
WO2014107542A1 (en) Capability based device driver framework
US10802855B2 (en) Producing an internal representation of a type based on the type's source representation
US10606569B2 (en) Declarative configuration elements
WO2023093134A1 (en) Method and apparatus for generating system resource allocation code, and electronic device and medium
US9830204B2 (en) Facilitating communication between software components that use middleware
US10445125B2 (en) Method and device for securing the application programming interface of a hypervisor
CN109739666A (en) Striding course call method, device, equipment and the storage medium of singleton method
US9015679B2 (en) System and method for translating business application functions into DBMS internal programming language procedures
CN105393216B (en) Run-time memory is adjusted
CN113778451A (en) File loading method and device, computer system and computer readable storage medium
WO2014107543A1 (en) High throughput low latency user mode drivers implemented in managed code
US9658838B2 (en) Optimized JavaServer Pages lifecycle model
CN109901826B (en) Data processing method and device for Java program and electronic equipment
Yamamoto et al. Component-based mruby platform for IoT devices
CN117573338A (en) Resource allocation method and device and electronic equipment
US9778917B2 (en) Dynamically building subsections of locale objects at run-time
CN117608686A (en) Configuration and transmission method, device, equipment, medium and server of accelerator
CN117950797A (en) Automatic packaging method for complex system service based on container

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22897229

Country of ref document: EP

Kind code of ref document: A1