Movatterモバイル変換


[0]ホーム

URL:


CN106445656A - Method and device for realizing thread local storage - Google Patents

Method and device for realizing thread local storage
Download PDF

Info

Publication number
CN106445656A
CN106445656ACN201610806319.2ACN201610806319ACN106445656ACN 106445656 ACN106445656 ACN 106445656ACN 201610806319 ACN201610806319 ACN 201610806319ACN 106445656 ACN106445656 ACN 106445656A
Authority
CN
China
Prior art keywords
global
local storage
variable
task
pointer
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.)
Granted
Application number
CN201610806319.2A
Other languages
Chinese (zh)
Other versions
CN106445656B (en
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 University of Posts and Telecommunications
Original Assignee
Beijing University of Posts and Telecommunications
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 University of Posts and TelecommunicationsfiledCriticalBeijing University of Posts and Telecommunications
Priority to CN201610806319.2ApriorityCriticalpatent/CN106445656B/en
Publication of CN106445656ApublicationCriticalpatent/CN106445656A/en
Application grantedgrantedCritical
Publication of CN106445656BpublicationCriticalpatent/CN106445656B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本发明公开了一种实现线程本地存储的方法及装置。本发明的方法将全局变量转换为任务的线程本地存储变量以实现线程本地存储,包括:将源代码中的所述全局变量修改为全局指针;在操作系统的任务切换回调函数中增加全局指针地址切换操作;为所述全局变量分配线程本地存储任务局部存储空间;通过所述全局指针来完成对所述线程本地存储变量的访问。根据本发明的方法和装置,可以将全局变量转换为任务的TLS变量从而实现TLS。本发明的方法不需要处理器、编译器提供特殊支持,也不修改原有操作系统,具有很高的应用灵活度。本发明的方法大大降低了TLS的实施难度,扩展了TLS的应用范围。

The invention discloses a method and a device for realizing thread local storage. The method of the present invention converts the global variable into the thread local storage variable of the task to realize the thread local storage, including: modifying the global variable in the source code into a global pointer; adding the global pointer address in the task switching callback function of the operating system Switching operation; allocate thread local storage task local storage space for the global variable; complete access to the thread local storage variable through the global pointer. According to the method and device of the present invention, global variables can be converted into TLS variables of tasks so as to realize TLS. The method of the invention does not require special support from processors and compilers, and does not modify the original operating system, so it has high application flexibility. The method of the invention greatly reduces the implementation difficulty of TLS and expands the application range of TLS.

Description

Translated fromChinese
一种实现线程本地存储的方法及装置A method and device for implementing thread local storage

技术领域technical field

本发明涉及计算机软件技术领域,具体说涉及一种实现线程本地存储的方法及装置。The invention relates to the technical field of computer software, in particular to a method and device for realizing thread local storage.

背景技术Background technique

当前主流的嵌入式操作系统基本上是采用C语言实现的多任务操作系统,而且所有任务共享同一个地址空间。在这种系统中,变量或数据有2种基本的存储方式:局部变量和全局变量。局部变量在函数中定义,使用时在各任务的函数调用堆栈中由编译器自动分配,局部变量不会再各任务间共享;而全局变量是全局的或者静态的,所有任务访问的都是同一份数据,如果某一个任务对其进行了修改,也就会影响到其他所有的任务,这会使得使用全局变量的函数不可重入,无法直接在多任务操作系统这种高度并发的环境下使用。The current mainstream embedded operating system is basically a multi-task operating system implemented in C language, and all tasks share the same address space. In this system, there are two basic storage methods for variables or data: local variables and global variables. Local variables are defined in functions, and are automatically allocated by the compiler in the function call stack of each task when used. Local variables will not be shared between tasks; global variables are global or static, and all tasks access the same If a task modifies it, it will affect all other tasks, which will make the functions using global variables non-reentrant and cannot be directly used in a highly concurrent environment such as a multi-tasking operating system. .

在嵌入式开发领域经常会使用到第三方的开源代码和库,这些源代码经常是针对Linux\Unix\Windows等具有进程抽象的操作系统环境开发的,代码是为每一个进程单独编译链接,存在进程自己独立的地址空间中,并没有考虑到源代码的并发访问问题。In the field of embedded development, third-party open source codes and libraries are often used. These source codes are often developed for Linux\Unix\Windows and other operating system environments with process abstraction. The code is compiled and linked separately for each process. In the process's own independent address space, the issue of concurrent access to the source code is not considered.

要在单一地址空间的多任务操作系统环境中使用这些代码,需要新的变量实现机制,使得各个函数调用都能访问、但其它任务不能访问变量。业界一般称作线程本地存储(Thread Local Storage,简称TLS)。To use these codes in a multitasking operating system environment with a single address space, a new variable implementation mechanism is required, so that each function call can access the variable, but other tasks cannot access the variable. The industry generally calls it Thread Local Storage (TLS for short).

目前,线程本地存储的实现方法有以下几种:Currently, the implementation methods of thread local storage are as follows:

1.静态TLS。通过编译器和操作系统共同支持。一般是在源代码中需要使用TLS变量的地方插入特定的TLS变量声明关键字(如Microsoft给Visual C++编译器添加的__declspec(thread)关键字),然后扩充编译器,编译时将声明的TLS变量放到生成的目标文件的特定的节中。在运行时,操作系统把带有TLS节的程序加载到内存中时,寻找可执行文件中的TLS节,并且动态地分配一个足够大的内存块,以便存放所有的静态TLS变量。应用程序中的代码每次引用其中的一个变量时,就要转换为已分配内存块中包含的一个内存位置。因此,编译器必须生成一些辅助代码来引用该静态TLS变量,这将使得程序变大且运行的速度降低。1. Static TLS. Both compiler and operating system support. Generally, a specific TLS variable declaration keyword (such as the __declspec(thread) keyword added by Microsoft to the Visual C++ compiler) is inserted in the place where TLS variables need to be used in the source code, and then the compiler is expanded to compile the declared TLS Variables are placed in specific sections of the generated object files. At runtime, when the operating system loads a program with a TLS section into memory, it looks for the TLS section in the executable file and dynamically allocates a block of memory large enough to store all the static TLS variables. Every time code in the application references one of these variables, it is converted to a memory location contained in the allocated memory block. Therefore, the compiler has to generate some auxiliary code to refer to this static TLS variable, which will make the program larger and run slower.

2.动态TLS。通过专用的线程库函数实现变量的动态分配、访问和释放。例如pthread线程库可以通过pthread_key_create函数动态创建TLS变量,Windows通过内核提供接口函数TLSAlloc分配TLS变量。此种办法的实现方式是为每个线程创建线程专享的TLS变量索引表,在线程访问TLS变量时,通过查询本线程的索引表获得要访问的TLS变量的地址。2. Dynamic TLS. Dynamic allocation, access and release of variables are realized through dedicated thread library functions. For example, the pthread thread library can dynamically create TLS variables through the pthread_key_create function, and Windows provides the interface function TLSAlloc through the kernel to allocate TLS variables. The implementation of this method is to create a thread-specific TLS variable index table for each thread. When a thread accesses a TLS variable, the address of the TLS variable to be accessed is obtained by querying the index table of the thread.

以上实现TLS的方法要么需要扩充编译器,要么需要提供专用的函数库,要么需要处理器做特殊的支持。在嵌入式开发领域,上述实现TLS的方法具有很大的局限性。The above methods of implementing TLS either need to expand the compiler, or need to provide a dedicated function library, or need special support from the processor. In the field of embedded development, the above-mentioned methods for implementing TLS have great limitations.

因此,为了进一步提高实现TLS的方法的应用灵活性,扩展TLS的应用范围,需要一种新的实现TLS的方法。Therefore, in order to further improve the application flexibility of the method for implementing TLS and expand the application range of TLS, a new method for implementing TLS is needed.

发明内容Contents of the invention

为了进一步提高实现TLS的方法的应用灵活性,扩展TLS的应用范围,本发明提供了一种实现线程本地存储的方法,将全局变量转换为任务的线程本地存储变量以实现线程本地存储,包括:In order to further improve the application flexibility of the method for realizing TLS and expand the application scope of TLS, the present invention provides a method for realizing thread local storage, which converts global variables into thread local storage variables of tasks to realize thread local storage, including:

将源代码中的所述全局变量修改为全局指针;Modifying the global variable in the source code into a global pointer;

在操作系统的任务切换回调函数中增加全局指针地址切换操作;Add the global pointer address switching operation in the task switching callback function of the operating system;

为所述全局变量分配线程本地存储任务局部存储空间;Allocating thread local storage task local storage space for the global variable;

通过所述全局指针来完成对所述线程本地存储变量的访问。The access to the thread local storage variable is accomplished through the global pointer.

在一实施例中,将全局变量修改为全局指针,其中,将所有全局变量的类型收集到一个总的全局数据结构体中,并生成一个指向所述全局数据结构体的全局指针。In an embodiment, the global variable is modified into a global pointer, wherein the types of all global variables are collected into a general global data structure, and a global pointer pointing to the global data structure is generated.

在一实施例中,对全局变量的定义进行注释,防止编译器编译时再分配静态空间。In one embodiment, the definition of the global variable is annotated to prevent the compiler from allocating static space during compilation.

在一实施例中,将对全局变量的访问,修改为通过全局指针的访问,防止编译器对全局变量的访问进行静态绑定。In one embodiment, the access to the global variable is changed to an access through the global pointer, preventing the compiler from performing static binding on the access to the global variable.

在一实施例中,在操作系统的任务切换回调函数中增加所述全局指针地址切换操作,其中:In one embodiment, the global pointer address switching operation is added to the task switching callback function of the operating system, wherein:

初始化时,将线程本地存储变量空间的指针切换函数挂接到操作系统系统中的切换回调函数中。During initialization, the pointer switching function of the thread local storage variable space is hooked into the switching callback function in the operating system.

在一实施例中,为所述全局变量分配线程本地存储任务局部存储空间,其中:In one embodiment, a thread local storage task local storage space is allocated for the global variable, wherein:

所述任务在调用含有全局变量的函数前,调用线程本地存储变量创建操作,为当前线程分配一份所述全局变量的本地存储空间。Before calling the function containing the global variable, the task calls the creation operation of the thread local storage variable, and allocates a local storage space of the global variable for the current thread.

在一实施例中,将当前任务的任务标识绑定到线程本地存储变量本地存储空间的首地址。In one embodiment, the task identifier of the current task is bound to the first address of the local storage space of the thread local storage variable.

在一实施例中,通过所述全局指针来完成对所述线程本地存储变量的访问,其中:In one embodiment, the access to the thread local storage variable is accomplished through the global pointer, wherein:

在操作系统进行任务切换时,回调函数通过被切入任务的标识找到其对应的线程本地存储变量本地存储空间的首地址,将该地址赋值给所述全局指针。When the operating system performs task switching, the callback function finds the first address of the corresponding thread local storage variable local storage space through the identifier of the switched task, and assigns the address to the global pointer.

在一实施例中,所述任务在不需要使用全局变量时,调用线程本地存储变量释放操作,释放之前分配的本地存储空间。In an embodiment, when the task does not need to use the global variable, it calls a thread local storage variable release operation to release the previously allocated local storage space.

本发明还提出了一种基于多任务操作系统的实现线程本地存储的装置,所述装置配置为将全局变量转换为任务的线程本地存储变量以实现线程本地存储,所述装置包括:The present invention also proposes a device for implementing thread local storage based on a multitasking operating system, the device is configured to convert global variables into thread local storage variables of tasks to realize thread local storage, and the device includes:

源程序修改单元,其配置为将源代码中的所述全局变量修改为全局指针;a source program modification unit configured to modify the global variable in the source code into a global pointer;

存储空间分配单元,其配置为所述全局变量分配线程本地存储任务局部存储空间;a storage space allocation unit configured to allocate a thread local storage task local storage space for the global variable;

变量指针切换单元,其配置为在操作系统的任务切换回调函数中增加全局指针地址切换操作;A variable pointer switching unit configured to add a global pointer address switching operation in the task switching callback function of the operating system;

访问单元,其配置为通过所述全局指针来完成对所述线程本地存储变量的访问。An access unit configured to access the thread local storage variable through the global pointer.

根据本发明的方法和装置,可以将全局变量转换为任务的TLS变量从而实现TLS。本发明的方法不需要处理器、编译器提供特殊支持,也不修改原有操作系统,具有很高的应用灵活度。本发明的方法大大降低了TLS的实施难度,扩展了TLS的应用范围。According to the method and device of the present invention, global variables can be converted into TLS variables of tasks so as to realize TLS. The method of the present invention does not require special support from processors and compilers, does not modify the original operating system, and has high application flexibility. The method of the invention greatly reduces the implementation difficulty of TLS and expands the application range of TLS.

本发明的其它特征或优点将在随后的说明书中阐述。并且,本发明的部分特征或优点将通过说明书而变得显而易见,或者通过实施本发明而被了解。本发明的目的和部分优点可通过在说明书、权利要求书以及附图中所特别指出的步骤来实现或获得。Additional features or advantages of the invention will be set forth in the ensuing description. And, some features or advantages of the present invention will be apparent from the description, or be understood by practicing the present invention. The objects and some of the advantages of the invention will be realized or obtained by the steps particularly pointed out in the written description, claims as well as the appended drawings.

附图说明Description of drawings

附图用来提供对本发明的进一步理解,并且构成说明书的一部分,与本发明的实施例共同用于解释本发明,并不构成对本发明的限制。在附图中:The accompanying drawings are used to provide a further understanding of the present invention, and constitute a part of the description, and are used together with the embodiments of the present invention to explain the present invention, and do not constitute a limitation to the present invention. In the attached picture:

图1是根据本发明一实施例的方法流程图;Fig. 1 is a method flowchart according to an embodiment of the present invention;

图2是根据本发明一实施例的系统结构简图。Fig. 2 is a schematic diagram of a system structure according to an embodiment of the present invention.

具体实施方式detailed description

以下将结合附图及实施例来详细说明本发明的实施方式,借此本发明的实施人员可以充分理解本发明如何应用技术手段来解决技术问题,并达成技术效果的实现过程并依据上述实现过程具体实施本发明。需要说明的是,只要不构成冲突,本发明中的各个实施例以及各实施例中的各个特征可以相互结合,所形成的技术方案均在本发明的保护范围之内。The implementation of the present invention will be described in detail below in conjunction with the accompanying drawings and examples, so that implementers of the present invention can fully understand how the present invention uses technical means to solve technical problems, and achieve the realization process of technical effects and according to the above-mentioned realization process The present invention is implemented concretely. It should be noted that, as long as there is no conflict, each embodiment and each feature in each embodiment of the present invention can be combined with each other, and the formed technical solutions are all within the protection scope of the present invention.

在现有技术环境下,实现TLS的方法要么需要扩充编译器,要么需要提供专用的函数库,要么需要处理器做特殊的支持。在嵌入式开发领域,上述实现TLS的方法具有很大的局限性。Under the current technical environment, the method of implementing TLS either needs to expand the compiler, or needs to provide a dedicated function library, or needs special support from the processor. In the field of embedded development, the above-mentioned methods for implementing TLS have great limitations.

为了进一步提高实现TLS的方法的应用灵活性,扩展TLS的应用范围,本发明的发明人首先分析了导致现有技术局限性的根本原因。In order to further improve the application flexibility of the method for implementing TLS and expand the application range of TLS, the inventors of the present invention firstly analyzed the root cause of the limitations of the prior art.

首先,在目标机资源有限时,一般不会在已有的操作系统上再增加一个线程库;First of all, when the resources of the target machine are limited, it is generally not necessary to add another thread library to the existing operating system;

其次,现有的方法中所使用的处理器、操作系统和开发工具都是根据具体的任务需求进行专门选型,然而特定于编译器、处理器和操作系统的技术往往需要对原技术进行改动,很难通用;Secondly, the processors, operating systems and development tools used in the existing methods are specially selected according to specific task requirements, but the technologies specific to compilers, processors and operating systems often require changes to the original technology , it is difficult to generalize;

再次,现有的方法都是针对新写的代码而实施的,很难把已有代码中的全局变量修改为TLS变量。Again, the existing methods are all implemented for newly written codes, and it is difficult to modify the global variables in the existing codes into TLS variables.

在把已有的全局全局变量修改为TLS变量的问题上,有一种常用的手工做法是:将源代码中的所有全局变量都变成函数指针参数,在线程进行函数调用前为每个全局变量分配空间,并将变量指针通过函数参数层层传递到需要使用了全局变量的位置。这种办法在代码量较少,函数调用关系简单的时候,是个简单而有效的办法,但是一旦使用的代码稍微复杂,全局变量一多,转换的难度和出错的概率都很大,而且通过函数传递所有全局变量会极大的加深堆栈,影响程序效率(因为全局变量的指针需要从顶层函数的栈帧一直传递到堆栈最底层。)On the issue of modifying existing global variables to TLS variables, there is a common manual method: turn all global variables in the source code into function pointer parameters, and set each global variable before the thread calls the function Allocate space, and pass variable pointers through function parameters layer by layer to locations where global variables need to be used. This method is a simple and effective method when the amount of code is small and the relationship between function calls is simple. Passing all global variables will greatly deepen the stack and affect the efficiency of the program (because the pointer of the global variable needs to be passed from the stack frame of the top-level function to the bottom of the stack.)

基于上述分析,本发明提出了一种实现TLS的方法。本发明的方法基于嵌入式多任务操作系统实现,其主要操作是将全局变量转换为任务的TLS变量。这样,在不需要处理器、编译器提供特殊支持,也不修改原有操作系统实现的基础上实现TLS。从而克服现有技术在嵌入式开发领域的不足。Based on the above analysis, the present invention proposes a method for realizing TLS. The method of the present invention is realized based on an embedded multi-task operating system, and its main operation is to convert global variables into TLS variables of tasks. In this way, TLS can be implemented on the basis of not requiring special support from processors and compilers, and without modifying the implementation of the original operating system. Thereby overcoming the deficiencies of the prior art in the field of embedded development.

具体的,在一实施例中,将全局变量转换为任务的TLS变量的过程包括:将源代码中的全局变量修改为全局指针;为全局变量分配线程本地存储任务局部存储空间;在操作系统的任务切换回调函数中增加全局指针地址切换操作。最后就可以通过全局指针来完成对线程本地存储变量的访问。依照上述步骤,既可以为新代码增加TLS支持,也可以方便的将已有代码的全局变量修改为TLS变量,从而解决访问全局变量的并发问题。Specifically, in one embodiment, the process of converting a global variable into a TLS variable of a task includes: modifying the global variable in the source code into a global pointer; assigning a thread local storage task local storage space for the global variable; The global pointer address switching operation is added in the task switching callback function. Finally, access to thread-local storage variables can be accomplished through the global pointer. According to the above steps, TLS support can be added to the new code, and the global variable of the existing code can be easily modified to a TLS variable, so as to solve the concurrency problem of accessing the global variable.

接下来基于附图详细描述本发明一实施例的具体执行流程。附图的流程图中示出的步骤可以在包含诸如一组计算机可执行指令的计算机系统中执行。虽然在流程图中示出了各步骤的逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。Next, a specific execution process of an embodiment of the present invention will be described in detail based on the accompanying drawings. The steps shown in the flowcharts of the figures can be performed in a computer system comprising, for example, a set of computer-executable instructions. Although a logical order of steps is shown in the flowcharts, in some cases the steps shown or described may be performed in an order different from that shown or described herein.

在本发明一实施例中,首先修改源代码中的全局变量,将源程序中的全局变量修改为全局指针(步骤S110)。具体的,将所有全局变量的类型收集到一个总的全局数据结构体中,并生成一个指向该总的全局数据结构体的全局指针(global_tls_ptr)。In an embodiment of the present invention, first modify the global variable in the source code, and modify the global variable in the source program into a global pointer (step S110). Specifically, the types of all global variables are collected into a general global data structure, and a global pointer (global_tls_ptr) pointing to the general global data structure is generated.

进一步的,在一实施例中,在步骤S110中对全局变量的定义进行注释,防止编译器编译时再分配静态空间;进一步的,在一实施例中,对全局变量的访问,修改为通过全局指针的访问,防止编译器对全局变量的访问进行静态绑定。Further, in one embodiment, the definition of the global variable is annotated in step S110 to prevent the compiler from allocating static space during compilation; further, in one embodiment, the access to the global variable is modified to pass through the global Pointer access prevents the compiler from performing static binding on access to global variables.

接下来,初始化时增加指针切换操作(步骤S120)。具体的,将TLS变量空间的指针切换函数挂接到操作系统系统中的切换回调函数中。例如,在嵌入式领域常用的多任务操作系统(如VxWorks、RTEMS、μC/OS等)中,基本都提供了任务切换时的回调函数。Next, a pointer switching operation is added during initialization (step S120). Specifically, the pointer switching function of the TLS variable space is hooked into the switching callback function in the operating system. For example, in the multi-tasking operating systems commonly used in the embedded field (such as VxWorks, RTEMS, μC/OS, etc.), callback functions during task switching are basically provided.

任务在调用含有全局变量的函数前,需要为线程分配本地存储空间(步骤S130)。具体的,调用TLS变量创建操作,为当前线程分配一份全局变量的本地存储空间。同时,将当前任务的任务标识(ID)绑定到TLS变量本地存储空间的首地址。Before the task calls the function containing the global variable, it needs to allocate a local storage space for the thread (step S130). Specifically, the TLS variable creation operation is invoked to allocate a local storage space of the global variable for the current thread. At the same time, bind the task identifier (ID) of the current task to the first address of the local storage space of the TLS variable.

进一步的,在分配TLS任务本地存储空间的过程中,TLS变量的本地存储空间位置是与任务绑定的,实现时有3种选择:全局静态区、任务堆栈、任务控制块。由于任务控制块在已有操作系统的实现上,大小固定,不修改操作系统无法实现,任务控制块并不适合。因此在本发明一实施例中主要使用全局静态数组或者任务堆栈。Furthermore, in the process of allocating the local storage space of the TLS task, the location of the local storage space of the TLS variable is bound to the task, and there are three options for implementation: the global static area, the task stack, and the task control block. Since the size of the task control block is fixed in the implementation of the existing operating system, it cannot be realized without modifying the operating system, so the task control block is not suitable. Therefore, in an embodiment of the present invention, a global static array or a task stack is mainly used.

在具体的开发环境中,如果需要TLS变量的任务数量在运行前就能确定,那么优先选择静态区,在嵌入式开发领域这是很常见的一种情况。如果任务数量动态变化,而且任务在退出后就TLS变量就不需要被别的程序访问了,那么也可以使用任务堆栈。In a specific development environment, if the number of tasks that require TLS variables can be determined before running, then the static area is preferred. This is a very common situation in the embedded development field. If the number of tasks changes dynamically, and the TLS variables do not need to be accessed by other programs after the task exits, then the task stack can also be used.

在操作系统进行任务切换时,查找线程本地存储变量的本地存储空间(步骤S140)。具体的,回调函数通过被切入任务的ID找到其对应的TLS变量本地存储空间的首地址,将该地址赋值给global_tls_ptr指针。因为通过第一步的操作,所有全局变量的使用都是通过指针进行的,如此,通过切换指针,就能完成任务全局变量到本地存储空间的转换。When the operating system performs task switching, the local storage space of the thread local storage variable is searched (step S140). Specifically, the callback function finds the first address of the corresponding TLS variable local storage space through the ID of the switched-in task, and assigns the address to the global_tls_ptr pointer. Because through the operation of the first step, all global variables are used through pointers, so by switching pointers, the conversion of task global variables to local storage space can be completed.

进一步的,在本发明一实施例中,在任务切换时,通过切入任务的ID查找对应的存储空间地址,通过一个hash函数对任务ID进行hash,以提高查找速率。Further, in an embodiment of the present invention, when the task is switched, the ID of the cut-in task is used to search for the corresponding storage space address, and a hash function is used to hash the task ID to increase the search rate.

此时,就通过全局变量的指针来完成对TLS变量的访问(步骤S150)。要注意的是,不同于其余TLS变量的技术手段,需要通过特殊的API来访问TLS变量,本发明仍然是通过全局指针来访问,不需要增加任何API,所以,即使不用在多任务环境,也不会影响程序的使用,具有很好的可移植性。At this time, the access to the TLS variable is completed through the pointer of the global variable (step S150). It should be noted that, unlike other technical means of TLS variables, TLS variables need to be accessed through a special API. It will not affect the use of the program and has good portability.

最后,当任务在不需要使用全局变量时,调用TLS变量释放操作,释放之前分配的本地存储空间(步骤S160)。Finally, when the task does not need to use the global variable, it calls the TLS variable release operation to release the previously allocated local storage space (step S160).

根据本发明的方法,可以将全局变量转换为任务的TLS变量从而实现TLS。本发明的方法不需要处理器、编译器提供特殊支持,也不修改原有操作系统,只需要操作系统提供一个任务切换回调函数接口就能实现,对编译器、操作系统的依赖很少,具有很高的应用灵活度。According to the method of the present invention, the global variable can be converted into the TLS variable of the task so as to realize TLS. The method of the present invention does not require special support from processors and compilers, and does not modify the original operating system. It can be realized only by providing a task switching callback function interface provided by the operating system, and has little dependence on compilers and operating systems. High application flexibility.

本发明的方法不需要在源代码中使用特殊的TLS变量访问函数,在其余操作系统上也能直接使用,大大降低了TLS的实施难度,扩展了TLS的应用范围。进一步的,根据本发明的方法,任务在切换TLS变量存储空间时,只需要修改一个指针就能完成切换操作,对原有系统的效率影响很小。The method of the invention does not need to use a special TLS variable access function in the source code, and can be used directly on other operating systems, greatly reducing the implementation difficulty of TLS and expanding the application range of TLS. Furthermore, according to the method of the present invention, when the task switches the TLS variable storage space, only one pointer needs to be modified to complete the switching operation, which has little impact on the efficiency of the original system.

基于本发明的方法,本发明还提出了一种基于多任务操作系统的实现线程本地存储的装置。本发明的装置配置为将全局变量转换为任务的线程本地存储变量以实现线程本地存储。在一实施例中,如图2所示,装置200包括:Based on the method of the present invention, the present invention also proposes a device for implementing thread local storage based on a multi-task operating system. The device of the present invention is configured to convert the global variable into a thread local storage variable of a task to realize thread local storage. In one embodiment, as shown in FIG. 2 , the device 200 includes:

源程序修改单元220,其配置为将源代码中的全局变量修改为全局指针;A source program modifying unit 220 configured to modify the global variable in the source code into a global pointer;

存储空间分配单元240,其配置为全局变量分配线程本地存储任务局部存储空间(线程本地存储任务局部存储空间被构造在本地存储空间202中);A storage space allocation unit 240 configured to allocate a thread local storage task local storage space for the global variable (the thread local storage task local storage space is constructed in the local storage space 202);

变量指针切换单元230,其配置为在操作系统的任务切换回调函数201中增加全局指针地址切换操作;The variable pointer switching unit 230 is configured to add a global pointer address switching operation in the task switching callback function 201 of the operating system;

访问单元210,其配置为通过全局指针来完成对线程本地存储变量的访问。The access unit 210 is configured to complete the access to the thread local storage variable through the global pointer.

在运行过程中,源程序修改单元220对全局变量的定义进行注释,防止编译器编译时再分配静态空间;并且将对全局变量的访问,修改为通过全局指针的访问,防止编译器对全局变量的访问进行静态绑定;同时,将所有全局变量的类型收集到一个总的全局数据结构体中,并生成一个指向全局数据结构体的全局指针。During operation, the source program modification unit 220 annotates the definition of the global variable to prevent the compiler from allocating static space when compiling; Static binding for access; at the same time, collect the types of all global variables into a total global data structure, and generate a global pointer pointing to the global data structure.

初始化时,变量指针切换单元230将线程本地存储变量空间的指针切换函数挂接到操作系统系统中的切换回调函数中。During initialization, the variable pointer switching unit 230 hooks the pointer switching function of the thread local storage variable space into the switching callback function in the operating system.

在任务在调用含有全局变量的函数前,存储空间分配单元240调用线程本地存储变量创建操作,为当前线程分配一份全局变量的本地存储空间(在本地存储空间202中构造线程本地存储任务局部存储空间)。同时,存储空间分配单元240构造任务ID与TLS任务本地存储空间地址的索引表。将当前任务的任务标识绑定到线程本地存储变量本地存储空间的首地址。Before the task calls the function that contains the global variable, the storage space allocation unit 240 invokes the creation operation of the thread local storage variable, and allocates a local storage space of the global variable for the current thread (constructing the thread local storage task local storage in the local storage space 202) space). At the same time, the storage space allocation unit 240 constructs an index table of the task ID and the address of the local storage space of the TLS task. Bind the task ID of the current task to the first address of the local storage space of the thread local storage variable.

