WO2017167289A1 - 代码控制方法和装置 - Google Patents

代码控制方法和装置 Download PDF

Info

Publication number
WO2017167289A1
WO2017167289A1 PCT/CN2017/079070 CN2017079070W WO2017167289A1 WO 2017167289 A1 WO2017167289 A1 WO 2017167289A1 CN 2017079070 W CN2017079070 W CN 2017079070W WO 2017167289 A1 WO2017167289 A1 WO 2017167289A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
application programming
programming interface
specific
source code
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/CN2017/079070
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.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo 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
Application filed by Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Publication of WO2017167289A1 publication Critical patent/WO2017167289A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/3017Runtime instruction translation, e.g. macros
    • G06F9/30174Runtime instruction translation, e.g. macros for non-native instruction set, e.g. Javabyte, legacy code
    • 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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a code control method and apparatus.
  • Some data storage systems such as databases are shared resources used by multiple users.
  • multiple processes may access the same data at the same time. If you do not control the concurrent operation, you may read and store incorrect data, which will destroy the consistency of the database.
  • the inventory data for a certain item is stored in the database.
  • the database receives a request from the user to purchase the item, the inventory data can be queried, and if the fashion is found to be in stock, the inventory data can be updated and an indication of the purchase can be returned.
  • the current inventory data is 1, and two users request to purchase the item at the same time, there will be two processes in the database to query the inventory data at the same time, and all the inventory is found and the inventory data is updated, so that the inventory The data will change to -1. That is to say, although there is only one item left in the stock, the item is sold to two users. Therefore, when a process updates data, you need to lock this data.
  • a process can lock a data object before it can operate on it. After locking, the process has certain control over the data object. Other processes cannot update this data object before unlocking.
  • the operation against the database can be written as source code, and the source code can be compiled into object code using the compiler.
  • the object code is machine identifiable and can be executed by a device such as a computer to implement operations on the database.
  • the source code is written in the order in which the lock and unlock functions (which can be referred to as lock functions) are implemented, due to hardware and software design, it is possible for the device to optimize the execution order of the code during the compilation of the source code and the execution of the target code. And adjustments, such that the order of execution of the object code for implementing the locking and unlocking functions is changed, so that the locking and unlocking of the data cannot be realized, resulting in the possibility that multiple processes simultaneously update the data. That is to say, even if the lock function is added when writing the source code, it may not work due to the code optimization performed by the device itself.
  • the present invention has been made in order to provide a code control method and apparatus that at least partially solves the above problems.
  • a code control method comprising: acquiring hardware information of a device; and calling a specific application programming interface of an operating system on the device according to the hardware information, the specific application programming interface Controlling execution of a particular object code obtained by compiling a particular source code on the device such that an order of execution of the particular object code is consistent with an order of execution indicated by the particular source code.
  • a code control apparatus includes an acquisition module and a calling module.
  • the acquisition module is used to obtain hardware information of the device.
  • Calling a module for invoking a specific application programming interface of an operating system on the device according to the hardware information, the specific application programming interface for controlling a specific target code obtained by compiling a specific source code on the device Execution is such that the order of execution of the particular object code is consistent with the order of execution indicated by the particular source code.
  • a code control method and apparatus controls an execution order of a specific target code to be consistent with an execution order indicated by a specific source code by calling a specific application programming interface on the device, which helps to avoid device-to-target The problem of invalidation of the lock function caused by the automatic adjustment of the execution order of the code.
  • a computer program comprising computer readable code, when said computer readable code is run on a computing device, causing said computing device to perform code control as described above method.
  • Figure 1 shows a schematic diagram of the operation represented by an exemplary source code
  • FIG. 2 is a flow chart showing a code control method according to an embodiment of the present invention.
  • FIG. 3 shows a schematic diagram of operations represented by source code in accordance with one embodiment of the present invention
  • Figure 4 shows a schematic block diagram of a code control device in accordance with one embodiment of the present invention
  • Figure 5 is a schematic block diagram of a computing device for performing a code control method in accordance with the present invention.
  • Fig. 6 schematically shows a storage unit for holding or carrying program code implementing the code control method according to the present invention.
  • Figure 1 shows a schematic diagram of the operations represented by the exemplary source code.
  • the source code in block 110 represents a concurrent operation
  • the source code in block 120 represents a lock operation
  • the source code in block 130 represents a serial operation
  • the source code in block 140 represents an unlock operation, in block 150.
  • the source code represents concurrent operations.
  • concurrent operations for the database can be performed before and after the unlocking operation, and serial operations should be performed after the locking operation and before the unlocking operation.
  • This serial operation can be an operation to update the inventory data as described above. Locking and unlocking allows only one process to update inventory data at a time.
  • Concurrent operations may be, for example, data query operations, such as querying inventory data, such operations may be performed in parallel, that is, may be performed in parallel by multiple processes (which may correspond to multiple users).
  • the serial operation can be, for example, a data update operation, such as updating inventory data, such operations can be performed serially, that is, can be performed by only one process at a time.
  • the device may optimize and adjust the execution order of the code. For example, it is possible to actually adjust the serial operation represented by the source code in block 130 to the lock represented by the source code in block 120 when executing the object code. The operation is either preceded or adjusted to the unlock operation represented by the source code in block 140. Thus, the locking operation and the unlocking operation will not be able to control the execution of the serial operation represented by the source code in the block 130, resulting in a parallel processing situation in which multiple processes may simultaneously update the data, causing errors in data reading and storage. . That is to say, even if the lock function is added when writing the source code, it may not work due to the code optimization performed by the device itself.
  • a code control method is provided. 2 shows a flow diagram of a code control method 200 in accordance with one embodiment of the present invention.
  • the code control method 200 includes the following steps.
  • step S210 hardware information of the device is acquired.
  • a device can be a hardware device on which a particular object code is to be executed.
  • the hardware information may be various configuration information related to the device, including but not limited to one or more of the following: a kernel version of an operating system on the device, a processor architecture of the device.
  • the kernel version of the operating system may include, but is not limited to, a disk operating system (DOS operating system), a Windows series operating system (such as Windows 95, Windows XP, Windows Vista, Windows 7, Windows 8, etc.), a Unix operating system, and a Linux operating system. Wait.
  • DOS operating system disk operating system
  • Windows series operating system such as Windows 95, Windows XP, Windows Vista, Windows 7, Windows 8, etc.
  • Unix operating system such as Windows 95, Windows XP, Windows Vista, Windows 7, Windows 8, etc.
  • the processor architecture may include, but is not limited to, an x86 architecture, an x86_64 architecture, and the like.
  • Obtaining the hardware information of the device may be reading hardware information of the device by using a compiler program.
  • a specific application programming interface (API) of an operating system on the device is invoked according to the hardware information, the specific application programming interface is used to control execution of the specific target code obtained by compiling the specific source code on the device.
  • the order of execution of the particular object code is made consistent with the order of execution indicated by the particular source code.
  • control instructions such as the application programming interfaces described herein
  • the underlying control instructions may not be different.
  • the application programming interface X can be invoked to control the execution order of the specific target code and the execution indicated by the specific source code.
  • the order is the same, and when the processor architecture of the device is x86_64 (64-bit) architecture, the kernel version of the operating system is windows 8, the application programming interface Y can be called to control the execution order of the specific target code and the specific source code indicates Hold The line order is the same.
  • the application programming interface X is different from the application programming interface Y, so it can be first determined whether the processor architecture of the device is an x86 architecture or an x86_64 architecture, and whether the kernel version of the operating system is Windows 7 or Windows 8, and then the corresponding use is determined according to the judgment result.
  • An application programming interface that controls the order in which specific target code is executed on the device.
  • the particular source code may be any suitable source code that is expected to be unadjusted in the order of execution of its corresponding object code, such as the source code described above for representing operations that update inventory data. It will be appreciated that the operation for inventory data is merely an example and not a limitation, and that particular source code may be source code for representing other types of operations.
  • the particular application programming interface can be utilized to control the execution of specific object code.
  • the execution order of the specific object code is controlled to be consistent with the execution order indicated by the specific source code by calling a specific application programming interface on the device, which helps to avoid the device-to-target code.
  • the specific application programming interface may include a first application programming interface
  • step S220 may further include: calling the first application programming interface according to the hardware information to control execution of the specific target code before compiling the specific source code. The order is not adjusted forward.
  • Figure 3 shows a schematic diagram of the operations represented by the source code in accordance with one embodiment of the present invention.
  • the source codes in blocks 310, 320, 340, 360, and 370 shown in FIG. 3 correspond to the source codes in blocks 110 to 150 shown in FIG. 1, respectively.
  • source code for representing the first invocation operation is added in front of the source code for representing serial operations in block 340.
  • the source code used to represent the first invocation operation can be represented by a custom primitive accq.
  • Accq can be pre-defined to enable the compiler program to recognize and compile it.
  • the main function of accq is to call the first application programming interface based on the hardware information.
  • the application programming interface X can be called.
  • the application programming interface X can control that the target code corresponding to the source code in block 340 is not forward-adjusted when executed on a 32-bit device installed with the Windows 7 operating system, that is, the source code in block 340 is represented.
  • the serial operation is not performed until the lock operation represented by the source code in block 320 is performed.
  • the call of the first application programming interface can ensure that the execution order of the specific target code is not adjusted forward.
  • the code control method 200 may further include: determining that the presence is for indicating the first application programming The first identifier of the interface.
  • the first application programming interface Before calling the first application programming interface, it can be determined whether the first identification exists. If the first identity exists, the first application programming interface can be invoked with the first identity. If the first identifier does not exist, an indication that the first application programming interface cannot be called may be returned.
  • the first application programming interface corresponding to the kernel version of the processor architecture and operating system is not found from the predefined accq primitive.
  • the first identifier that is, the first application programming interface corresponding to the processor architecture and the kernel version of the operating system is not predefined in the accq primitive, in which case the first application cannot be invoked
  • the programming interface so it can return instructions that the first application programming interface cannot call.
  • the first application programming interface that is desired to be invoked can be quickly and accurately determined using the first identification.
  • the code control method 200 may further include compiling the source code for representing the locking operation,
  • the locking operation includes: setting a token; and assigning a token to the process that originally requested the desired data in chronological order, wherein the operation represented by the specific source code is performed by the process that possesses the token.
  • source code in block 320 for representing the locking operation prior to the source code in block 330 for representing the first invocation operation, there is source code in block 320 for representing the locking operation. That is, the source code used to represent the locking operation can be compiled before the first application programming interface is called.
  • the serial operation represented by the source code in block 340 can be controlled such that the actions in the serial operation are performed by only one process at a time.
  • Such a locking operation can be achieved by assigning a token.
  • the token is unique, and only the process that owns the token can perform the serial operation represented by the source code in block 340.
  • This serial operation can be performed, for example, with a data update or the like.
  • tokens to control the operations represented by a particular source code allows the operations represented by a particular source code to be executed by only one process at a time, helping to avoid errors in data reading and storage.
  • a specific application programming interface may include a second application programming The interface, the above step S220 may further include: after compiling the specific source code, calling the second application programming interface according to the hardware information to control the execution order of the specific target code not to be adjusted backward.
  • source code for representing the second invocation operation is added.
  • the source code used to represent the second invocation operation can be represented by a custom primitive release. Similar to accq, release can be pre-defined to enable the compiler program to recognize and compile it.
  • the main function of the release is to call the second application programming interface according to the hardware information, so that the target code corresponding to the source code in the control block 340 is not adjusted backward when executed on the device, that is, the source code in the block 340 is used.
  • the representative serial operation is not performed after the unlock operation represented by the source code in block 360 is adjusted.
  • the second application programming interface is called in a similar manner to the first application programming interface, and will not be described again.
  • the call of the second application programming interface can ensure that the execution order of the specific target code is not adjusted backwards.
  • the specific application programming interface may include a first application programming interface and a second application programming interface
  • the step S220 may further include: calling the first application programming interface according to the hardware information before compiling the specific source code to The execution order of the control specific target code is not adjusted forward; and after compiling the specific source code, the second application programming interface is called according to the hardware information to control the execution order of the specific target code not to be adjusted backward. That is to say, the first application programming interface and the second application programming interface can be called together, so that the execution order of the specific target code is neither adjusted forward nor backward adjusted to ensure that the specific source code represents The operations can be performed in the desired order.
  • the code control method 200 may further include: determining that the presence is for indicating the second application programming The second identifier of the interface.
  • the second identification is present prior to invoking the second application programming interface. If the second identity is present, the second application programming interface can be invoked with the second identity. If the second identifier does not exist, an indication that the second application programming interface cannot be called may be returned.
  • a second application programming interface corresponding to the kernel version of the processor architecture and operating system is not found from the predefined release primitive.
  • the second identifier that is, not in the release primitive
  • the second application programming interface corresponding to the kernel architecture of the processor architecture and the operating system is predefined, in which case the second application programming interface cannot be called, so an indication that the second application programming interface cannot be called can be returned. information.
  • the second application programming interface that is desired to be invoked can be quickly and accurately determined using the second identification.
  • the code control method 200 may further include compiling the source code for representing the unlocking operation, The unlocking operation includes: releasing the token.
  • source code in block 360 for representing the unlock operation there is source code in block 360 for representing the unlock operation. That is, the source code used to represent the unlock operation can be compiled after the second application programming interface is called.
  • the token may be released after the process occupying the token performs the serial operation represented by the source code in block 340. After the token is released, the token may be assigned to the next process requesting the desired data in chronological order to continue execution of the serial operation represented by the source code in block 340 by the next process.
  • the specific source code may include source code for representing operations of: acquiring desired data from the memory; modifying the desired data; and storing the modified desired data to the memory.
  • the desired data may be the desired data involved in the locking operation described above, such as inventory data, etc.
  • the serial operation represented by the source code in block 340 may be a data update (ie, modification) operation.
  • the inventory data is 1.
  • two processes can be initiated simultaneously for querying and modifying the inventory data of the item.
  • the tokens can be assigned to the process that originally requested the desired data in chronological order. Assuming that the process that first requested the expected data is process a and the other process is process b, process a can first fetch the token. Process a queries that the inventory data at this time is 1, and can decrement the inventory data by 1, that is, to 0.
  • Process b queries the inventory data and finds that the inventory data is 0 and cannot be traded. In this case, the process b can return an indication that the inventory is insufficient to be traded to the corresponding user.
  • FIG. 4 shows a schematic block diagram of a code control device 400 in accordance with one embodiment of the present invention.
  • the code control device 400 includes an acquisition module 410 and a call module 420.
  • the obtaining module 410 is configured to acquire hardware information of the device.
  • the calling module 420 is configured to invoke a specific application programming interface of an operating system on the device according to the hardware information, where the specific application programming interface is used to control a specific target code obtained by compiling a specific source code on a device. Execution is such that the order of execution of the particular object code is consistent with the order of execution indicated by the particular source code.
  • the acquisition module 410 can communicate directly or indirectly with the calling module 420, and any of the acquisition module 410 and the calling module 420 can be implemented using any suitable hardware, software, and/or firmware.
  • a code control apparatus controls an execution order of a specific target code to be consistent with an execution order indicated by a specific source code by calling a specific application programming interface on the device, which helps to avoid the device-to-target code The problem of invalidation of the lock function caused by the automatic adjustment of the execution sequence.
  • the specific application programming interface can include a first application programming interface
  • the calling module 420 can further include a first calling sub-module (not shown) for invoking the first based on the hardware information prior to compiling the particular source code
  • the application programming interface controls the order in which specific target code is executed without being adjusted forward.
  • the code control apparatus 400 can further include a first identification determining module (not shown) for determining that there is a first identification for indicating the first application programming interface.
  • a first identification determining module (not shown) for determining that there is a first identification for indicating the first application programming interface.
  • the code control apparatus 400 may further include a first compiling module (not shown) for compiling source code for representing a locking operation, the locking operation may include: setting a token; and chronologically toward the earliest A process that requests the desired data to allocate a token, wherein the operation represented by the particular source code is performed by the process that owns the token.
  • a first compiling module (not shown) for compiling source code for representing a locking operation
  • the locking operation may include: setting a token; and chronologically toward the earliest A process that requests the desired data to allocate a token, wherein the operation represented by the particular source code is performed by the process that owns the token.
  • the specific application programming interface can include a second application programming interface
  • the calling module 420 can further include a second calling sub-module (not shown) for invoking the second based on the hardware information after compiling the specific source code
  • the application programming interface controls the order in which specific target code is executed without being adjusted backwards.
  • the code control apparatus 400 can further include a second identification determining module (not shown) for determining that there is a second identification for indicating the second application programming interface.
  • a second identification determining module (not shown) for determining that there is a second identification for indicating the second application programming interface.
  • the code control apparatus 400 may further include a second compiling module (not shown) for compiling source code for representing an unlocking operation, the unlocking operation including: releasing the token.
  • a second compiling module (not shown) for compiling source code for representing an unlocking operation, the unlocking operation including: releasing the token.
  • particular source code may include source code for representing operations from: memory Obtaining the desired data; modifying the desired data; and storing the modified desired data to the memory.
  • the hardware information can include one or more of the following: a kernel version of an operating system on the device, a processor architecture of the device.
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
  • Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processor may be used in practice to implement some or all of the functionality of some or all of the components of the code control device in accordance with embodiments of the present invention.
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
  • Figure 5 illustrates a computing device that can implement a code control method in accordance with the present invention.
  • the computing device conventionally includes a processor 510 and a computer program product or computer readable medium in the form of a memory 520.
  • the memory 520 may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read Only Memory), an EPROM, a hard disk, or a ROM.
  • Memory 520 has a storage space 530 that stores program code 531 for performing any of the method steps described above.
  • storage space 530 storing program code may store respective program code 531 for implementing various steps in the above methods, respectively.
  • the program code can be read from or written to one or more computer program products.
  • Such computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
  • Such a computer program product is typically a portable or fixed storage unit such as that shown in FIG.
  • the storage unit may have storage segments, storage spaces, and the like that are similarly arranged to memory 520 in the computing device of FIG.
  • the program code can be compressed, for example, in an appropriate form.
  • the storage unit stores computer readable code 531' for performing the method steps of the present invention, ie, code that can be read by a processor, such as 510, when the code is run by a computing device, causing the computing device Perform the various steps in the method described above.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

