Thread working method based on floating data and terminal

By adopting random rotation scheduling based on floating data and independent task memory methods in thread work, the problem of high resource consumption during thread security guarantee is solved, and efficient and safe thread task execution is achieved.

CN120066763APending Publication Date: 2025-05-30FUJIAN TQ ONLINE INTERACTIVE INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510019386.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

When the prior art ensures the security of threads and data in thread work, the processing time is increased, resource consumption is large, and memory usage is increased.

Method used

Using a thread working method based on floating data, the target thread that performs the target step execution is selected from the idle execution thread through random rotation scheduling, and each execution thread is allocated independent task memory.

Benefits of technology

While keeping the total number of threads unchanged, the execution security of target tasks is ensured and resource consumption is reduced through the floating mechanism and random rotation of threads.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066763A_ABST
    Figure CN120066763A_ABST
Patent Text Reader

Abstract

According to the drifting data-based thread working method and the terminal, thread initialization is carried out, a plurality of execution threads are generated, and an independent task memory is allocated for each execution thread; for each target step of the target task, selecting a target thread for executing the target step from each idle execution thread in a random round-robin scheduling mode, and distributing task data and randomly distributing task attributes for the target thread; according to the method, under the condition that the total number of the threads is kept unchanged, a fluttering mechanism is established, a mode of randomly rotating the threads is adopted, and one of the execution threads is selected to execute the target task, so that an attacker cannot quickly obtain the hijacked target object, the execution safety of the target task is ensured, and compared with a daemon thread, the resource consumption is effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data thread security, and particularly relates to a thread working method and a terminal based on floating data. Background Art

[0002] Thread safety means that when a certain function, method or code segment is concurrently accessed by multiple threads in a multi-threaded environment, it can correctly process the data of each thread, ensure the correctness of the data, and prevent data pollution, hijacking, etc.

[0003] Data security means that data is symmetrically encrypted / asymmetrically encrypted through technical means, and the spatial complexity is used to limit the possibility of data being cracked.

[0004] Thread data security means that the data in a thread is manually protected by technology from being tampered with, and the security of the data in the thread is maintained.

[0005] Data thread security means that through mutual monitoring between threads, the threads can mutually monitor and protect the thread data from being hijacked, polluted, hooked, etc.

[0006] In the prior art, in order to ensure the security of threads and data during thread operation, various protection schemes are adopted. Among them, maximizing the complexity of data through encryption usually significantly increases the processing time; using a daemon thread to protect other threads may cause additional resource consumption; checking the operation of threads / data by creating a cyclic redundancy check (CRC) increases the memory usage and running time of the program. Summary of the Invention

[0007] The technical problem to be solved by the present invention is: to provide a thread working method and a terminal based on floating data, which ensure security while being more efficient.

[0008] To solve the above technical problem, the technical solution adopted by the present invention is: A thread working method based on floating data, comprising the steps of: S1. Perform thread initialization, generate multiple execution threads, and allocate independent task memory for each of the execution threads; S2. For each target step of a target task, randomly select a target thread for executing the target step from the idle execution threads through a random rotation scheduling method, and allocate task data and randomly assign task attributes to the target thread.

[0009] To solve the above technical problem, the technical solution adopted by the present invention is: A thread working terminal based on floating data, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: S1. Perform thread initialization, generate multiple execution threads, and allocate independent task memory for each of the execution threads; S2. For each target step of a target task, select a target thread for executing the target step from each of the idle execution threads by means of random round-robin scheduling, allocate task data for the target thread, and randomly allocate task attributes.

[0010] The beneficial effects of the present invention are as follows: A thread working method and terminal based on floating data of the present invention generate multiple execution threads. While keeping the total number of threads unchanged, a floating mechanism is established, and in the way of randomly rotating threads, one of the execution threads is selected to execute the target task. Moreover, each execution thread has independent task memory. Even if thread hijacking occurs, due to the independence of the task memory, the normal work of other execution threads will not be affected. And when the current execution thread is unresponsive, other execution threads can also be allocated to execute the current step, thereby ensuring the security of the execution of the target task. And compared with daemon threads, the resource consumption is effectively reduced. Description of the Drawings

[0011] Figure 1 It is a flowchart of a thread working method based on floating data according to an embodiment of the present invention; Figure 2 It is a structural diagram of a thread working terminal based on floating data according to an embodiment of the present invention; Label Description: 1. A thread working terminal based on floating data; 2. Processor; 3. Memory. Detailed Embodiments