这样,在操作系统进行任务切换时,回调函数通过被切入任务的标识找到其对应的线程本地存储变量本地存储空间的首地址,将该地址赋值给所述全局指针。从而使得访问单元210可以通过全局指针(基于任务ID与TLS任务本地存储空间地址的索引表)来完成对线程本地存储变量的访问。In this way, when the operating system performs task switching, the callback function finds the first address of the corresponding thread local storage variable local storage space through the identifier of the switched-in task, and assigns the address to the global pointer. Thus, the access unit 210 can complete the access to the thread local storage variable through the global pointer (an index table based on the task ID and the address of the TLS task local storage space).

最后,装置200还包含释放单元250。任务在不需要使用全局变量时,释放单元250调用线程本地存储变量释放操作,释放之前分配的本地存储空间。Finally, the device 200 also includes a release unit 250 . When the task does not need to use the global variable, the release unit 250 calls the thread local storage variable release operation to release the previously allocated local storage space.

接下来通过一个具体的应用实例对本发明一实施例的方法以及装置执行流程做进一步的描述(该应用实例以图2所示的装置结构为基础)。Next, a specific application example is used to further describe the execution flow of the method and the device in one embodiment of the present invention (the application example is based on the device structure shown in FIG. 2 ).

A)源程序修改单元220完成源代码的预处理,将全局变量修改为全局指针。A) The source program modifying unit 220 completes the preprocessing of the source code, and modifies the global variable into a global pointer.

