WO2011127862A2 - 多线程访问多副本的方法和装置 - Google Patents

多线程访问多副本的方法和装置 Download PDF

Info

Publication number
WO2011127862A2
WO2011127862A2 PCT/CN2011/074384 CN2011074384W WO2011127862A2 WO 2011127862 A2 WO2011127862 A2 WO 2011127862A2 CN 2011074384 W CN2011074384 W CN 2011074384W WO 2011127862 A2 WO2011127862 A2 WO 2011127862A2
Authority
WO
WIPO (PCT)
Prior art keywords
thread
page directory
directory table
entry
threads
Prior art date
Application number
PCT/CN2011/074384
Other languages
English (en)
French (fr)
Other versions
WO2011127862A3 (zh
Inventor
王伟
刘仪阳
章晓峰
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2011/074384 priority Critical patent/WO2011127862A2/zh
Priority to EP11768473A priority patent/EP2434402A4/en
Priority to CN2011800005531A priority patent/CN102203737B/zh
Publication of WO2011127862A2 publication Critical patent/WO2011127862A2/zh
Priority to US13/339,230 priority patent/US8880813B2/en
Publication of WO2011127862A3 publication Critical patent/WO2011127862A3/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1009Address translation using page tables, e.g. page table structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/25Using a specific main memory architecture
    • G06F2212/254Distributed memory
    • G06F2212/2542Non-uniform memory access [NUMA] architecture

Definitions

  • This invention relates to the field of computers and, more particularly, to a method and apparatus for multi-thread access to multiple copies in the computer arts. Background technique
  • NUMA Non-uniform Memory Access
  • each processor mounts memory, peripherals, and so on. Since each set of processors and memory is connected to the same system, NUMA shows its scalability advantages, coupled with its high reliability, high applicability and high service characteristics, it has been widely used in the middle and high-end server field.
  • any processor in a NUMA node can access any memory, there are different delays for each processor accessing different memories. As the system expands, the NUMA nodes gradually increase, and the delay of the processor accessing the remote nodes is correspondingly greatly increased, thereby affecting the overall performance of the system. Especially for data that is frequently accessed in the system (such as kernel code and kernel read-only data), if the data exists only in one node, the processors of other nodes will have a large delay in accessing the data, and if these Data is accessed by processors of multiple nodes in a short period of time, and the transmission bandwidth of the interconnect hardware becomes another factor that affects performance.
  • data that is frequently accessed in the system such as kernel code and kernel read-only data
  • frequently accessed data in the system can be copied into the memory of each node, so that each node has a local copy, and processes running on each node can access the local copy, thereby avoiding The latency effects caused by not accessing these frequently accessed data by other nodes, while also reducing the transmission bandwidth consumption of the interconnected hardware.
  • kernel code and kernel read-only data in order to implement multiple copies of the kernel, you can apply enough memory on each node to copy the kernel code and kernel read-only data to the new area; The mapping between the copy and the corresponding linear address; when the process is scheduled to a node, based on the mapping relationship of the kernel copy saved on the node, modify some entries of the process page directory table, so that the process passes its process.
  • the contents of the page directory table can access a copy of the kernel code of this node.
  • the kernel multi-copy technology allows the process to access the kernel code and kernel read-only data on this node, if the process creates multiple threads and these threads are distributed to different nodes for execution, then these threads will still be based on The contents of the process page catalog table runs. In this way, due to The kernel copy pointed to by the directory directory table is located in one node, so multi-threading can not access the kernel copy saved in the node, which will still generate large delay and is limited by the interconnect hardware transmission bandwidth.
  • Embodiments of the present invention provide a method and apparatus for multi-thread accessing multiple copies, so that threads distributed to different nodes can access data with multiple copies stored at a node, thereby improving system performance.
  • an embodiment of the present invention provides a method for multi-thread accessing multiple copies, including: when a plurality of threads of a process are distributed to different nodes, creating a thread page directory table having the same content as a process page directory table of the process.
  • Each thread page directory table includes a special table item for pointing to a specific data and a normal table item other than the special table item, wherein each thread corresponds to a thread page directory table, and each thread execution is based on a corresponding Thread page directory table, the specific data is data having multiple copies at different nodes; for each thread when being scheduled, when a special table entry in the thread's page directory table of the thread does not point to the node where the thread is located When the specific data is stored, the special entry is modified to point to the specific data based on the physical address of the specific data.
  • an embodiment of the present invention provides an apparatus for multi-thread accessing multiple copies, including: a first creating module, configured to create a process page with the process when multiple threads of a process are distributed to different nodes
  • the thread table directory table of the same content of the table of contents, each thread page directory table includes a special table item for pointing to specific data and a common table item other than the special table item, wherein each thread corresponds to a thread page directory Table, the execution of each thread is based on a corresponding thread page directory table, the specific data is data having multiple copies at different nodes; a modification module, for each thread when being scheduled, when the thread page of the thread When a special table entry in the directory table does not point to the specific data stored in the node where the thread is located, the special entry is modified to point to the specific data based on the physical address of the specific data.
  • FIG. 1 is a flow chart of a method of multi-thread accessing multiple copies in accordance with an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of a logical structure for implementing multi-thread access to multiple copies in accordance with an embodiment of the present invention.
  • 3 is a flow diagram of another method of multi-thread accessing multiple copies in accordance with an embodiment of the present invention.
  • 4 is a flow diagram of the overall process of fully executing a process in the case of implementing multi-threaded access to multiple copies, in accordance with an embodiment of the present invention.
  • 5 is a flow diagram of still another method of multi-thread accessing multiple copies in accordance with an embodiment of the present invention.
  • 6 is a flow diagram of a method of creating a process page directory table of FIG. 5, in accordance with an embodiment of the present invention.
  • FIG. 7 is a structural block diagram of an apparatus for multi-thread accessing multiple copies in accordance with an embodiment of the present invention.
  • Figure 8 is a block diagram showing the structure of another apparatus for multi-thread accessing multiple copies in accordance with an embodiment of the present invention.
  • FIG. 9 is a block diagram showing still another apparatus for multi-thread accessing multiple copies in accordance with an embodiment of the present invention. detailed description
  • the method 100 includes: In S110, when a plurality of threads of a process are distributed to different nodes, a thread page directory table having the same content as a process page directory table of the process is created, and each thread page directory table is created.
  • It includes a special table item for pointing to specific data and a common table item other than a special table item, wherein each thread corresponds to a thread page directory table, and each thread is executed based on a corresponding thread page directory table, and the specific data is Data having multiple copies at different nodes; in S120, when each thread is scheduled, when a special entry in the thread's thread page directory table of the thread does not point to the line When the specific data stored in the node is located, the special entry is modified to point to the specific data based on the physical address of the specific data.
  • the threads distributed to different nodes can access the specific ones in the node. Data, thereby avoiding the delays caused by threads accessing remote data and avoiding the limitations of the interconnect hardware transmission bandwidth, resulting in improved system performance.
  • a process can be divided into multiple threads, and threads can be distributed to different nodes for execution.
  • a node can be a node in a NUMA architecture, or a node that supports multi-processor concurrent operations in other scalable system structures, or a node in any device that needs to implement multi-threaded frequent access to read-only data.
  • a thread page directory table can be created for a thread so that the thread executes based on its corresponding thread page directory table.
  • each thread can correspond to a thread page directory table that belongs to itself only.
  • 20 thread page directory tables need to be created for 20 threads, corresponding to the thread page directory table.
  • each thread corresponds to a thread page directory table shared by at least two threads that are in the same node as the thread.
  • each thread page directory table shared by at least two threads that are in the same node as the thread.
  • there can be only one thread page directory table in each node which is shared by threads on that node.
  • the number of thread page directory tables that need to be maintained can be reduced compared to the thread and thread page directory table - corresponding to the system overhead.
  • each of the plurality of threads corresponds to one thread page directory table belonging to itself, and each of the other threads corresponds to one shared by at least two threads that are in the same node as the thread.
  • Thread page directory table This situation is a combination of the above two situations. For example, after the 20 threads included in the process are evenly distributed to 4 nodes, for 5 threads on a node, 2 of the threads can have their own thread page directory table, and the other 3 threads can share one.
  • the thread page directory table, at this point in the node has a total of 3 thread page directory table.
  • one thread page directory table corresponds to one or more threads
  • one thread corresponds to one thread page directory Table, and run based on the thread page directory table it corresponds to.
  • the entries can be divided into two parts: a special entry and a normal entry.
  • a special entry points to specific data, which is data that has multiple copies at different nodes.
  • the specific data may be kernel code and kernel read-only data, or all read-only data in the memory, or some read-only data in the memory, and of course, a combination of the above.
  • data with multiple copies at different nodes is data that needs frequent access, so specific data can also be these frequently accessed data.
  • the created thread page directory table may be a newly created thread page directory table, or may share a process page directory table to obtain a thread page directory table. For example, you can set the process page catalog table as the thread page catalog table for the main thread; for other threads, generate the same thread page catalog table as the contents of the process page catalog table.
  • the thread page directory table of the created main thread is the process page directory table, and the thread page directory table pointer of the main thread may be pointed to the process page directory table, or may be set to null and default to the process page directory table; For threads other than the main thread, a new thread page directory table needs to be generated.
  • the address of the thread page directory table corresponding to the thread is loaded into the hardware register to execute the thread.
  • the hardware registers can be CR3 registers under the X86 platform. If a particular entry in the thread's directory table of a thread does not point to specific data in the node where the thread resides, modify the special entry to point to the specific data in the node. When modifying, you need to refer to the physical address stored in the local data of the specific data, and modify the special entry based on the physical address.
  • the thread can implement multi-thread access to multiple copies during the execution of the thread. Avoid delays caused by accessing remote data and high requirements for transmission bandwidth, and improve access efficiency to frequently accessed data, thereby improving system performance.
  • FIG. 2 A schematic diagram of a logical structure for implementing multi-thread access to multiple copies through a thread page directory table is described by taking FIG. 2 as an example. Only the logical structure related to the embodiment of the present invention is shown in Fig. 2 instead of the entire logical structure.
  • Thread 1 is the main thread
  • the process page directory table can be used as the thread page directory table of thread 1, so the thread page directory table pointer of thread 1 is a null pointer, and the default is the same as the process page directory table pointer.
  • thread 1's thread page directory table pointer can also be set to point to the value of the process page directory table.
  • the thread page directory table pointers of thread 2 and thread 3 point to the respective thread page directory tables of thread 2 and thread 3, respectively.
  • the thread page directory table is divided into two parts, which are special items and common items. Special entries are used to point to data that has multiple copies on different nodes.
  • the special table entry in the thread page directory table of thread 1 points to the kernel copy of the node where thread 1 is located, and the thread page of thread 2
  • the special table entry in the directory table points to the kernel copy of the node where the thread 2 is located
  • the special table entry in the thread page directory table of the thread 3 points to the kernel copy of the node where the thread 3 is located.
  • the value in the special entry can be modified to point to these areas based on the physical address of the multiple copies of the data stored in the node.
  • FIG. 3 is a flow diagram of a method 300 of multiple data access multiple copies in accordance with an embodiment of the present invention.
  • the method 300 adds a step of synchronizing a normal entry to the method 100 to further ensure the normal execution of the thread in the process of implementing multi-thread access to multiple copies.
  • S310 and S320 of method 300 are substantially identical to S110 and S120 of method 100.
  • a common entry in all other thread page directory tables is updated based on the normal entry.
  • the thread page directory table of the main thread is a process page directory table
  • thread 2 modifies its own thread page directory table after applying for freeing memory.
  • the normal table entries in all other thread page directory tables are not immediately updated, but only the thread page directory table of thread 2 is recorded.
  • a modification has occurred. For example, by setting the mask flag bit to record which thread page directory table has been modified, each flag bit corresponds to a thread page directory table.
  • a page fault exception is triggered when other threads, such as thread 3, access this area during the run.
  • thread 3 looks for a modified thread page directory table in the system, for example by masking the flag bits to find out which thread page directory tables have changed.
  • the thread page directory table of the thread 2 is found to be modified, the thread 3 updates the normal table entry of the thread page directory table of the thread to the normal table entry of the thread page directory table of the thread 2, thereby solving the page fault exception and performing normally.
  • each thread can access data with multiple copies. At the same time, it can be executed normally, thus ensuring the complete implementation of the process function. Moreover, the synchronization performed during the running of the thread does not require additional content space, and the synchronization overhead is small in the case of a small number of threads.
  • FIG. 4 The flow chart of the overall process of enabling multiple threads to access multiple copies and enabling threads to execute normally is described below using FIG. 4 as an example.
  • the specific data having multiple copies in this example is a kernel copy, and those skilled in the art can also think of specific data or read-only data in the memory, and the implementation process is similar.
  • a kernel copy is created. Apply the content at each node, and copy the kernel code and kernel read-only data of the master node into the newly applied memory, and record the mapping relationship of the kernel copy of the node at each node.
  • the process is created. Divide the process into multiple threads and distribute the threads to different nodes for execution.
  • a thread page directory table is created. Create a thread page directory table for the newly created thread.
  • the process is scheduled. Since processes are divided into multiple threads, process scheduling is also thread scheduling.
  • the content of the thread page directory table is made consistent with the content of the process page directory table.
  • the thread page directory table pointer of the thread is set to be empty, and the process page directory table is taken as its thread page directory table.
  • the thread page directory table is loaded.
  • S451 when a thread is scheduled, it is determined whether the thread is the main thread. If it is determined that the thread is the main thread, proceed to S452, otherwise proceed to S455.
  • S452 it is determined whether the thread can access the kernel copy locally based on the special entry in the corresponding thread page directory table. If it is determined in S452 that the kernel copy cannot be accessed locally, then proceed to S453, otherwise proceed to S454. Makes it accessible to the kernel copy stored in the node where the main thread is located.
  • the processor of the main thread of the line corresponds to the hardware register.
  • S455 it is determined whether the thread can access the kernel copy locally based on the special entry in the corresponding thread page directory table. If it is determined in S455 that the kernel copy cannot be accessed locally, then proceed to S456, otherwise proceed to S457.
  • the address of the thread's thread page directory table is loaded into the hardware register corresponding to the processor executing the thread. In this way, based on the operation in S450, the thread page directory table corresponding to all threads can be loaded, and the special table entry of the thread page directory table points to the kernel copy stored in the node where the thread is located, thereby performing local access.
  • the method 500 can also cause all threads to execute normally, but compared to the method 300, instead of synchronizing the normal entries of the thread page directory table during the running of the thread, the thread can be guaranteed to be normal when the thread page directory table is created.
  • S510 and S520 of method 500 are substantially identical to S110 and S120 of method 100.
  • all address spaces that the process will use are determined in advance. For example, reserve all user space that the process will use in advance.
  • a process page directory table is created to point to all address spaces based on all address spaces.
  • the process page directory table can be created based on the physical addresses of those spaces. For example, when a process creates a main thread, it can apply for a page upper table for all user spaces of the process, and fill the corresponding page directory entry of the table with the address generation table entry into the process page directory table.
  • the normal table entry of the process page directory table will not be due to the memory unit.
  • the new application or release changes, so that the normal entry can remain unchanged during the operation. Therefore, when the common entry of the thread page directory table is consistent with the normal entry of the process page directory table, the normal entry of the thread page directory table can be executed normally without changing in the running process.
  • the efficiency overhead of the method for synchronizing the thread page directory table in the process 300 can be saved, and some memory space is consumed in exchange for each thread. The performance of the normal execution.
  • the process page directory table in S504 of Fig. 5 can be created in the manner shown in Fig. 6.
  • the process is created.
  • S630 it is determined whether the next item is empty. If it is empty, proceed to S640, otherwise return to S620.
  • an entry of the process page directory table is populated to point to the upper table of the page based on the allocated upper table of the page.
  • Figure 7 is a block diagram showing the structure of an apparatus 700 for multi-thread accessing multiple copies in accordance with an embodiment of the present invention.
  • Apparatus 700 includes a first creation module 710 and a modification module 720.
  • the first creating module 710 can be configured to create a thread page directory table having the same content as the process page directory table of the process when multiple threads of the process are distributed to different nodes, where each thread page directory table includes a point for pointing to specific data.
  • the modification module 720 can be configured to modify, when each thread is scheduled, when the special entry in the thread page directory table of the thread does not point to the specific data stored in the node where the thread is located, based on the physical address of the specific data, modify This special entry points to this specific data.
  • the specific data may include at least one of the following: kernel code and Core read-only data; read-only data in memory.
  • each thread may correspond to a thread page directory table that belongs only to itself.
  • Each thread can also correspond to a thread page directory table shared by at least two threads that are on the same node as the thread.
  • each of the plurality of threads may correspond to a thread page directory table that belongs to only one of itself, and each of the other threads may be shared by at least two threads that are in the same node as the thread.
  • a thread page directory table may correspond to a thread page directory table that belongs only to itself.
  • the foregoing and other operations and/or functions of the first creating module 710 and the modifying module 720 may refer to S110 and S120 in the foregoing method 100. To avoid repetition, details are not described herein again.
  • the special entry of the thread page directory table is modified to point to specific data such as kernel code and read-only data in the node where the thread is located
  • specific data in the line node is executed, thereby Multi-thread access to multiple copies, avoiding delays caused by accessing remote data and high requirements for transmission bandwidth, and improving access efficiency to frequently accessed data, thereby improving system performance.
  • Figure 8 is a block diagram showing the structure of an apparatus 800 for multi-thread accessing multiple copies in accordance with an embodiment of the present invention.
  • the first creation module 810 and the modification module 820 of the device 800 are substantially identical to the first creation module 710 and the modification module 720 of the device 700.
  • Apparatus 800 may include an update module 830, in accordance with an embodiment of the present invention.
  • the update module 830 can be used to update common entries in the thread page directory table that need to be synchronized in the process of executing each thread based on the thread page directory table of each thread, so that each thread executes normally.
  • the update module 830 can be configured to update a common entry in all other thread page directory tables based on the normal entry when the normal entry in the specific thread page directory table changes.
  • the update module 830 can include a lookup unit 832 and an update unit 834, in accordance with an embodiment of the present invention.
  • the lookup unit 832 can be used to look for a thread page directory table in which a change has occurred when a page fault occurs for a particular thread.
  • the update unit 834 can be configured to update a normal entry in a thread page directory table of a specific thread based on a normal entry in the thread page directory table.
  • the first creation module 810 may include a setting unit 812 and a generation unit 814.
  • the setting unit 812 can be used to set the process page directory table as the thread page directory table of the main thread.
  • the generating unit 814 can be configured to generate, for other threads, the same thread page directory table as the content of the process page directory table.
  • the above and other operations and/or functions of the update module 830, the search unit 832, the update unit 834, the setup unit 812, and the generation unit 814 may refer to S330 of the above method 300 and S110 of the above method 100, in order to avoid repetition, no longer Narration.
  • each element of the thread page directory table may be synchronized in real time during the thread running process, or the common table item of the corresponding thread page directory table may be updated when a page fault exception occurs, so that each device can be made A thread can execute normally while having access to data with multiple copies, thus ensuring a complete implementation of the process functions.
  • the synchronization performed during the running of the thread does not require additional content space, and the synchronization overhead is small in the case of a small number of threads.
  • Figure 9 is a block diagram showing the structure of an apparatus 900 for multi-thread accessing multiple copies in accordance with an embodiment of the present invention.
  • the first creation module 910 and the modification module 920 of the device 900 are substantially identical to the first creation module 710 and the modification module 720 of the device 700.
  • Apparatus 900 may also include a determination module 902 and a second creation module 904, in accordance with an embodiment of the present invention.
  • the determination module 902 can be used to determine all of the address spaces that the process will use.
  • the second creation module 904 can be used to create a process page directory table to point to all address spaces based on all address spaces. At this time, the thread page directory table created by the first creation module 910 is created based on the process page directory table created by the second creation module 904.
  • the foregoing and other operations and/or functions of the determining module 902 and the second creating module 904 may refer to S502 and S504 of the foregoing method 500. To avoid repetition, details are not described herein again.
  • the normal entry of the process page directory table is not changed due to a new application or release of the memory unit, so that the normal entry may remain unchanged during the running process. Therefore, when the normal entry of the thread page directory table is consistent with the normal entry of the process page directory table, the normal entry of the thread page directory table can be executed normally without changing in the running process.
  • the efficiency overhead of the method for synchronizing the thread page directory table in the process 300 can be saved, and some memory space is consumed in exchange for each thread. The performance of the normal execution.
  • RAM random access memory
  • ROM read only memory
  • electrically programmable ROM electrically erasable programmable ROM
  • registers hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art. in.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明实施例提供了多线程访问多副本的方法和装置。该方法包括:当进程的多个线程被分布到不同节点时,创建与进程的进程页目录表的内容相同的线程页目录表,每份线程页目录表包括用于指向特定数据的特殊表项和特殊表项之外的普通表项,其中每个线程对应一份线程页目录表,每个线程的执行基于相对应的线程页目录表,特定数据是在不同节点具有多副本的数据;对于每个线程在被调度时,当该线程的线程页目录表中的特殊表项未指向在该线程所在节点中存储的特定数据时,基于该特定数据的物理地址,修改该特殊表项以指向该特定数据。基于上述技术方案,可以使分布到不同节点的线程访问所在节点处存储的数据副本,从而提高系统性能。

Description

多线程访问多副本的方法和装置 技术领域
本发明涉及计算机领域, 并且更具体地, 涉及计算机领域中多线程访问 多副本的方法和装置。 背景技术
NUMA ( Non-uniform Memory Access , 非一致内存访问)是一种分布式 结构, 每个处理器都会挂载内存、 外设等。 由于每组处理器和内存都连接到 同一系统, NUMA显示了其扩展性的优势, 加上其高可靠性、 高应用性和 高服务性的特征, 已广泛应用到中高端服务器领域。
由于 NUMA节点中的任一处理器都可以访问任意的内存, 使得每个处 理器访问不同的内存存在着不同的延迟。 随着系统的扩展, NUMA 节点逐 渐增加, 处理器访问远端节点的延迟也相应大幅提升, 从而影响系统的整体 性能。 特别是对于系统中被频繁访问的数据 (例如内核代码和内核只读数 据), 如果这些数据只存在于一个节点中, 那么其他节点的处理器访问这些 数据将具有较大的延迟, 并且如果这些数据在短时间内被多个节点的处理器 访问, 互联硬件的传输带宽就成为了另一影响性能的因素。
在相关技术中,可以将系统中被频繁访问的数据复制到每个节点的内存 中, 这样每个节点都有一个本地副本, 运行在各个节点上的进程都可以访问 本地副本,从而避免因为不得不在其他节点访问这些被频繁访问的数据而引 发的延迟影响, 同时还可以减少互联硬件的传输带宽消耗。
以内核代码和内核只读数据为例, 为了实现内核多副本, 可以在每个节 点上申请足够的内存, 将内核代码和内核只读数据复制到该新区域; 通过计 算获取各个节点的内核多副本和对应线性地址的映射关系; 当进程被调度到 某个节点上时, 基于保存在该节点上的内核副本的映射关系, 修改进程页目 录表的某些表项,使得该进程通过其进程页目录表的内容可以访问本节点的 内核代码副本。
虽然通过内核多副本技术, 可以使进程访问本节点上的内核代码和内核 只读数据, 但是如果进程创建了多个线程, 并且这些线程被分布到不同的节 点上执行, 那么这些线程仍将基于进程页目录表的内容运行。 这样, 由于进 程页目录表指向的内核副本位于一个节点中,所以多线程并不能访问所在节 点中保存的内核副本, 仍将产生较大的延迟并受互联硬件传输带宽的限制。 发明内容
本发明实施例提供了多线程访问多副本的方法和装置,使得分布到不同 节点的线程能够访问所在节点处保存的具有多副本的数据, 从而可以改善系 统性能。
一方面, 本发明实施例提供了多线程访问多副本的方法, 包括: 当进程 的多个线程被分布到不同节点时,创建与所述进程的进程页目录表的内容相 同的线程页目录表,每份线程页目录表包括用于指向特定数据的特殊表项和 所述特殊表项之外的普通表项, 其中每个线程对应一份线程页目录表, 每个 线程的执行基于相对应的线程页目录表, 所述特定数据是在不同节点具有多 副本的数据; 对于每个线程在被调度时, 当该线程的线程页目录表中的特殊 表项未指向在该线程所在节点中存储的所述特定数据时,基于该特定数据的 物理地址, 修改该特殊表项以指向该特定数据。
另一方面, 本发明实施例提供了用于多线程访问多副本的装置, 包括: 第一创建模块, 用于当进程的多个线程被分布到不同节点时, 创建与所述进 程的进程页目录表的内容相同的线程页目录表,每份线程页目录表包括用于 指向特定数据的特殊表项和所述特殊表项之外的普通表项, 其中每个线程对 应一份线程页目录表, 每个线程的执行基于相对应的线程页目录表, 所述特 定数据是在不同节点具有多副本的数据; 修改模块, 用于对于每个线程在被 调度时, 当该线程的线程页目录表中的特殊表项未指向在该线程所在节点中 存储的所述特定数据时, 基于该特定数据的物理地址, 修改该特殊表项以指 向该特定数据。
基于上述技术方案, 通过创建线程页目录表, 并使线程目录表中的特殊 表项指向线程所在节点处的具有多副本的数据, 这样在线程执行过程中可以 使得分布到不同节点的线程访问所在节点处存储的数据副本,从而避免线程 访问远端数据产生的延迟并避免受到互联硬件传输带宽的限制,使得系统性 能得以提高。 附图说明 为了更清楚地说明本发明实施例的技术方案, 下面将对实施例中所需要 使用的附图作筒单地介绍, 显而易见地, 下面描述中的附图仅仅是本发明的 一些实施例, 对于本领域技术人员来讲, 在不付出创造性劳动的前提下, 还 可以根据这些附图获得其他的附图。
图 1是根据本发明实施例的多线程访问多副本的方法的流程图。
图 2 是根据本发明实施例的实现多线程访问多副本的逻辑结构的示意 图。
图 3是根据本发明实施例的多线程访问多副本的另一方法的流程图。 图 4是根据本发明实施例的在实现多线程访问多副本的情况下完整执行 进程的总过程的流程图。
图 5是根据本发明实施例的多线程访问多副本的再一方法的流程图。 图 6是根据本发明实施例的创建图 5 中的进程页目录表的方法的流程 图。
图 7是根据本发明实施例的用于多线程访问多副本的装置的结构框图。 图 8是根据本发明实施例的用于多线程访问多副本的另一装置的结构框 图。
图 9是根据本发明实施例的用于多线程访问多副本的再一装置的结构框 图。 具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例的技术方案进行清 楚、 完整地描述, 显然, 所描述的实施例是本发明的一部分实施例, 而不是 全部实施例。 基于本发明中的所述实施例, 本领域技术人员在没有做出创造 性劳动的前提下所获得的所有其他实施例, 都应属于本发明保护的范围。
首先,结合图 1描述根据本发明实施例的多线程访问多副本的方法 100。 如图 1所示, 方法 100包括: 在 S110中, 当进程的多个线程被分布到 不同节点时, 创建与进程的进程页目录表的内容相同的线程页目录表, 每份 线程页目录表包括用于指向特定数据的特殊表项和特殊表项之外的普通表 项, 其中每个线程对应一份线程页目录表, 每个线程的执行基于相对应的线 程页目录表, 特定数据是在不同节点具有多副本的数据; 在 S120 中, 对于 每个线程在被调度时, 当该线程的线程页目录表中的特殊表项未指向在该线 程所在节点中存储的特定数据时, 基于该特定数据的物理地址, 修改该特殊 表项以指向该特定数据。
这样, 通过创建线程页目录表, 并使线程目录表中的特殊表项指向线程 所在节点处存储的在不同节点具有多副本的特定数据, 可以使分布到不同节 点的线程访问所在节点中的特定数据,从而避免线程访问远端数据产生的延 迟并避免受到互联硬件传输带宽的限制, 使得系统性能得以提高。
在 S110 中, 进程可以被划分为多个线程, 线程可以被分布到不同的节 点来执行。 节点可以是 NUMA架构中的节点, 也可以是其他具有扩展性的 系统结构中支持多处理器并发操作的节点,还可以是需要实现多线程频繁访 问只读数据的任何装置中的节点等。
可以为线程创建线程页目录表,使得线程基于它所对应的线程页目录表 来执行。
例如, 每个线程可以对应只属于自己的一份线程页目录表。 这样, 如果 进程被划分为 20个线程, 那么需要为 20个线程创建 20份线程页目录表, 线程与线程页目录表——对应。
再例如,每个线程对应由与该线程处于同一节点的至少两个线程共享的 一份线程页目录表。 这样, 如果进程被划分为 20个线程, 20个线程被平均 分配到 4个节点, 那么每个节点中可以只有一份线程页目录表, 由该节点上 的线程所共享。 从而, 相比于线程与线程页目录表——对应的情形, 可以减 小需要维护的线程页目录表数量, 从而减小系统开销。 当然, 本领域技术人 员也可以想到, 在该例子中, 在一个节点也可以存在两份线程页目录表, 其 中一份由位于该节点的 5个线程中的两个共享, 另一份由剩余的 3个线程共 享。
还例如, 多个线程中的部分线程中的每个线程对应只属于自己的一份线 程页目录表, 其他线程中的每个线程对应由与该线程处于同一节点的至少两 个线程共享的一份线程页目录表。 该情形即是上述两种情形的组合。 例如, 进程包含的 20个线程被平均分配到 4个节点之后, 对于某节点上的 5个线 程, 其中的 2个线程可以分别具有只属于自己的线程页目录表, 另外 3个线 程可以共享一份线程页目录表, 此时在该节点共具有 3份线程页目录表。
当然, 本领域技术人员还可以想到其他设置线程页目录表的方式。 不管 一份线程页目录表对应一个还是多个线程, 一个线程对应一份线程页目录 表, 并基于它所对应的线程页目录表运行。 程页目录表中, 表项可以被分为特殊表项和普通表项这两部分。 特殊表项指 向特定数据, 该特定数据是在不同节点具有多副本的数据。 例如, 特定数据 可以是内核代码和内核只读数据, 也可以是内存中的所有只读数据, 还可以 是内存中的部分只读数据, 当然还可以是上述内容的组合。 通常, 在不同节 点具有多副本的数据是需要频繁访问的数据,所以特定数据也可以是这些频 繁访问的数据。
所创建的线程页目录表可以都是新创建的线程页目录表,也可以共享进 程页目录表来得到线程页目录表。 例如, 可以将进程页目录表设置为主线程 的线程页目录表; 对于其它线程, 生成与进程页目录表的内容相同的线程页 目录表。 此时, 所创建的主线程的线程页目录表就是进程页目录表, 将主线 程的线程页目录表指针指向进程页目录表即可,也可以置为空而默认指向进 程页目录表; 而针对主线程之外的其他线程, 则需要新生成线程页目录表。
在 S120中, 当调度线程时, 将线程对应的线程页目录表的地址加载到 硬件寄存器中以执行线程。 例如, 硬件寄存器可以是 X86平台下的 CR3寄 存器。如果某线程的线程页目录表中的特殊表项没有指向该线程所在节点中 的特定数据, 则修改该特殊表项, 使其指向本节点中的特定数据。 修改时需 要参考特定数据在本节点中存储的物理地址,基于物理地址来进行特殊表项 的修改。
这样,在修改了线程页目录表的特殊表项以指向线程所在节点中诸如内 核代码、 只读数据之类的特定数据之后, 在执行线程的过程中, 线程可以基 实现多线程访问多副本,避免访问远端数据造成的延迟和对传输带宽的高要 求, 并且可以提高对频繁访问的数据的访问效率, 从而提高系统性能。
以图 2为例来描述通过线程页目录表实现多线程访问多副本的逻辑结构 的示意图。在图 2中只示出了与本发明实施例有关的逻辑结构而不是全部的 逻辑结构。
在图 2中, 进程被划分线程 1、 线程 2和线程 3这三个线程, 并且这三 个进程处于不同的节点。 线程 1、 2、 3的地址空间指针分别指向进程地址空 间。 线程 1是主线程, 可以将进程页目录表作为线程 1的线程页目录表, 所 以线程 1的线程页目录表指针为空指针, 默认与进程页目录表指针相同。 当 然, 也可以将线程 1的线程页目录表指针设置为指向进程页目录表的值。 线 程 2和线程 3的线程页目录表指针分别指向线程 2和线程 3各自的线程页目 录表。
线程页目录表被划分为两部分, 分别是特殊表项和普通表项。 特殊表项 用于指向在不同节点具有多副本的数据。 在图 2中, 假设多副本的数据是包 括内核代码和内核只读数据的内核副本, 所以线程 1的线程页目录表中的特 殊表项指向线程 1所在节点的内核副本, 线程 2的线程页目录表中的特殊表 项指向线程 2所在节点的内核副本, 线程 3的线程页目录表中的特殊表项指 向线程 3所在节点的内核副本。 为了使特殊表项指向所在节点的多副本的数 据, 可以根据多副本的数据在节点中存储的物理地址, 来修改特殊表项中的 值以指向这些区域。
图 3是根据本发明实施例的多数据访问多副本的方法 300的流程图。 方 法 300在方法 100的基础上增加了同步普通表项的步骤, 以在实现多线程访 问多副本的过程中进一步保证线程的正常执行。
方法 300的 S310和 S320与方法 100的 S110和 S120基本相同。
在 S330中, 在基于各线程的线程页目录表执行各线程的过程中, 更新 需要同步的线程页目录表中的普通表项以使各线程正常执行。
将线程页目录表的地址加载到硬件寄存器之后, 可以开始执行线程。 在 线程执行过程中, 某个或某些线程可能由于新申请内存空间或释放内存空间 等而使得所对应的线程页目录表中的普通表项发生改变。该改变只会体现在 相对应的线程页目录表中,从而其他线程的线程页目录表中的普通表项并不 会因此改变, 那么其他线程在基于它们的线程页目录表进行执行的过程中可 能出现错误, 例如无法访问新开辟的内存空间或某内存空间无效了但仍然以 为有效等。 因此, 需要同步线程页目录表中的普通表项。
根据本发明的一个实施例, 当特定线程页目录表中的普通表项改变时, 基于该普通表项, 更新其它所有线程页目录表中的普通表项。
当某一线程页目录表中的普通表项发生改变时,将其他所有线程页目录 表中的普通表项都进行更新, 例如将发生改变的线程页目录表的普通表项的 内容拷贝到其他所有线程页目录表中的普通表项中。 可以将一个进程的所有线程页目录表由链表组织。 当任一线程中硬件寄 存器对应的线程页目录表修改时, 更新其他线程页目录表。 例如, 当主线程 的线程页目录表是进程页目录表时, 当在执行过程中有线程页目录表发生改 变时, 可以判断是否是主线程的线程页目录表发生改变, 如果是, 则修改其 他所有线程页目录表, 否则, 则告知修改进程页目录表即主线程的线程页目 录表, 再修改其他线程页目录表。
根据本发明的一个实施例, 当特定线程发生缺页异常时, 寻找发生了变 化的线程页目录表; 基于该线程页目录表中的普通表项, 更新所述特定线程 的线程页目录表中的普通表项。
例如,在图 2中假设线程 2在申请释放内存后修改了自己的线程页目录 表, 此时不立即更新其他所有线程页目录表中的普通表项, 而只是记录线程 2的线程页目录表发生了修改。 例如通过设置掩码标志位来记录哪个线程页 目录表发生了修改, 每个标志位对应一份线程页目录表。 当其他线程例如线 程 3在运行过程中访问此区域时, 会触发缺页异常。 此时, 线程 3寻找系统 中发生修改的线程页目录表, 例如通过掩码标志位来寻找哪些线程页目录表 有改变。 当找到线程 2的线程页目录表发生修改时, 线程 3将自己的线程页 目录表的普通表项更新为线程 2的线程页目录表的普通表项,从而解决缺页 异常而正常执行。
通过在线程运行过程中, 实时同步所有线程页目录表的普通表项, 或者 在出现缺页异常时更新相应线程页目录表的普通表项, 可以使每个线程在可 以访问具有多副本的数据的同时得以正常执行,从而保证进程功能的完整实 现。 并且, 在线程运行过程中进行的同步无需额外耗费内容空间, 在线程个 数较少的情况下同步开销也很小。
下面以图 4为例来描述既能实现多线程访问多副本、 又能使线程得以正 常执行的总过程的流程图。 在该例子中具有多副本的特定数据是内核副本, 本领域技术人员也可以想到特定数据也可以是内存中的只读数据等, 其实现 过程与之相似。
在 S410中, 过程开始。
在 S420中, 建立内核副本。 在各个节点申请内容, 并将主节点的内核 代码和内核只读数据拷贝到新申请的内存中, 并在各个节点记录本节点内核 副本的映射关系。 在 S430中, 进程创建。 将进程划分为多个线程, 并将线程分布到不同 的节点来执行。
在 S440中, 创建线程页目录表。 为新创建的线程建立线程页目录表。 在 S450中, 进程调度。 由于进程被划分为了多个线程, 所以进程调度 也是线程调度。
在 S460中, 进程运行。
在 S470中, 过程结束。
在 S440的创建线程页目录表的过程中, 使线程页目录表的内容与进程 页目录表的内容相一致。
在 S441中, 判断创建线程页目录表所针对的线程是否是主线程。
如果在 S441中判断是主线程, 则在 S442中, 将该线程的线程页目录表 指针置为空, 将进程页目录表作为其线程页目录表。
如果在 S441中判断不是主线程, 则在 S443中, 将进程页目录表的内容 复制到为该线程生成的线程页目录表中。
在 S450的进程调度过程中, 加载线程页目录表。
在 S451 中, 当一个线程被调度时, 判断该线程是否是主线程。 如果确 定该线程是主线程, 则前进到 S452, 否则前进到 S455。
在 S452中, 判断该线程基于相应的线程页目录表中的特殊表项, 是否 可以对内核副本进行本地访问。如果在 S452中确定不能本地访问内核副本, 则前进到 S453中, 否则前进到 S454中。 使其可以访问主线程所在节点中存储的内核副本。 行主线程的处理器对应的硬件寄存器中。
在 S455 中, 判断该线程基于相应的线程页目录表中的特殊表项, 是否 可以对内核副本进行本地访问。如果在 S455中确定不能本地访问内核副本, 则前进到 S456中, 否则前进到 S457中。
在 S456中, 修改该线程的线程页目录表中的特殊表项, 使其可以访问 该线程所在节点中存储的内核副本。
在 S457 中, 将该线程的线程页目录表的地址装载到执行该线程的处理 器对应的硬件寄存器中。 这样, 基于 S450中的操作, 可以装载所有线程对应的线程页目录表, 并使线程页目录表的特殊表项指向线程所在节点中存储的内核副本,从而进 行本地访问。
在 S460的进程运行过程中, 对需要同步的线程页目录表的普通表项进 行修改。 该处以同步所有线程页目录表中的普通表项为例进行描述。
在 S461 中, 某线程对应的线程页目录表被修改。 由于在线程运行过程 中普通表项会被修改, 所以此处修改的是普通表项。
在 S462中, 判断该线程是否为主线程。如果是主线程, 则前进到 S464, 否则前进到 S463。
在 S463 中, 由于主线程的线程页目录表是进程页目录表, 则更新进程 页目录表中的普通表项。
在 S464中, 更新除主线程之外的其他线程的线程页目录表中的普通表 项。
这样, 当特定线程的线程页目录表发生改变时, 利用该特定线程的线程 页目录表中的普通表项来更新其他所有线程的线程页目录表中的普通表项, 使得所有线程可以正常执行。
接下来, 参考图 5 描述根据本发明实施例的多线程访问多副本的方法 500的流程图。方法 500也可以使所有线程正常执行,但相比方法 300而言, 不是在运行线程的过程中同步线程页目录表的普通表项, 而是在创建线程页 目录表时就保证了线程可以正常执行。 方法 500的 S510和 S520与方法 100 的 S110和 S120基本相同。
在 S502中, 确定进程将使用的所有地址空间。
针对将被执行的进程,可以提前确定进程将使用的所有地址空间。例如, 提前预留进程将使用的所有用户空间。
在 S504中, 基于所有地址空间, 创建进程页目录表以指向所有地址空 间。
为进程预留好将使用的所有地址空间之后, 就可以基于这些空间的物理 地址来创建进程页目录表。 例如, 在进程创建主线程时, 可以为该进程的所 有用户空间申请页上级表, 并将该表的地址生成对应的页目录表项填入进程 页目录表中。
这样, 在进程运行过程中, 进程页目录表的普通表项不会由于内存单元 的新申请或释放等而改变,从而普通表项在运行过程中可以保持不变。因此, 当线程页目录表的普通表项与进程页目录表的普通表项一致时, 线程页目录 表的普通表项在运行过程中无需改变就可以使得线程得以正常执行。 此外, 利用预先保留好所有地址空间来创建进程页目录表进而创建线程页目录表, 可以节省方法 300中需要在运行过程中同步线程页目录表的效率开销, 以耗 费一些内存空间来换取各线程正常执行的筒便性。
例如,可以利用图 6所示的方式来创建图 5的 S504中的进程页目录表。 在 S610中, 进程创建。
在 S620中, 读取进程页目录表的普通表项中的下一项表项。
在 S630中, 判断该下一项表项是否为空。 如果为空, 则前进到 S640, 否则退回 S620。
在 S640中, 预留进程将使用的用户空间, 并分配页上级表。
在 S650中, 基于所分配的页上级表, 填充进程页目录表的表项以指向 该页上级表。
在 S660中, 进程页目录表填充是否结束。 如果结束, 则前进到 S670, 否则退回 S630。
在 S670中, 进程页目录表的普通表项填充完成。 这样, 进程页目录表 的普通表项指向了进程将使用到的所有用户地址空间。
上面描述了根据本发明实施例的多线程访问多副本的方法, 下面结合图 7至图 10描述与之相对应的装置的结构框图。
图 7是根据本发明实施例的用于多线程访问多副本的装置 700的结构框 图。
装置 700包括第一创建模块 710和修改模块 720。 第一创建模块 710可 用于当进程的多个线程被分布到不同节点时,创建与进程的进程页目录表的 内容相同的线程页目录表,每份线程页目录表包括用于指向特定数据的特殊 表项和特殊表项之外的普通表项, 其中每个线程对应一份线程页目录表, 每 个线程的执行基于相对应的线程页目录表,特定数据是在不同节点具有多副 本的数据。 修改模块 720可用于对于每个线程在被调度时, 当该线程的线程 页目录表中的特殊表项未指向在该线程所在节点中存储的特定数据时,基于 该特定数据的物理地址, 修改该特殊表项以指向该特定数据。
根据本发明的实施例, 特定数据可以包括如下至少一个: 内核代码和内 核只读数据; 内存中的只读数据。
根据本发明的实施例,每个线程可以对应只属于自己的一份线程页目录 表。每个线程也可以对应由与该线程处于同一节点的至少两个线程共享的一 份线程页目录表。 另外, 多个线程中的部分线程中的每个线程可以对应只属 于自己的一份线程页目录表, 其他线程中的每个线程可以对应由与该线程处 于同一节点的至少两个线程共享的一份线程页目录表。
第一创建模块 710和修改模块 720的上述和其他操作和 /或功能可以参考 上述方法 100中的 S110和 S120, 为了避免重复, 在此不再赘述。
根据本发明实施例提供的装置,在修改了线程页目录表的特殊表项以指 向线程所在节点中诸如内核代码、 只读数据之类的特定数据之后, 在执行线 节点中的特定数据, 从而实现多线程访问多副本, 避免访问远端数据造成的 延迟和对传输带宽的高要求, 并且可以提高对频繁访问的数据的访问效率, 从而提高系统性能。
图 8是根据本发明实施例的用于多线程访问多副本的装置 800的结构框 图。装置 800的第一创建模块 810和修改模块 820与装置 700的第一创建模 块 710和修改模块 720基本相同。
根据本发明的一个实施例, 装置 800可以包括更新模块 830。 更新模块 830可用于在基于各线程的线程页目录表执行各线程的过程中, 更新需要同 步的线程页目录表中的普通表项以使各线程正常执行。
根据本发明的一个实施例, 更新模块 830可用于当特定线程页目录表中 的普通表项改变时, 基于该普通表项, 更新其它所有线程页目录表中的普通 表项。
根据本发明的一个实施例, 更新模块 830可以包括寻找单元 832和更新 单元 834。 寻找单元 832可用于当特定线程发生缺页异常时, 寻找发生了变 化的线程页目录表。更新单元 834可用于基于该线程页目录表中的普通表项, 更新特定线程的线程页目录表中的普通表项。
根据本发明的一个实施例, 第一创建模块 810可以包括设置单元 812和 生成单元 814。 设置单元 812可用于将进程页目录表设置为主线程的线程页 目录表。 生成单元 814可用于对于其它线程, 生成与进程页目录表的内容相 同的线程页目录表。 更新模块 830、 寻找单元 832、 更新单元 834、 设置单元 812、 生成单元 814的上述和其他操作和 /或功能可以参考上述方法 300的 S330和上述方法 100的 S110, 为了避免重复, 在此不再赘述。
根据本发明实施例提供的装置, 通过在线程运行过程中, 实时同步所有 线程页目录表的普通表项, 或者在出现缺页异常时更新相应线程页目录表的 普通表项, 可以使每个线程在可以访问具有多副本的数据的同时得以正常执 行, 从而保证进程功能的完整实现。 并且, 在线程运行过程中进行的同步无 需额外耗费内容空间, 在线程个数较少的情况下同步开销也很小。
图 9是根据本发明实施例的用于多线程访问多副本的装置 900的结构框 图。装置 900的第一创建模块 910和修改模块 920与装置 700的第一创建模 块 710和修改模块 720基本相同。
根据本发明的一个实施例, 装置 900还可以包括确定模块 902和第二创 建模块 904。 确定模块 902可用于确定进程将使用的所有地址空间。 第二创 建模块 904可用于基于所有地址空间,创建进程页目录表以指向所有地址空 间。 此时, 第一创建模块 910创建的线程页目录表是基于第二创建模块 904 创建的进程页目录表来创建的。
确定模块 902和第二创建模块 904的上述和其他操作和 /或功能可以参考 上述方法 500的 S502和 S504, 为了避免重复, 在此不再赘述。
根据本发明实施例提供的装置, 在进程运行过程中, 进程页目录表的普 通表项不会由于内存单元的新申请或释放等而改变,从而普通表项在运行过 程中可以保持不变。 因此, 当线程页目录表的普通表项与进程页目录表的普 通表项一致时, 线程页目录表的普通表项在运行过程中无需改变就可以使得 线程得以正常执行。 此外, 利用预先保留好所有地址空间来创建进程页目录 表进而创建线程页目录表, 可以节省方法 300中需要在运行过程中同步线程 页目录表的效率开销, 以耗费一些内存空间来换取各线程正常执行的筒便 性。
本领域技术人员可以意识到,结合本文中所公开的实施例中描述的各方 法步骤和单元, 能够以电子硬件、 计算机软件或者二者的结合来实现, 为了 清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描 述了各实施例的步骤及组成。 这些功能究竟以硬件还是软件方式来执行, 取 决于技术方案的特定应用和设计约束条件。本领域技术人员可以对每个特定 的应用使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发 明的范围。
结合本文中所公开的实施例描述的方法步骤可以用硬件、处理器执行的 软件程序、 或者二者的结合来实施。 软件程序可以置于随机存取存储器
( RAM ), 内存、 只读存储器 (ROM )、 电可编程 ROM、 电可擦除可编程 ROM, 寄存器、 硬盘、 可移动磁盘、 CD-ROM或技术领域内所公知的任意 其它形式的存储介质中。
尽管已示出和描述了本发明的一些实施例, 但本领域技术人员应该理 解,在不脱离本发明的原理和精神的情况下,可对这些实施例进行各种修改, 这样的修改应落入本发明的范围内。

Claims

权利要求
1. 一种多线程访问多副本的方法, 其特征在于, 包括:
当进程的多个线程被分布到不同节点时,创建与所述进程的进程页目录 表的内容相同的线程页目录表,每份线程页目录表包括用于指向特定数据的 特殊表项和所述特殊表项之外的普通表项, 其中每个线程对应一份线程页目 录表, 每个线程的执行基于相对应的线程页目录表, 所述特定数据是在不同 节点具有多副本的数据;
对于每个线程在被调度时, 当该线程的线程页目录表中的特殊表项未指 向在该线程所在节点中存储的所述特定数据时, 基于该特定数据的物理地 址, 修改该特殊表项以指向该特定数据。
2. 根据权利要求 1所述的方法, 其特征在于, 还包括:
在基于各线程的线程页目录表执行各线程的过程中, 更新需要同步的线 程页目录表中的普通表项以使各线程正常执行。
3. 根据权利要求 2所述的方法, 其特征在于, 所述更新需要同步的线 程页目录表中的普通表项包括:
当特定线程页目录表中的普通表项改变时, 基于该普通表项, 更新其它 所有线程页目录表中的普通表项。
4. 根据权利要求 2所述的方法, 其特征在于, 所述更新需要同步的线 程页目录表中的普通表项包括:
当特定线程发生缺页异常时, 寻找发生了变化的线程页目录表; 基于该线程页目录表中的普通表项, 更新所述特定线程的线程页目录表 中的普通表项。
5. 根据权利要求 1所述的方法, 其特征在于, 所述创建与所述进程的 进程页目录表的内容相同的线程页目录表之前, 还包括:
确定所述进程将使用的所有地址空间;
基于所述所有地址空间, 创建进程页目录表以指向所述所有地址空间。
6. 根据权利要求 1所述的方法, 所述特定数据包括如下至少一个: 内核代码和内核只读数据;
内存中的只读数据。
7. 根据权利要求 1所述的方法, 其特征在于, 所述创建与所述进程的 进程页目录表的内容相同的线程页目录表包括:
将所述进程页目录表设置为主线程的线程页目录表;
对于其它线程,
8. 根据权利要求 1所述的方法, 其特征在于, 所述每个线程对应一份 线程页目录表包括如下之一:
每个线程对应只属于自己的一份线程页目录表;
每个线程对应由与该线程处于同一节点的至少两个线程共享的一份线 程页目录表;
所述多个线程中的部分线程中的每个线程对应只属于自己的一份线程 页目录表, 其他线程中的每个线程对应由与该线程处于同一节点的至少两个 线程共享的一份线程页目录表。
9. 一种用于多线程访问多副本的装置, 其特征在于, 包括:
第一创建模块, 用于当进程的多个线程被分布到不同节点时, 创建与所 述进程的进程页目录表的内容相同的线程页目录表,每份线程页目录表包括 用于指向特定数据的特殊表项和所述特殊表项之外的普通表项,其中每个线 程对应一份线程页目录表, 每个线程的执行基于相对应的线程页目录表, 所 述特定数据是在不同节点具有多副本的数据;
修改模块, 用于对于每个线程在被调度时, 当该线程的线程页目录表中 的特殊表项未指向在该线程所在节点中存储的所述特定数据时,基于该特定 数据的物理地址, 修改该特殊表项以指向该特定数据。
10. 根据权利要求 9所述的装置, 其特征在于, 还包括:
更新模块, 用于在基于各线程的线程页目录表执行各线程的过程中, 更 新需要同步的线程页目录表中的普通表项以使各线程正常执行。
11. 根据权利要求 10所述的装置, 其特征在于, 所述更新模块用于当 特定线程页目录表中的普通表项改变时, 基于该普通表项, 更新其它所有线 程页目录表中的普通表项。
12. 根据权利要求 10所述的装置, 其特征在于, 所述更新模块包括: 寻找单元, 用于当特定线程发生缺页异常时, 寻找发生了变化的线程页 目录表;
更新单元, 用于基于该线程页目录表中的普通表项, 更新所述特定线程 的线程页目录表中的普通表项。
13. 根据权利要求 9所述的装置, 其特征在于, 还包括: 确定模块, 用于确定所述进程将使用的所有地址空间;
第二创建模块, 用于基于所述所有地址空间, 创建进程页目录表以指向 所述所有地址空间。
14. 根据权利要求 9所述的装置, 所述特定数据包括如下至少一个: 内核代码和内核只读数据;
内存中的只读数据。
15. 根据权利要求 9所述的装置,其特征在于,所述第一创建模块包括: 设置单元, 用于将所述进程页目录表设置为主线程的线程页目录表; 生成单元, 用于对于其它线程, 生成与所述进程页目录表的内容相同的 线程页目录表。
16. 根据权利要求 9所述的装置, 其特征在于, 所述每个线程对应一份 线程页目录表包括如下之一:
每个线程对应只属于自己的一份线程页目录表;
每个线程对应由与该线程处于同一节点的至少两个线程共享的一份线 程页目录表;
所述多个线程中的部分线程中的每个线程对应只属于自己的一份线程 页目录表, 其他线程中的每个线程对应由与该线程处于同一节点的至少两个 线程共享的一份线程页目录表。
PCT/CN2011/074384 2011-05-20 2011-05-20 多线程访问多副本的方法和装置 WO2011127862A2 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
PCT/CN2011/074384 WO2011127862A2 (zh) 2011-05-20 2011-05-20 多线程访问多副本的方法和装置
EP11768473A EP2434402A4 (en) 2011-05-20 2011-05-20 METHOD AND DEVICE FOR A MULTI-THREAD FOR ACCESS TO SEVERAL COPIES
CN2011800005531A CN102203737B (zh) 2011-05-20 2011-05-20 多线程访问多副本的方法和装置
US13/339,230 US8880813B2 (en) 2011-05-20 2011-12-28 Method and device for multithread to access multiple copies

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/074384 WO2011127862A2 (zh) 2011-05-20 2011-05-20 多线程访问多副本的方法和装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US13/339,230 Continuation US8880813B2 (en) 2011-05-20 2011-12-28 Method and device for multithread to access multiple copies

Publications (2)

Publication Number Publication Date
WO2011127862A2 true WO2011127862A2 (zh) 2011-10-20
WO2011127862A3 WO2011127862A3 (zh) 2012-04-26

Family

ID=44662779

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/074384 WO2011127862A2 (zh) 2011-05-20 2011-05-20 多线程访问多副本的方法和装置

Country Status (4)

Country Link
US (1) US8880813B2 (zh)
EP (1) EP2434402A4 (zh)
CN (1) CN102203737B (zh)
WO (1) WO2011127862A2 (zh)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104252419B (zh) 2014-09-16 2017-09-19 华为技术有限公司 一种内存分配的方法及装置
CN104536764A (zh) * 2015-01-09 2015-04-22 浪潮(北京)电子信息产业有限公司 程序运行方法和装置
CN109766131B (zh) * 2017-11-06 2022-04-01 上海宝信软件股份有限公司 基于多线程技术实现软件智能化自动升级的系统及方法
CN113821157B (zh) * 2020-06-18 2024-05-24 中移(苏州)软件技术有限公司 一种本地磁盘挂载方法、装置、设备及存储介质
CN116841751B (zh) * 2023-08-31 2023-11-10 中国兵器装备集团兵器装备研究所 一种多任务线程池的策略配置方法、装置和存储介质

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6269391B1 (en) * 1997-02-24 2001-07-31 Novell, Inc. Multi-processor scheduling kernel
US6785888B1 (en) * 1997-08-29 2004-08-31 International Business Machines Corporation Memory allocator for a multiprocessor computer system
US20030066056A1 (en) * 2001-09-28 2003-04-03 Petersen Paul M. Method and apparatus for accessing thread-privatized global storage objects
US7334230B2 (en) * 2003-03-31 2008-02-19 International Business Machines Corporation Resource allocation in a NUMA architecture based on separate application specified resource and strength preferences for processor and memory resources
CN1842770A (zh) * 2003-08-28 2006-10-04 美普思科技有限公司 一种在处理器中挂起和释放执行过程中计算线程的整体机制
US7370156B1 (en) * 2004-11-04 2008-05-06 Panta Systems, Inc. Unity parallel processing system and method
EP1936498A1 (en) * 2006-12-21 2008-06-25 International Business Machines Corporation A method and system to manage memory accesses from multithread programs on multiprocessor systems
CN101464900B (zh) * 2009-01-15 2010-07-21 上海交通大学 Ntfs文件系统下轻量级文件隐藏方法
US9164812B2 (en) * 2009-06-16 2015-10-20 International Business Machines Corporation Method and system to manage memory accesses from multithread programs on multiprocessor systems
US8832388B2 (en) * 2011-03-11 2014-09-09 Microsoft Corporation Managing shared memory used by compute nodes
WO2011107040A2 (zh) * 2011-04-19 2011-09-09 华为技术有限公司 数据访问处理方法和设备

Non-Patent Citations (1)

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

Also Published As

Publication number Publication date
EP2434402A4 (en) 2012-08-01
CN102203737B (zh) 2013-09-11
WO2011127862A3 (zh) 2012-04-26
EP2434402A2 (en) 2012-03-28
US8880813B2 (en) 2014-11-04
CN102203737A (zh) 2011-09-28
US20120297149A1 (en) 2012-11-22

Similar Documents

Publication Publication Date Title
US10552337B2 (en) Memory management and device
EP2985702B1 (en) Data processing method and device, and computer system
US8055872B2 (en) Data processor with hardware accelerator, accelerator interface and shared memory management unit
JP5780243B2 (ja) スケジューリング方法、およびマルチコアプロセッサシステム
US10169087B2 (en) Technique for preserving memory affinity in a non-uniform memory access data processing system
US20120036334A1 (en) Access to shared memory segments by multiple application processes
US8793439B2 (en) Accelerating memory operations using virtualization information
US20070288720A1 (en) Physical address mapping framework
WO2011127862A2 (zh) 多线程访问多副本的方法和装置
US20150095585A1 (en) Consistent and efficient mirroring of nonvolatile memory state in virtualized environments
JP2019521409A (ja) 仮想アドレスから物理アドレスへの変換を実行する入出力メモリ管理ユニットにおける複数のメモリ素子の使用
WO2017190266A1 (zh) 管理转址旁路缓存的方法和多核处理器
CN101563674A (zh) 对来自多处理器系统上的多线程程序的存储器访问进行管理的方法和系统
WO2013131443A1 (zh) 存储数据的方法及装置
US20150095576A1 (en) Consistent and efficient mirroring of nonvolatile memory state in virtualized environments
US8006055B2 (en) Fine granularity hierarchiacal memory protection
US20120124297A1 (en) Coherence domain support for multi-tenant environment
CN111241011B (zh) 一种分布式持久性内存的全局地址空间管理方法
JP6343722B2 (ja) マルチコアシステムにおいてデータ訪問者ディレクトリにアクセスするための方法及びデバイス
WO2015035882A1 (zh) 基于节点控制器的请求响应方法和装置
US10733003B2 (en) Cost efficient and on-demand pool of running instances in a virtual machine environment
US20220237126A1 (en) Page table manager
JP2007226786A (ja) 別のプロセスのプロセス・ローカル・ストレージにアクセスする方法、装置、コンピュータ・プログラム、およびコンピュータ実装方法
KR101203157B1 (ko) 데이터 전달 시스템, 장치 및 방법
US11281612B2 (en) Switch-based inter-device notational data movement system

Legal Events

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

Ref document number: 201180000553.1

Country of ref document: CN

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

Ref document number: 11768473

Country of ref document: EP

Kind code of ref document: A2

REEP Request for entry into the european phase

Ref document number: 2011768473

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2011768473

Country of ref document: EP

NENP Non-entry into the national phase

Ref country code: DE