一种代码控制方法和装置。该代码控制方法包括:获取设备的硬件信息(S210);以及根据硬件信息调用设备上的操作系统的特定应用程序编程接口,所述特定应用程序编程接口用于控制通过编译特定源代码所获得的特定目标代码在设备上的执行以使得特定目标代码的执行顺序与特定源代码所指示的执行顺序一致(S220)。上述代码控制方法和装置,通过调用设备上的特定应用程序编程接口来控制特定目标代码的执行顺序与特定源代码所指示的执行顺序一致,这有助于避免由于设备对目标代码的执行顺序的自动调整而导致的锁功能失效的问题。

Description

代码控制方法和装置 技术领域
本发明涉及计算机技术领域,具体涉及一种代码控制方法和装置。
背景技术
某些数据存储系统(例如数据库)是多用户使用的共享资源。下面以数据库为例进行说明。当多个用户并发地存取数据库中的数据时,可能会发生多个进程同时存取同一数据的情况。若对并发操作不加控制就可能会读取和存储不正确的数据,破坏数据库的一致性。
例如,假设数据库中存储了某种商品的库存数据。当数据库接收到用户购买该商品的请求时,可以查询库存数据,如果发现此时尚有库存,则可以更新库存数据并返回可以购买的指示。假设当前的库存数据为1,并且在同一时间有两个用户请求购买该商品,数据库中会存在两个进程同时对库存数据进行查询,均发现尚有库存并对库存数据进行更新,这样,库存数据将变为-1。也就是说,虽然商品的库存仅剩一件,但是该商品却被卖给了两个用户。因此在某一进程对数据进行更新的时候,需要锁定这条数据。
进程在对某个数据对象进行操作前,可以首先对该数据对象进行锁定。锁定后进程就对该数据对象具有一定的控制权,在解锁之前,其他进程不能对此数据对象进行更新。
可以将针对数据库的操作编写为源代码,并且可以利用编译程序将源代码编译为目标代码。目标代码是机器可识别的,可以由诸如计算机的设备执行,从而实现针对数据库的操作。
虽然按照实现锁定和解锁功能(可称为锁功能)的顺序编写源代码,但是由于硬件和软件设计原因,在编译源代码和执行目标代码的过程中,设备有可能对代码的执行顺序进行优化和调整,使得用于实现锁定和解锁功能的目标代码的执行顺序发生变化,从而无法实现对数据的锁定和解锁,导致可能出现多个进程同时对数据进行更新的情况。也就是说,即使在编写源代码时加入了锁功能,其也有可能由于设备自身进行的代码优化而无法发挥作用。
发明内容
鉴于上述问题,提出了本发明以便提供一种至少部分地解决上述问题的代码控制方法和装置。
根据本发明的一个方面,提供一种代码控制方法,包括:获取设备的硬件信息;以及根据所述硬件信息调用所述设备上的操作系统的特定应用程序编程接口,所述特定应用程序编程接口用于控制通过编译特定源代码所获得的特定目标代码在所述设备上的执行以使得所述特定目标代码的执行顺序与所述特定源代码所指示的执行顺序一致。
根据本发明的另一个方面,提供一种代码控制装置。该代码控制装置包括获取模块和调用模块。获取模块用于获取设备的硬件信息。调用模块用于根据所述硬件信息调用所述设备上的操作系统的特定应用程序编程接口,所述特定应用程序编程接口用于控制通过编译特定源代码所获得的特定目标代码在所述设备上的执行以使得所述特定目标代码的执行顺序与所述特定源代码所指示的执行顺序一致。
根据本发明实施例的代码控制方法和装置,通过调用设备上的特定应用程序编程接口来控制特定目标代码的执行顺序与特定源代码所指示的执行顺序一致,这有助于避免由于设备对目标代码的执行顺序的自动调整而导致的锁功能失效的问题。
根据本发明的又一个方面,还提供了一种计算机程序,其包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行如上文所述的代码控制方法。
根据本发明的再一个方面,还提供了一种计算机可读介质,其中存储了如上文所述的计算机程序。
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。
附图说明
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示 相同的部件。在附图中:
图1示出示例性的源代码所代表的操作的示意图;
图2示出根据本发明一个实施例的代码控制方法的流程示意图;
图3示出根据本发明一个实施例的源代码所代表的操作的示意图;
图4示出根据本发明一个实施例的代码控制装置的示意性框图;
图5示意性地示出了用于执行根据本发明的代码控制方法的计算设备的框图;以及
图6示意性地示出了用于保持或者携带实现根据本发明的代码控制方法的程序代码的存储单元。
具体实施方式
下面结合附图和具体的实施方式对本发明作进一步的描述。
图1示出示例性的源代码所代表的操作的示意图。在图1中,块110中的源代码代表并发操作,块120中的源代码代表锁定操作,块130中的源代码代表串行操作,块140中的源代码代表解锁操作,块150中的源代码代表并发操作。
假设按照图1所示的顺序编写源代码,并相应地期望按照如下顺序执行操作:首先执行并发操作,然后执行锁定操作、串行操作和解锁操作,最后执行并发操作。这样,根据源代码所指示的执行顺序,在锁定操作之前及解锁操作之后,可以实施针对数据库的并发操作,而在锁定操作之后及解锁操作之前的时段内,应当实施串行操作。这段串行操作可以是如上文所述的更新库存数据的操作。锁定和解锁可以使得在同一时间仅有一个进程能够对库存数据进行更新。
并发操作可以是诸如数据查询操作,例如查询库存数据,这类操作可以是并行执行的,也就是可以由多个进程(可对应于多个用户)并行执行。串行操作可以是诸如数据更新操作,例如更新库存数据,这类操作可以串行执行,即可以在同一时间仅由一个进程执行。
如上文所述,虽然按照图1所示的顺序编写源代码,但是由于硬件和软件设计原因,在编译源代码和执行目标代码的过程中,设备有可能对代码的执行顺序进行优化和调整,例如,有可能在执行目标代码时实际上已经将块130中的源代码所代表的串行操作调整到了块120中的源代码所代表的锁定 操作前面或者调整到了块140中的源代码所代表的解锁操作后面。这样,锁定操作和解锁操作将无法控制块130中的源代码所代表的串行操作的执行,导致可能出现多个进程同时对数据进行更新的并行处理情况,使得数据的读取和存储出现错误。也就是说,即使在编写源代码时加入了锁功能,其也有可能由于设备自身进行的代码优化而无法发挥作用。
为了解决上述问题,根据本发明的一个方面,提供一种代码控制方法。图2示出根据本发明一个实施例的代码控制方法200的流程示意图。
如图2所示,代码控制方法200包括以下步骤。
在步骤S210,获取设备的硬件信息。
设备可以是特定目标代码要在其上执行的硬件设备。硬件信息可以是与该设备相关的各种配置信息,包括但不限于以下项中的一项或多项:所述设备上的操作系统的内核版本、所述设备的处理器架构。
操作系统的内核版本可以包括但不限于:磁盘操作系统(DOS操作系统)、Windows系列操作系统(例如Windows 95、Windows XP、Windows Vista、Windows 7、Windows 8等)、Unix操作系统、Linux操作系统等。
处理器架构可以包括但不限于:x86架构、x86_64架构等。
本领域技术人员可以理解,以上硬件信息的类型仅是示例而非对本发明的限制,可以针对任何其他合适的现有或未来可能出现的硬件信息实现本发明实施例提供的代码控制方法。
获取设备的硬件信息可以是利用编译器程序读取设备的硬件信息。
在步骤S220,根据硬件信息调用设备上的操作系统的特定应用程序编程接口(API),所述特定应用程序编程接口用于控制通过编译特定源代码所获得的特定目标代码在设备上的执行以使得特定目标代码的执行顺序与特定源代码所指示的执行顺序一致。
对于不同的硬件和软件配置环境,用于控制目标代码的执行顺序不被调整的底层控制指令(例如本文所述的应用程序编程接口)可能是不同的。
例如,假设当设备的处理器架构是x86(32位)架构,操作系统的内核版本是windows 7时,可以调用应用程序编程接口X来控制特定目标代码的执行顺序与特定源代码所指示的执行顺序一致,而当设备的处理器架构是x86_64(64位)架构,操作系统的内核版本是windows 8时,可以调用应用程序编程接口Y来控制特定目标代码的执行顺序与特定源代码所指示的执 行顺序一致。应用程序编程接口X与应用程序编程接口Y不同,因此可以首先判断设备的处理器架构是x86架构还是x86_64架构以及操作系统的内核版本是Windows 7还是Windows 8,然后根据判断结果确定对应的用于控制特定目标代码在设备上的执行顺序的应用程序编程接口。
特定源代码可以是任何合适的、期望其对应的目标代码的执行顺序不被调整的源代码,例如上文所述的用于代表对库存数据进行更新的操作的源代码。可以理解,针对库存数据的操作仅是示例而非限制,特定源代码可以是用于代表其他类型的操作的源代码。
在调用特定应用程序编程接口之后,可以利用该特定应用程序编程接口控制特定目标代码的执行。
根据本发明实施例的代码控制方法,通过调用设备上的特定应用程序编程接口来控制特定目标代码的执行顺序与特定源代码所指示的执行顺序一致,这有助于避免由于设备对目标代码的执行顺序的自动调整而导致的锁功能失效的问题。
根据本发明实施例,特定应用程序编程接口可以包括第一应用程序编程接口,步骤S220可以进一步包括:在编译特定源代码之前,根据硬件信息调用第一应用程序编程接口以控制特定目标代码的执行顺序不被向前调整。
图3示出根据本发明一个实施例的源代码所代表的操作的示意图。图3所示的块310、320、340、360和370中的源代码分别与图1所示的块110至150中的源代码相对应。如图3所示,在块340中的用于代表串行操作的源代码的前面,加入用于代表第一调用操作的源代码。用于代表第一调用操作的源代码可以用自定义原语accq表示。accq可以预先进行定义,以使得编译器程序能够对其进行识别和编译。accq的主要作用是根据硬件信息调用第一应用程序编程接口。例如,如果设备的处理器架构是x86(32位),操作系统的内核版本是windows 7,则可以调用应用程序编程接口X。该应用程序编程接口X可以控制块340中的源代码所对应的目标代码在安装windows 7操作系统的32位的设备上执行时不被向前调整,也就是使块340中的源代码所代表的串行操作不被调整到块320中的源代码所代表的锁定操作之前执行。
也就是说,通过第一应用程序编程接口的调用可以保证特定目标代码的执行顺序不被向前调整。
根据本发明实施例,在根据硬件信息调用第一应用程序编程接口以控制特定目标代码的执行顺序不被向前调整之前,代码控制方法200可以进一步包括:确定存在用于指示第一应用程序编程接口的第一标识。
在调用第一应用程序编程接口之前,可以确定第一标识是否存在。如果第一标识存在,则可以利用第一标识调用第一应用程序编程接口。如果第一标识不存在,则可以返回第一应用程序编程接口无法调用的指示信息。
例如,假设在确定设备的处理器架构和操作系统的内核版本之后,从预定义的accq原语中找不到与该处理器架构和操作系统的内核版本相对应的第一应用程序编程接口的第一标识,也就是说,在accq原语中未对该处理器架构和操作系统的内核版本所对应的第一应用程序编程接口进行预定义,在这种情况下,无法调用第一应用程序编程接口,因此可以返回第一应用程序编程接口无法调用的指示信息。
一般而言,可以利用第一标识可以快速准确地确定期望调用的第一应用程序编程接口。
根据本发明实施例,在根据硬件信息调用第一应用程序编程接口以控制特定目标代码的执行顺序不被向前调整之前,代码控制方法200可以进一步包括编译用于代表锁定操作的源代码,所述锁定操作包括:设置令牌;以及按照时间顺序向最早请求期望数据的进程分配令牌,其中,特定源代码所代表的操作由占有令牌的进程执行。
继续参考图3,示出在块330中的用于代表第一调用操作的源代码之前,存在块320中的用于代表锁定操作的源代码。也就是说,可以在调用第一应用程序编程接口之前,编译用于代表锁定操作的源代码。
利用代表锁定操作的源代码,可以控制块340中的源代码所代表的串行操作,使得串行操作中的动作在同一时间仅由一个进程执行。这样的锁定操作可以通过分配令牌来实现。令牌是唯一的,仅占有令牌的进程能够执行块340中的源代码所代表的串行操作。该串行操作可以例如数据更新等类似操作。
利用令牌控制特定源代码所代表的操作可以使得特定源代码所代表的操作在同一时间仅由一个进程执行,有助于避免数据的读取和存储出现错误。
根据本发明实施例,特定应用程序编程接口可以包括第二应用程序编程 接口,上述步骤S220可以进一步包括:在编译特定源代码之后,根据硬件信息调用第二应用程序编程接口以控制特定目标代码的执行顺序不被向后调整。
继续参考图3,在块340中的用于代表串行操作的源代码的后面,加入用于代表第二调用操作的源代码。用于代表第二调用操作的源代码可以用自定义原语release表示。与accq类似地,release可以预先进行定义,以使得编译器程序能够对其进行识别和编译。release的主要作用是根据硬件信息调用第二应用程序编程接口,以控制块340中的源代码所对应的目标代码在设备上执行时不被向后调整,也就是使块340中的源代码所代表的串行操作不被调整到块360中的源代码所代表的解锁操作之后执行。第二应用程序编程接口的调用方式与第一应用程序编程接口类似,不再赘述。
也就是说,通过第二应用程序编程接口的调用可以保证特定目标代码的执行顺序不被向后调整。
示例性地,特定应用程序编程接口可以包括第一应用程序编程接口和第二应用程序编程接口,上述步骤S220可以进一步包括:在编译特定源代码之前,根据硬件信息调用第一应用程序编程接口以控制特定目标代码的执行顺序不被向前调整;以及在编译特定源代码之后,根据硬件信息调用第二应用程序编程接口以控制特定目标代码的执行顺序不被向后调整。也就是说,可以一起调用第一应用程序编程接口和第二应用程序编程接口,使得特定目标代码的执行顺序既不会被向前调整也不会被向后调整,以保证特定源代码所代表的操作能够按照期望顺序执行。
根据本发明实施例,在根据硬件信息调用第二应用程序编程接口以控制特定目标代码的执行顺序不被向后调整之前,代码控制方法200可以进一步包括:确定存在用于指示第二应用程序编程接口的第二标识。
与第一标识类似地,在调用第二应用程序编程接口之前,可以确定第二标识是否存在。如果第二标识存在,则可以利用第二标识调用第二应用程序编程接口。如果第二标识不存在,则可以返回第二应用程序编程接口无法调用的指示信息。
例如,假设在确定设备的处理器架构和操作系统的内核版本之后,从预定义的release原语中找不到与该处理器架构和操作系统的内核版本相对应的第二应用程序编程接口的第二标识,也就是说,在release原语中未对该处 理器架构和操作系统的内核版本所对应的第二应用程序编程接口进行预定义,在这种情况下,无法调用第二应用程序编程接口,因此可以返回第二应用程序编程接口无法调用的指示信息。
类似地,利用第二标识可以快速准确地确定期望调用的第二应用程序编程接口。
根据本发明实施例,在根据硬件信息调用第二应用程序编程接口以控制特定目标代码的执行顺序不被向后调整之后,代码控制方法200可以进一步包括编译用于代表解锁操作的源代码,所述解锁操作包括:释放令牌。
继续参考图3,示出在块350中的用于代表第二调用操作的源代码之后,存在块360中的用于代表解锁操作的源代码。也就是说,可以在调用第二应用程序编程接口之后,编译用于代表解锁操作的源代码。
示例性地,当占有令牌的进程执行完块340中的源代码所代表的串行操作之后,可以释放令牌。在释放令牌之后,可以按照时间顺序向下一个请求期望数据的进程分配所述令牌,以由下一个进程继续执行块340中的源代码所代表的串行操作。
根据本发明实施例,特定源代码可以包括用于代表以下操作的源代码:从存储器中获取期望数据;修改期望数据;以及将经修改的期望数据存储到存储器。
示例性地,期望数据可以是上文所述的锁定操作所涉及的期望数据,例如库存数据等,块340中的源代码所代表的串行操作可以是数据更新(即修改)操作。假设某种商品的库存仅剩一件,则其库存数据为1。当同时存在两个用户请求购买该商品时,可以同时发起两个进程用于对该商品的库存数据进行查询和修改。如上文所述,可以根据时间顺序向最早请求期望数据的进程分配令牌。假设最早请求期望数据的进程是进程a,另一个进程是进程b,则进程a可以首先取到令牌。进程a查询到此时的库存数据为1,并且可以将库存数据减1,即修改为0。这样,与进程a对应的用户可以成功购买商品。随后,释放令牌并将令牌分配给进程b。进程b对库存数据进行查询,发现库存数据为0,无法进行交易。这种情况下,进程b可以向对应用户返回库存不足无法交易的指示信息。
根据本发明的另一方面,提供一种代码控制装置。图4示出根据本发明一个实施例的代码控制装置400的示意性框图。如图4所示,代码控制装置 400包括获取模块410和调用模块420。
获取模块410用于获取设备的硬件信息。
调用模块420用于根据所述硬件信息调用所述设备上的操作系统的特定应用程序编程接口,所述特定应用程序编程接口用于控制通过编译特定源代码所获得的特定目标代码在设备上的执行以使得特定目标代码的执行顺序与特定源代码所指示的执行顺序一致。
获取模块410可以与调用模块420直接或间接地通信,获取模块410和调用模块420的任何一者可以采用任何合适的硬件、软件和/或固件实现。
根据本发明实施例的代码控制装置,通过调用设备上的特定应用程序编程接口来控制特定目标代码的执行顺序与特定源代码所指示的执行顺序一致,这有助于避免由于设备对目标代码的执行顺序的自动调整而导致的锁功能失效的问题。
示例性地,特定应用程序编程接口可以包括第一应用程序编程接口,调用模块420可以进一步包括第一调用子模块(未示出),用于在编译特定源代码之前,根据硬件信息调用第一应用程序编程接口以控制特定目标代码的执行顺序不被向前调整。
示例性地,代码控制装置400可以进一步包括第一标识确定模块(未示出),用于确定存在用于指示第一应用程序编程接口的第一标识。
示例性地,代码控制装置400可以进一步包括第一编译模块(未示出),用于编译用于代表锁定操作的源代码,所述锁定操作可以包括:设置令牌;以及按照时间顺序向最早请求期望数据的进程分配令牌,其中,特定源代码所代表的操作由占有令牌的进程执行。
示例性地,特定应用程序编程接口可以包括第二应用程序编程接口,调用模块420可以进一步包括第二调用子模块(未示出),用于在编译特定源代码之后,根据硬件信息调用第二应用程序编程接口以控制特定目标代码的执行顺序不被向后调整。
示例性地,代码控制装置400可以进一步包括第二标识确定模块(未示出),用于确定存在用于指示第二应用程序编程接口的第二标识。
示例性地,代码控制装置400可以进一步包括第二编译模块(未示出),用于编译用于代表解锁操作的源代码,所述解锁操作包括:释放令牌。
示例性地,特定源代码可以包括用于代表以下操作的源代码:从存储器 中获取期望数据;修改期望数据;以及将经修改的期望数据存储到存储器。
示例性地,硬件信息可以包括以下项中的一项或多项:设备上的操作系统的内核版本、设备的处理器架构。
上文已经描述了代码控制方法的各步骤的实施方式和优点等,本领域技术人员结合图1至3以及上文关于代码控制方法的描述,可以理解代码控制装置400的具体结构、运行方式及其优点等,本文不对此进行赘述。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的代码控制装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。
例如,图5示出了可以实现根据本发明的代码控制方法的计算设备。该计算设备传统上包括处理器510和以存储器520形式的计算机程序产品或者计算机可读介质。存储器520可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器520具有存储用于执行上述方法中的任何方法步骤的程序代码531的存储空间530。例如,存储程序代码的存储空间530可以存储分别用于实现上面的方法中的各种步骤的各个程序代码531。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为例如图6所示的便携式或者固定存储单元。该存储单元可以具有与图5的计算设备中的存储器520类似布置的存储段、存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元存储用于执行本发明的方法步骤的计算机可读代码531’,即可以由例如510之类的处理器读取的代码,当这些代码当由计算设备运行时,导致该计算设备执行上面所描述的方法中的各个步骤。
本文中所称的“一个实施例”、“实施例”或者“一个或者多个实施例”意味着,结合实施例描述的特定特征、结构或者特性包括在本发明的至少一个实施例中。此外,请注意,这里“在一个实施例中”的词语例子不一定全指同一个实施例。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利 要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
此外,还应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所做的公开是说明性的,而非限制性的,本发明的范围由所附权利要求书限定。