具体的,取源程序中的2个全局变量为例:Specifically, take two global variables in the source program as an example:

通过第一步修改全局变量为全局指针后,将产生如下的代码:After modifying the global variable to a global pointer through the first step, the following code will be generated:

其中的全局变量id和desc_cr的定义被注释掉,新生成了一个包含所有全局变量类型的结构体struct task_tls_space,id和desc_cr的访问函数被替换为global_tls_ptr->id和global_tls_ptr->desc_cr.cmd。由于这种变换是很有规律性的,因此在本发明一实施例中,可以通过手工或者预处理器方便的实现。The definitions of the global variables id and desc_cr are commented out, and a structure struct task_tls_space containing all global variable types is newly generated, and the access functions of id and desc_cr are replaced by global_tls_ptr->id and global_tls_ptr->desc_cr.cmd. Since this transformation is very regular, in an embodiment of the present invention, it can be conveniently realized manually or by a preprocessor.

这样就可以构造出TLS全局变量指针。所有的全局变量都通过指针寻址。In this way, the TLS global variable pointer can be constructed. All global variables are addressed by pointers.

如例中的全局指针就是:For example, the global pointer in the example is:

Struct task_tls_space*global_tls_ptr;Struct task_tls_space *global_tls_ptr;

B)存储空间分配单元240分配TLS任务本地存储空间。B) The storage space allocation unit 240 allocates the local storage space of the TLS task.