[0012] To describe in detail the technical content, achieved objectives, and effects of the present invention, the following is described in conjunction with embodiments and with reference to the drawings.

[0013] Please refer to Figure 1 , a thread working method based on floating data, comprising the steps of: S1. Perform thread initialization, generate multiple execution threads, and allocate independent task memory for each of the execution threads; S2. For each target step of a target task, select a target thread for executing the target step from each of the idle execution threads by means of random round-robin scheduling, allocate task data for the target thread, and randomly allocate task attributes.

[0014] As can be seen from the above description, the beneficial effects of the present invention are as follows: A thread working method and a terminal based on floating data of the present invention generate multiple execution threads. While keeping the total number of threads unchanged, a floating mechanism is established, and the method of randomly rotating threads is adopted to select one of the execution threads to execute the target task. Moreover, each execution thread has an independent task memory. Even if thread hijacking occurs, due to the independence of the task memory, it will not affect the normal operation of other execution threads. And when the current execution thread is unresponsive, other execution threads can also be allocated to execute the current step, thereby ensuring the security of the target task execution. And compared with the daemon thread, the resource consumption is effectively reduced.

[0015] Further, step S1 is specifically as follows: Perform thread initialization, generate a TASK thread and multiple execution threads. Each of the execution threads has an independent task memory, and a thread state machine for recording the thread state is set for each of the execution threads, and a memory state machine for recording the task attributes is set for each of the task memories.

[0016] As can be seen from the above description, when performing thread initialization, in addition to generating execution threads, a TASK thread for thread management also needs to be generated. At the same time, a thread state machine is allocated to each execution thread to record the working state of the current thread, and a memory state machine is allocated to each task memory to record the task attributes.

[0017] Further, step S2 is specifically as follows: For each target step of the target task, the TASK thread selects the execution threads according to the states of the respective thread state machines to obtain the first execution threads whose all thread state machines are in the unactivated state; Select a target thread for executing the target step from each of the first execution threads by means of random rotation scheduling, allocate task data to the task memory of the target thread, and randomly allocate task attributes to the memory state machine of the task memory; The selection of the task attributes includes encryption and non-encryption, and the execution memory determines whether to encrypt the task memory according to the task attributes.

[0018] As can be seen from the above description, the TASK thread performs random rotation scheduling of the execution threads, randomly selects from the idle execution memories, and randomly allocates task attributes.

[0019] Further, the number of the executors and execution threads is determined according to the total number of CPU cores.

[0020] As described above, the number of executors and execution threads is determined according to the total number of CPU cores, so that the number of execution threads and executors can be reasonably set to give full play to the device performance.

[0021] Further, the relationship among the executor, the execution thread, and the total number of CPU cores is expressed as: m = 2n - 1; where m represents the number of the executors / execution threads, and n represents the total number of CPU cores.

[0022] As described above, in the case of hyper-threading, each core can support 2 executors, and the number of threads is equal to the number of executors, so that each thread can exclusively occupy one executor to achieve parallel execution.

[0023] Please refer to Figure 2 , a thread working terminal based on floating data, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: S1. Perform thread initialization, generate multiple execution threads, and allocate independent task memory for each execution thread; S2. For each target step of the target task, select a target thread for executing the target step from the idle execution threads by means of random round-robin scheduling, allocate task data for the target thread, and randomly allocate task attributes.

[0024] As can be seen from the above description, the beneficial effects of the present invention are as follows: A thread working method and terminal based on floating data of the present invention generate multiple execution threads. While keeping the total number of threads unchanged, a floating mechanism is established, and a random round-robin thread method is adopted to select one of the execution threads to execute the target task. Moreover, each execution thread has independent task memory. Even if thread hijacking occurs, due to the independence of the task memory, the normal work of other execution threads will not be affected. And when the current execution thread is unresponsive, other execution threads can also be allocated to execute the current step, thereby ensuring the security of the target task execution. And compared with daemon threads, the resource consumption is effectively reduced.

[0025] Further, step S1 is specifically: Perform thread initialization, generate a TASK thread and multiple execution threads. Each execution thread has independent task memory, and a thread state machine for recording the thread state is set for each execution thread, and a memory state machine for recording task attributes is set for each task memory.

[0026] As described above, when initializing a thread, in addition to generating an execution thread, a TASK thread for thread management needs to be generated. At the same time, a thread state machine is allocated to each execution thread to record the working state of the current thread, and a memory state machine is allocated to each task memory to record task attributes.