Claims (20)

  1. 一种代码控制方法,包括:
    获取设备的硬件信息;以及
    根据所述硬件信息调用所述设备上的操作系统的特定应用程序编程接口,所述特定应用程序编程接口用于控制通过编译特定源代码所获得的特定目标代码在所述设备上的执行以使得所述特定目标代码的执行顺序与所述特定源代码所指示的执行顺序一致。
  2. 如权利要求1所述的代码控制方法,其中,所述特定应用程序编程接口包括第一应用程序编程接口,
    所述根据所述硬件信息调用所述设备上的操作系统的特定应用程序编程接口进一步包括:
    在编译所述特定源代码之前,根据所述硬件信息调用所述第一应用程序编程接口以控制所述特定目标代码的执行顺序不被向前调整。
  3. 如权利要求2所述的代码控制方法,其中,在所述根据所述硬件信息调用所述第一应用程序编程接口以控制所述特定目标代码的执行顺序不被向前调整之前,所述代码控制方法进一步包括:
    确定存在用于指示所述第一应用程序编程接口的第一标识。
  4. 如权利要求2或3所述的代码控制方法,其中,在所述根据所述硬件信息调用所述第一应用程序编程接口以控制所述特定目标代码的执行顺序不被向前调整之前,所述代码控制方法进一步包括编译用于代表锁定操作的源代码,
    所述锁定操作包括:
    设置令牌;以及
    按照时间顺序向最早请求期望数据的进程分配所述令牌,
    其中,所述特定源代码所代表的操作由占有所述令牌的进程执行。
  5. 如权利要求1-4中任一项所述的代码控制方法,其中,所述特定应用程序编程接口包括第二应用程序编程接口,
    所述根据所述硬件信息调用所述设备上的操作系统的特定应用程序编程接口进一步包括:
    在编译所述特定源代码之后,根据所述硬件信息调用所述第二应用程序 编程接口以控制所述特定目标代码的执行顺序不被向后调整。
  6. 如权利要求5所述的代码控制方法,其中,在根据所述硬件信息调用所述第二应用程序编程接口以控制所述特定目标代码的执行顺序不被向后调整之前,所述代码控制方法进一步包括:
    确定存在用于指示所述第二应用程序编程接口的第二标识。
  7. 如权利要求1-6中任一项所述的代码控制方法,其中,在所述根据所述硬件信息调用所述第二应用程序编程接口以控制所述特定目标代码的执行顺序不被向后调整之后,所述代码控制方法进一步包括编译用于代表解锁操作的源代码,
    所述解锁操作包括:释放所述令牌。
  8. 如权利要求1-7中任一项所述的代码控制方法,其中,所述特定源代码包括用于代表以下操作的源代码:
    从存储器中获取期望数据;
    修改所述期望数据;以及
    将经修改的期望数据存储到所述存储器。
  9. 如权利要求1-8任一项所述的代码控制方法,其中,所述硬件信息包括以下项中的一项或多项:所述设备上的操作系统的内核版本、所述设备的处理器架构。
  10. 一种代码控制装置,包括:
    获取模块,用于获取设备的硬件信息;以及
    调用模块,用于根据所述硬件信息调用所述设备上的操作系统的特定应用程序编程接口,所述特定应用程序编程接口用于控制通过编译特定源代码所获得的特定目标代码在所述设备上的执行以使得所述特定目标代码的执行顺序与所述特定源代码所指示的执行顺序一致。
  11. 如权利要求10所述的代码控制装置,其中,所述特定应用程序编程接口包括第一应用程序编程接口,
    所述调用模块进一步包括第一调用子模块,用于在编译所述特定源代码之前,根据所述硬件信息调用所述第一应用程序编程接口以控制所述特定目标代码的执行顺序不被向前调整。
  12. 如权利要求11所述的代码控制装置,其中,所述代码控制装置进一步包括第一标识确定模块,用于确定存在用于指示所述第一应用程序编程 接口的第一标识。
  13. 如权利要求11或12所述的代码控制装置,其中,所述代码控制装置进一步包括第一编译模块,用于编译用于代表锁定操作的源代码,
    所述锁定操作包括:
    设置令牌;以及
    按照时间顺序向最早请求期望数据的进程分配所述令牌,
    其中,所述特定源代码所代表的操作由占有所述令牌的进程执行。
  14. 如权利要求10-13中任一项所述的代码控制装置,其中,所述特定应用程序编程接口包括第二应用程序编程接口,
    所述调用模块进一步包括第二调用子模块,用于在编译所述特定源代码之后,根据所述硬件信息调用所述第二应用程序编程接口以控制所述特定目标代码的执行顺序不被向后调整。
  15. 如权利要求14所述的代码控制装置,其中,所述代码控制装置进一步包括第二标识确定模块,用于确定存在用于指示所述第二应用程序编程接口的第二标识。
  16. 如权利要求10-15中任一项所述的代码控制装置,其中,所述代码控制装置进一步包括第二编译模块,用于编译用于代表解锁操作的源代码,
    所述解锁操作包括:释放所述令牌。
  17. 如权利要求10-16中任一项所述的代码控制装置,其中,所述特定源代码包括用于代表以下操作的源代码:
    从存储器中获取期望数据;
    修改所述期望数据;以及
    将经修改的期望数据存储到所述存储器。
  18. 如权利要求10-17任一项所述的代码控制装置,其中,所述硬件信息包括以下项中的一项或多项:所述设备上的操作系统的内核版本、所述设备的处理器架构。
  19. 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行根据权利要求1-9中任一项所述的代码控制方法。
  20. 一种计算机可读介质,其中存储了如权利要求19所述的计算机程序。