在本实施例中,使用静态数组存储TLS变量地址空间,实现如下:In this embodiment, a static array is used to store the TLS variable address space, and the implementation is as follows:

Struct task_tls_space task_tls_index[MAX_TASK_SUPPORTED];Struct task_tls_space task_tls_index[MAX_TASK_SUPPORTED];

进一步的,为了分配TLS任务本地存储空间,存储空间分配单元240包含TLS任务本地存储空间的申请函数。任务在调用含有全局变量的函数前,调用void task_tls_space_create(int taskid);函数为TLS变量创建操作,为当前线程分配一份全局变量的本地存储空间。Further, in order to allocate the TLS task local storage space, the storage space allocation unit 240 includes an application function for the TLS task local storage space. Before the task calls the function containing the global variable, call void task_tls_space_create(int taskid); the function creates an operation for the TLS variable, and allocates a local storage space for the global variable to the current thread.

进一步的,为了通过全局指针来完成对线程本地存储变量的访问还要构造任务ID与TLS任务本地存储空间地址的索引表。具体的,在本实施例中,使用静态数组存储TLS变量地址空间,实现如下:Further, in order to complete the access to the thread local storage variables through the global pointer, an index table of the task ID and the address of the TLS task local storage space must be constructed. Specifically, in this embodiment, a static array is used to store the TLS variable address space, and the implementation is as follows:

struct task_tls_space task_tls_index[MAX_TASK_SUPPORTED];struct task_tls_space task_tls_index[MAX_TASK_SUPPORTED];

C)变量指针切换单元230增加全局指针地址切换操作,切换TLS变量指针。具体包括:C) The variable pointer switching unit 230 adds a global pointer address switching operation to switch the TLS variable pointer. Specifically include:

int task_tls_space_hook_Init(void);int task_tls_space_hook_Init(void);

void task_tls_space_swap_hook(int oldtaskid,int newtaskid);void task_tls_space_swap_hook(int oldtaskid, int newtaskid);

初始化时,变量指针切换单元230通过调用函数int task_tls_space_hook_Init(void);将TLS变量空间的指针切换函数task_tls_space_swap_hook挂接到操作系统系统中的切换回调函数中。During initialization, the variable pointer switching unit 230 hooks the pointer switching function task_tls_space_swap_hook of the TLS variable space into the switching callback function in the operating system by calling the function int task_tls_space_hook_Init(void).

D)在操作系统进行任务切换时,D) When the operating system performs task switching,

调用void task_tls_space_swap_hook(int oldtaskid,int newtaskid);call void task_tls_space_swap_hook(int oldtaskid, int newtaskid);

通过newtaskid作为索引在task_tls_index中查找将要切入的任务的taskid,然后将global_tls_ptr赋值为数组中对应位置的struct task_tls_space指针。Use newtaskid as an index to find the taskid of the task to be cut in in task_tls_index, and then assign global_tls_ptr to the struct task_tls_space pointer at the corresponding position in the array.