[0027] Further, step S2 is specifically as follows: For each target step of the target task, the TASK thread selects the execution thread according to the states of the respective thread state machines, and obtains the first execution threads in which all the thread state machines are in an unactivated state; Selects a target thread for executing the target step from the respective first execution threads by means of random round-robin scheduling, allocates task data to the task memory of the target thread, and randomly allocates task attributes to the memory state machine of the task memory; The selection of the task attributes includes encryption and non-encryption, and the execution memory determines whether to encrypt the task memory according to the task attributes.

[0028] As described above, the TASK thread performs random round-robin scheduling of the execution threads, randomly selects from the idle execution memories, and randomly allocates task attributes.

[0029] Further, the number of the executors and execution threads is determined according to the total number of CPU cores.

[0030] As described above, determining the number of executors and execution threads according to the total number of CPU cores can reasonably set the number of execution threads and executors to give full play to the device performance.

[0031] Further, the relationship between the executor, the execution thread and the total number of CPU cores is expressed as: m = 2n - 1; where m represents the number of the executors / execution threads, and n represents the total number of CPU cores.

[0032] As described above, in the case of hyper-threading, each core can support 2 executors, and the number of threads is equal to the number of executors, so each thread can exclusively occupy one executor to achieve parallel execution.

[0033] A thread working method and a terminal based on floating data according to the present invention are applicable to security protection in the process of computer task execution.

[0034] Please refer to Figure 1 , and Embodiment 1 of the present invention is: A thread working method based on floating data, comprising the steps of: S1. Initialize threads, generate multiple execution threads, and allocate independent task memory for each of the execution threads; Step S1 is specifically as follows: Initialize threads, generate a TASK thread and multiple execution threads. Each of the execution threads has independent task memory, and a thread state machine for recording the thread state is set for each of the execution threads, and a memory state machine for recording task attributes is set for each of the task memories.

[0035] The number of the executors and execution threads is determined according to the total number of CPU cores. The relationship among the executors, the execution threads, and the total number of CPU cores is expressed as: m = 2n - 1; where m represents the number of the executors / the execution threads, and n represents the total number of CPU cores.

[0036] In this embodiment, a target task that requires random threads is passed in and threads are initialized. The initial threads consist of 2 types of threads, including a TASK thread and other initial threads (execution threads) (explained as other initial threads here because the task memory state is not unique).

[0037] In this embodiment, the number of created threads is determined according to the total number of CPU cores n. Excluding the number 1 of the TASK thread, the number of created executors and execution threads is both 2n - 1. For example, if the total number of CPU cores is 3, then 6 threads are generated. One of them is the TASK thread and needs to be excluded, and the remaining 5 are execution threads.

[0038] In this embodiment, an executor is loaded in each execution thread. The executor is provided with independent task memory, and the executor has operation rules for the task memory.

[0039] Meanwhile, the executor has a thread state machine, and the thread state machine records the excited state or unexcited state of the executor, that is, the usage state of the thread. The task memory of each executor is provided with a memory state machine, and the memory state machine records task attributes, including encrypted or not encrypted, which determines whether the task memory is encrypted when the thread executes.

[0040] S2. For each target step of the target task, select a target thread for executing the target step from each of the idle execution threads by means of random round-robin scheduling, allocate task data to the target thread and randomly allocate task attributes; Step S2 is specifically as follows: For each target step of the target task, the TASK thread selects the execution thread according to the states of the respective thread state machines, and obtains the first execution threads for which all the thread state machines are in an untriggered state; Select a target thread for executing the target step from each of the first execution threads by means of random round-robin scheduling, allocate task data to the task memory of the target thread, and randomly allocate task attributes to the memory state machine of the task memory; The selection of the task attributes includes encryption and non-encryption, and the execution memory determines whether to encrypt the task memory according to the task attributes.

[0041] In this embodiment, during execution, the TASK thread randomly selects an idle executor according to the thread state machine of the execution thread executor, and different independent task memories are stored in the executor.

[0042] After the execution of the current step in the target task is completed, clear the data in the task memory.

[0043] For each target step in the target task, the same method is used for processing. Since the execution subject is randomly switched during the execution of each step of the entire target task, the working thread and the working memory mode are randomly rotated. In this way, it is impossible to obtain what operations the task memory needs to perform by interrupting the hijack thread. Even if a thread hijacking occurs, due to the independence of the task memory, it will not affect the normal work of other execution threads, and when the current execution thread is unresponsive, other execution threads can also be allocated to execute the current step, thereby ensuring the security of the execution of the target task, and effectively reducing resource consumption compared with the daemon thread.