PCT/CN2017/079070 2016-03-31 2017-03-31 代码控制方法和装置 Ceased WO2017167289A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610201574.4A CN105892997B (zh) 2016-03-31 2016-03-31 代码控制方法和装置
CN201610201574.4 2016-03-31

Publications (1)

Publication Number Publication Date
WO2017167289A1 true WO2017167289A1 (zh) 2017-10-05

Family

ID=57012131

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/079070 Ceased WO2017167289A1 (zh) 2016-03-31 2017-03-31 代码控制方法和装置

Country Status (2)

Country Link
CN (1) CN105892997B (zh)
WO (1) WO2017167289A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113238757A (zh) * 2021-04-10 2021-08-10 北京猿力未来科技有限公司 编程指令的识别方法及装置

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105892997B (zh) * 2016-03-31 2019-02-19 北京奇虎科技有限公司 代码控制方法和装置
CN106650421B (zh) * 2016-12-27 2020-04-28 中国民生银行股份有限公司 程序处理方法、装置及设备
CN107093048A (zh) * 2017-04-25 2017-08-25 广州麦海知识产权服务有限公司 一种大件商品库存调度方法及系统
CN110333851B (zh) * 2019-06-12 2023-06-16 平安科技(深圳)有限公司 代码解耦方法及相关设备
CN114595445A (zh) * 2022-02-10 2022-06-07 深圳市小满科技有限公司 一种任务处理方法、装置与相关产品
CN116346963A (zh) * 2023-03-06 2023-06-27 东南大学 网络通信方法、设备、介质和程序产品

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040088690A1 (en) * 2002-08-27 2004-05-06 Hayim Shaul Method for accelerating a computer application by recompilation and hardware customization
CN101542437A (zh) * 2005-12-07 2009-09-23 微软公司 软件事务性存储器操作的优化
CN104572235A (zh) * 2014-12-31 2015-04-29 北京奇虎科技有限公司 一种可加载内核模块的编译方法和装置
CN104679504A (zh) * 2013-12-02 2015-06-03 英特尔公司 基于可执行代码的平台选择
CN105892997A (zh) * 2016-03-31 2016-08-24 北京奇虎科技有限公司 代码控制方法和装置

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030101439A1 (en) * 2001-11-29 2003-05-29 Giuseppe Desoli System and method for supporting emulation of a computer system through dynamic code caching and transformation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040088690A1 (en) * 2002-08-27 2004-05-06 Hayim Shaul Method for accelerating a computer application by recompilation and hardware customization
CN101542437A (zh) * 2005-12-07 2009-09-23 微软公司 软件事务性存储器操作的优化
CN104679504A (zh) * 2013-12-02 2015-06-03 英特尔公司 基于可执行代码的平台选择
CN104572235A (zh) * 2014-12-31 2015-04-29 北京奇虎科技有限公司 一种可加载内核模块的编译方法和装置
CN105892997A (zh) * 2016-03-31 2016-08-24 北京奇虎科技有限公司 代码控制方法和装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113238757A (zh) * 2021-04-10 2021-08-10 北京猿力未来科技有限公司 编程指令的识别方法及装置
CN113238757B (zh) * 2021-04-10 2023-10-31 北京猿力未来科技有限公司 编程指令的识别方法及装置