这样,访问单元200就可以通过全局指针来完成对线程本地存储变量的访问。In this way, the access unit 200 can complete the access to the thread local storage variable through the global pointer.

E)最后,释放单元250包含TLS任务本地存储空间的释放函数。具体的,在本实施例中,当不再使用本地存储空间时,释放单元250调用E) Finally, the release unit 250 includes a release function for the local storage space of the TLS task. Specifically, in this embodiment, when the local storage space is no longer used, the releasing unit 250 calls

void task_tls_space_destroy(int taskid);void task_tls_space_destroy(int taskid);

函数销毁TLS变量的存储空间。The function destroys the storage space for TLS variables.

进一步的,本技术既可以用在新写代码中,也可以用在已有的代码中,使得可以支持TLS变量存储。如果将本发明的方法应用在将已有代码转化为支持TLS的代码,需要将源代码中的全局变量转换为全局指针。在本发明一实施例中,实现代码转换时有2种选择:手工转换以及代码预处理。Furthermore, this technology can be used in both new codes and existing codes, so that TLS variable storage can be supported. If the method of the present invention is applied to convert existing codes into codes supporting TLS, it is necessary to convert the global variables in the source codes into global pointers. In an embodiment of the present invention, there are two options for implementing code conversion: manual conversion and code preprocessing.

如果代码量和全局变量都比较少,手工使用字符串搜索/替换就能方便的完成转换。If the amount of code and global variables are relatively small, the conversion can be easily completed by manually using string search/replacement.

如果代码量和全局变量多比较多,则使用一个代码预处理器。代码预处理器实现为一个简单的C语言语法分析器,因为只需要识别出C代码中的全局变量的定义和访问,该预处理器比一个完整的C语法分析器要简单的多。主要实现步骤是:扫描源代码,找到全局变量,如果是变量的定义语句,则收集全局变量的定义结构,注释掉已有的全局变量定义防止编译器为全局变量分配内存;如果是全局变量的使用语句,则将变量的访问结构修改为一个全局指针的访问结果。最后根据收集到的所有全局变量定义,生成一个总的全局数据结构体,包含所有源代码中的全局变量定义,并生成一个指向该全局数据结构体的全局指针。这个指针就是任务切换是需要根据被切入的任务修改的唯一的数据。If the code size and global variables are relatively large, use a code preprocessor. The code preprocessor is implemented as a simple C language parser, because it only needs to identify the definition and access of global variables in the C code, the preprocessor is much simpler than a complete C parser. The main implementation steps are: scan the source code, find the global variable, if it is a variable definition statement, collect the definition structure of the global variable, comment out the existing global variable definition to prevent the compiler from allocating memory for the global variable; if it is a global variable Using the statement, the access structure of the variable is modified to the access result of a global pointer. Finally, according to all the collected global variable definitions, a total global data structure is generated, including the global variable definitions in all source codes, and a global pointer pointing to the global data structure is generated. This pointer is that task switching is the only data that needs to be modified according to the task being cut in.

进一步的,在本发明一实施例中,将全局变量转换为全局指针时,有2种选择:Further, in an embodiment of the present invention, when converting a global variable into a global pointer, there are two options:

一是为每个全局变量使用一个全局指针。这样在访问全局变量时,通过对应的全局指针进行一次跳转就能找到变量地址。但是任务切换时必须为每个全局指针重新赋值为新任务的TLS变量地址,会降低任务切换时间。因此如果全局变量少,任务切换不频繁,切换时间要求不苛刻,可以使用这种办法。One is to use a global pointer for each global variable. In this way, when accessing a global variable, the variable address can be found by performing a jump through the corresponding global pointer. However, each global pointer must be reassigned to the TLS variable address of the new task during task switching, which will reduce the task switching time. Therefore, if there are few global variables, task switching is infrequent, and switching time requirements are not strict, this method can be used.

二是为所有全局变量使用一个全局指针。这样在访问全局变量时,通过对应的全局指针进行一次跳转就能找到变量地址。但是任务切换时只需要为这一个全局指针重新赋值为新任务的TLS变量本地存储空间的首地址即可。如果任务切换频繁,切换时间要求苛刻,可以使用这种办法。在很多嵌入式开发环境里,这种选择更可取。The second is to use a global pointer for all global variables. In this way, when accessing a global variable, the variable address can be found by performing a jump through the corresponding global pointer. However, when the task is switched, it is only necessary to reassign this global pointer as the first address of the TLS variable local storage space of the new task. This method can be used if the task switching is frequent and the switching time is demanding. In many embedded development environments, this option is preferable.