[0044] Please refer to Figure 2 , Embodiment 2 of the present invention is: A thread working terminal 1 based on floating data, comprising a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, it implements the steps in a thread working method based on floating data in Embodiment 1 above.

[0045] In summary, a thread working method and a terminal based on floating data provided by the present invention generate multiple execution threads. While keeping the total number of threads unchanged, a floating mechanism is established, and the method of randomly rotating threads is adopted to select one of the execution threads to execute the target task, so that the working threads and the working memory mode rotate randomly. In this way, it is impossible to obtain what operations need to be performed on the task memory by interrupting and hijacking the thread. Even if thread hijacking occurs, due to the independence of the task memory, it will not affect the normal work of other execution threads, and when the current execution thread is unresponsive, other execution threads can also be allocated to execute the current step, thus ensuring the security of the target task execution. And compared with the daemon thread, the resource consumption is effectively reduced.

[0046] The above are only the embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in the relevant technical fields, shall be included in the patent protection scope of the present invention by the same token.

Claims

1. A thread working method based on floating data, characterized in that: Includes steps: S1. Perform thread initialization, generate multiple execution threads, and allocate independent task memory to each of the execution threads; S2. For each target step of the target task, a target thread for executing the target step is selected from the idle execution threads by random round-robin scheduling, and task data and task attributes are randomly assigned to the target thread.

2. A thread working method based on floating data according to claim 1, characterized in that: Step S1 is specifically as follows: Perform thread initialization to generate a TASK thread and multiple execution threads, each of which has an independent task memory, and set a thread state machine for recording thread status for each of the execution threads, and set a memory state machine for recording task attributes for each of the task memories.

3. A thread working method based on floating data according to claim 2, characterized in that: Step S2 is specifically as follows: For each target step of the target task, the TASK thread selects the execution thread according to the state of each thread state machine, and obtains the first execution thread in which all the thread state machines are in an unactivated state; Selecting a target thread for executing the target step from each of the first execution threads by random round-robin scheduling, allocating task data to the task memory of the target thread, and randomly allocating task attributes to the memory state machine of the task memory; The selection of the task attribute includes encryption and non-encryption, and the execution memory determines whether to encrypt the task memory according to the task attribute.

4. The thread working method based on floating data according to claim 1 is characterized in that: The number of executors and execution threads is determined according to the total number of CPU cores.

5. A thread working method based on floating data according to claim 4, characterized in that: The relationship between the executor, the execution thread and the total number of CPU cores is expressed as: m=2n-1; Wherein, m represents the number of the executors / the execution threads, and n represents the total number of the CPU cores.

6. A thread work terminal based on floating data, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: S1. Perform thread initialization, generate multiple execution threads, and allocate independent task memory to each of the execution threads; S2. For each target step of the target task, a target thread for executing the target step is selected from the idle execution threads by random round-robin scheduling, and task data and task attributes are randomly assigned to the target thread.

7. A thread work terminal based on floating data according to claim 6, characterized in that: Step S1 is specifically as follows: Perform thread initialization to generate a TASK thread and multiple execution threads, each of which has an independent task memory, and set a thread state machine for recording thread status for each of the execution threads, and set a memory state machine for recording task attributes for each of the task memories.

8. A thread work terminal based on floating data according to claim 7, characterized in that: Step S2 is specifically as follows: For each target step of the target task, the TASK thread selects the execution thread according to the state of each thread state machine, and obtains the first execution thread in which all the thread state machines are in an unactivated state; Selecting a target thread for executing the target step from each of the first execution threads by random round-robin scheduling, allocating task data to the task memory of the target thread, and randomly allocating task attributes to the memory state machine of the task memory; The selection of the task attribute includes encryption and non-encryption, and the execution memory determines whether to encrypt the task memory according to the task attribute.

9. The thread work terminal based on floating data according to claim 6, characterized in that: The number of executors and execution threads is determined according to the total number of CPU cores.

10. A thread work terminal based on floating data according to claim 9, characterized in that: The relationship between the executor, the execution thread and the total number of CPU cores is expressed as: m=2n-1; Wherein, m represents the number of the executors / the execution threads, and n represents the total number of the CPU cores.