Also Published As

Publication number Publication date
CN105892997A (zh) 2016-08-24
CN105892997B (zh) 2019-02-19

Similar Documents

Publication Publication Date Title
US8375175B2 (en) Fast and efficient reacquisition of locks for transactional memory systems
US8180986B2 (en) Memory conflict detection via mapping of the physical heap to control access permissions to the memory
CN106708975B (zh) 商品库存信息的处理方法及系统
US7899997B2 (en) Systems and methods for implementing key-based transactional memory conflict detection
US9563446B2 (en) Binary file generation
US20080320282A1 (en) Method And Systems For Providing Transaction Support For Executable Program Components
US11972777B2 (en) Reader bias based locking technique enabling high read concurrency for read-mostly workloads
US9075634B2 (en) Minimizing overhead in resolving operating system symbols
CN105892997B (zh) 代码控制方法和装置
JP2005332387A (ja) メモリ命令をグループ化及び管理する方法及びシステム
EP2049992A1 (en) Software transactional protection of managed pointers
US10019258B2 (en) Hardware assisted software versioning of clustered applications
US8327084B2 (en) Method and apparatus to trigger synchronization and validation actions upon memory access
US9189297B2 (en) Managing shared memory
CN112783954A (zh) 数据访问方法、装置及服务器
CN116049207A (zh) 应用程序sql脚本处理方法、装置、处理器及电子设备
US10599617B2 (en) Methods and apparatus to modify a binary file for scalable dependency loading on distributed computing systems
US7818756B2 (en) SKU determination mechanism and API
CN114490686A (zh) 多个数据源的切换方法、装置、系统以及介质
US10725667B2 (en) Method of transferring data in parallel system, and parallel system for performing the same
CN116501812B (zh) Ddl语句执行方法及装置
CN118295669B (zh) 一种确定全局偏移表的方法、装置及电子设备
CN117312462B (zh) 一种关系的处理方法、装置及电子设备
JP6610037B2 (ja) テスト実施装置、方法、および、プログラム
US9542342B2 (en) Smart holding registers to enable multiple register accesses

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

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

Ref document number: 17773319

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 17773319

Country of ref document: EP

Kind code of ref document: A1