综上,根据本发明的方法和装置,可以将全局变量转换为任务的TLS变量从而实现TLS。本发明的方法不需要处理器、编译器提供特殊支持,也不修改原有操作系统,具有很高的应用灵活度。本发明的方法大大降低了TLS的实施难度,扩展了TLS的应用范围。To sum up, according to the method and device of the present invention, global variables can be converted into TLS variables of tasks so as to realize TLS. The method of the invention does not require special support from processors and compilers, and does not modify the original operating system, so it has high application flexibility. The method of the invention greatly reduces the implementation difficulty of TLS and expands the application range of TLS.

虽然本发明所公开的实施方式如上,但所述的内容只是为了便于理解本发明而采用的实施方式,并非用以限定本发明。本发明所述的方法还可有其他多种实施例。在不背离本发明实质的情况下,熟悉本领域的技术人员当可根据本发明作出各种相应的改变或变形,但这些相应的改变或变形都应属于本发明的权利要求的保护范围。Although the embodiments disclosed in the present invention are as above, the described content is only an embodiment adopted for the convenience of understanding the present invention, and is not intended to limit the present invention. The method described in the present invention can also have other various embodiments. Without departing from the essence of the present invention, those skilled in the art can make various corresponding changes or modifications according to the present invention, but these corresponding changes or modifications should all belong to the protection scope of the claims of the present invention.

Claims (10)

Translated fromChinese
1.一种实现线程本地存储的方法,其特征在于,将全局变量转换为任务的线程本地存储变量以实现线程本地存储,包括:1. A method for realizing thread local storage is characterized in that global variables are converted into thread local storage variables of tasks to realize thread local storage, including:将源代码中的所述全局变量修改为全局指针;Modifying the global variable in the source code into a global pointer;在操作系统的任务切换回调函数中增加全局指针地址切换操作;Add the global pointer address switching operation in the task switching callback function of the operating system;为所述全局变量分配线程本地存储任务局部存储空间;Allocating thread local storage task local storage space for the global variable;通过所述全局指针来完成对所述线程本地存储变量的访问。The access to the thread local storage variable is accomplished through the global pointer.2.根据权利要求1所述的方法,其特征在于,将全局变量修改为全局指针,其中,将所有全局变量的类型收集到一个总的全局数据结构体中,并生成一个指向所述全局数据结构体的全局指针。2. The method according to claim 1, wherein the global variable is modified into a global pointer, wherein the types of all global variables are collected in a total global data structure, and a pointer to the global data structure is generated A global pointer to the structure.3.根据权利要求2所述的方法,其特征在于,对全局变量的定义进行注释,防止编译器编译时再分配静态空间。3. The method according to claim 2, wherein the definition of the global variable is annotated to prevent the compiler from allocating static space when compiling.4.根据权利要求2或3所述的方法,其特征在于,将对全局变量的访问,修改为通过全局指针的访问,防止编译器对全局变量的访问进行静态绑定。4. The method according to claim 2 or 3, characterized in that the access to the global variable is changed to access through a global pointer, preventing the compiler from statically binding the access to the global variable.5.根据权利要求1-4中任一项所述的方法,其特征在于,在操作系统的任务切换回调函数中增加所述全局指针地址切换操作,其中:5. The method according to any one of claims 1-4, wherein the global pointer address switching operation is added in the task switching callback function of the operating system, wherein:初始化时,将线程本地存储变量空间的指针切换函数挂接到操作系统系统中的切换回调函数中。During initialization, the pointer switching function of the thread local storage variable space is hooked into the switching callback function in the operating system.6.根据权利要求5所述的方法,其特征在于,为所述全局变量分配线程本地存储任务局部存储空间,其中:6. The method according to claim 5, wherein the global variable is allocated a thread local storage task local storage space, wherein:所述任务在调用含有全局变量的函数前,调用线程本地存储变量创建操作,为当前线程分配一份所述全局变量的本地存储空间。Before calling the function containing the global variable, the task calls the creation operation of the thread local storage variable, and allocates a local storage space of the global variable for the current thread.7.根据权利要求6所述的方法,其特征在于,将当前任务的任务标识绑定到线程本地存储变量本地存储空间的首地址。7. The method according to claim 6, wherein the task identifier of the current task is bound to the head address of the local storage space of the thread local storage variable.8.根据权利要求7所述的方法,其特征在于,通过所述全局指针来完成对所述线程本地存储变量的访问,其中:8. The method according to claim 7, wherein the access to the thread local storage variable is completed through the global pointer, wherein:在操作系统进行任务切换时,回调函数通过被切入任务的标识找到其对应的线程本地存储变量本地存储空间的首地址,将该地址赋值给所述全局指针。When the operating system performs task switching, the callback function finds the first address of the corresponding thread local storage variable local storage space through the identifier of the switched task, and assigns the address to the global pointer.9.根据权利要求1-8中任一项所述的方法,其特征在于,所述任务在不需要使用全局变量时,调用线程本地存储变量释放操作,释放之前分配的本地存储空间。9. The method according to any one of claims 1-8, wherein when the task does not need to use the global variable, it calls a thread local storage variable release operation to release the previously allocated local storage space.10.一种实现线程本地存储的装置,其特征在于,所述装置配置为将全局变量转换为任务的线程本地存储变量以实现线程本地存储,所述装置包括:10. A device for implementing thread local storage, characterized in that the device is configured to convert global variables into thread local storage variables of tasks to realize thread local storage, and the device comprises:源程序修改单元,其配置为将源代码中的所述全局变量修改为全局指针;a source program modification unit configured to modify the global variable in the source code into a global pointer;存储空间分配单元,其配置为所述全局变量分配线程本地存储任务局部存储空间;a storage space allocation unit configured to allocate a thread local storage task local storage space for the global variable;变量指针切换单元,其配置为在操作系统的任务切换回调函数中增加全局指针地址切换操作;A variable pointer switching unit configured to add a global pointer address switching operation in the task switching callback function of the operating system;访问单元,其配置为通过所述全局指针来完成对所述线程本地存储变量的访问。An access unit configured to access the thread local storage variable through the global pointer.
CN201610806319.2A2016-09-062016-09-06 A method and device for implementing thread local storageActiveCN106445656B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201610806319.2ACN106445656B (en)2016-09-062016-09-06 A method and device for implementing thread local storage

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201610806319.2ACN106445656B (en)2016-09-062016-09-06 A method and device for implementing thread local storage

Publications (2)

Publication NumberPublication Date
CN106445656Atrue CN106445656A (en)2017-02-22
CN106445656B CN106445656B (en)2019-10-11

Family

ID=58165122

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201610806319.2AActiveCN106445656B (en)2016-09-062016-09-06 A method and device for implementing thread local storage

Country Status (1)

CountryLink
CN (1)CN106445656B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN107741883A (en)*2017-09-292018-02-27武汉斗鱼网络科技有限公司A kind of method, apparatus and computer equipment for avoiding thread block
CN109240702A (en)*2018-08-152019-01-18无锡江南计算技术研究所Quick segmentation addressing configuration and access method under a kind of multithread mode
CN106445656B (en)*2016-09-062019-10-11北京邮电大学 A method and device for implementing thread local storage
CN113076556A (en)*2021-03-292021-07-06北京中电华大电子设计有限责任公司eUICC signed data file management method
CN116483545A (en)*2023-06-192023-07-25支付宝(杭州)信息技术有限公司Multitasking execution method, device and equipment
WO2024124375A1 (en)*2022-12-122024-06-20Nvidia CorporationApplication programming interface to allocate fifth generation new radio (5g-nr) statically-sized linked storage
CN120122957A (en)*2025-04-272025-06-10上海壁仞科技股份有限公司 Code compilation method, electronic device and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN1983191A (en)*2005-12-122007-06-20中兴通讯股份有限公司Method for setting up scheduling restricted zone in built-in realtime system by global variable
CN101937367A (en)*2009-06-302011-01-05英特尔公司The MPI source code program arrives the automatic conversion based on the program of MPI thread
CN103116522A (en)*2013-01-312013-05-22广州海格通信集团股份有限公司Kernel dynamic switching method and control system of digital signal processing (DSP) chip
CN104216767A (en)*2014-09-182014-12-17东软集团股份有限公司Method and device for accessing shared data among multiple threads
CN104778138A (en)*2015-04-202015-07-15中国科学院光电技术研究所Kernel multithreading direct storage drive implementation method
CN105786525A (en)*2016-03-232016-07-20鼎点视讯科技有限公司Method and device for transplanting code from process model to thread model

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN106445656B (en)*2016-09-062019-10-11北京邮电大学 A method and device for implementing thread local storage

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN1983191A (en)*2005-12-122007-06-20中兴通讯股份有限公司Method for setting up scheduling restricted zone in built-in realtime system by global variable
CN101937367A (en)*2009-06-302011-01-05英特尔公司The MPI source code program arrives the automatic conversion based on the program of MPI thread
CN103116522A (en)*2013-01-312013-05-22广州海格通信集团股份有限公司Kernel dynamic switching method and control system of digital signal processing (DSP) chip
CN104216767A (en)*2014-09-182014-12-17东软集团股份有限公司Method and device for accessing shared data among multiple threads
CN104778138A (en)*2015-04-202015-07-15中国科学院光电技术研究所Kernel multithreading direct storage drive implementation method
CN105786525A (en)*2016-03-232016-07-20鼎点视讯科技有限公司Method and device for transplanting code from process model to thread model

Cited By (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN106445656B (en)*2016-09-062019-10-11北京邮电大学 A method and device for implementing thread local storage
CN107741883A (en)*2017-09-292018-02-27武汉斗鱼网络科技有限公司A kind of method, apparatus and computer equipment for avoiding thread block
CN109240702A (en)*2018-08-152019-01-18无锡江南计算技术研究所Quick segmentation addressing configuration and access method under a kind of multithread mode
CN113076556A (en)*2021-03-292021-07-06北京中电华大电子设计有限责任公司eUICC signed data file management method
WO2024124375A1 (en)*2022-12-122024-06-20Nvidia CorporationApplication programming interface to allocate fifth generation new radio (5g-nr) statically-sized linked storage
CN116483545A (en)*2023-06-192023-07-25支付宝(杭州)信息技术有限公司Multitasking execution method, device and equipment
CN116483545B (en)*2023-06-192023-09-29支付宝(杭州)信息技术有限公司Multitasking execution method, device and equipment
CN120122957A (en)*2025-04-272025-06-10上海壁仞科技股份有限公司 Code compilation method, electronic device and storage medium

Also Published As

Publication numberPublication date
CN106445656B (en)2019-10-11

Similar Documents

PublicationPublication DateTitle
CN106445656B (en) A method and device for implementing thread local storage
US8402224B2 (en)Thread-shared software code caches
EP3143500B1 (en)Handling value types
EP2460073B1 (en)Mapping processing logic having data parallel threads across processors
US20060026183A1 (en)Method and system provide concurrent access to a software object
US7647586B2 (en)System and method for providing exceptional flow control in protected code through watchpoints
US20110161944A1 (en)Method and apparatus for transforming program code
US7039911B2 (en)Hybrid threads for multiplexing virtual machine
US7168071B2 (en)Method and system of permitting stack allocation to programs having open-world features
KR20030020397A (en)A method for scalable memory efficient thread-local object allocation
CN102096598A (en) A virtual machine system and its implementation method
US20070300210A1 (en)Compiling device, list vector area assignment optimization method, and computer-readable recording medium having compiler program recorded thereon
CN102004662A (en)Embedded scalable virtual machine
Agbaria et al.Virtual‐machine‐based heterogeneous checkpointing
US20120005460A1 (en)Instruction execution apparatus, instruction execution method, and instruction execution program
Campanoni et al.A highly flexible, parallel virtual machine: Design and experience of ILDJIT
Wolfe et al.The OpenACC data model: Preliminary study on its major challenges and implementations
US6275985B1 (en)Method and apparatus for developing an application that implements garbage collection efficiently by combining proxy objects with compiler support
Hagen et al.PGASUS: a framework for C++ application development on NUMA architectures
CN108647087B (en)Method, device, server and storage medium for realizing reentry of PHP kernel
BarthelmannInter-task register-allocation for static operating systems
US9250878B1 (en)Function attribute for dynamic stack allocation
DawsonChallenges in implementing the real-time specification for Java (RTSJ) in a commercial real-time Java virtual machine
JP6011329B2 (en) PROGRAM GENERATION DEVICE, PROGRAM GENERATION METHOD, AND COMPUTER PROGRAM
US9110793B2 (en)Inner process

Legal Events

DateCodeTitleDescription
C06Publication
PB01Publication
C10Entry into substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp