Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

Multithreading hard real-time control method based on Linux

A control method, hard real-time technology, applied in the field of multi-thread processing, can solve the problem that multiple threads cannot access shared resources at the same time, achieve the effect of hard real-time control height, real-time recovery of the controlled thread, and real-time suspension of the controlled thread

Active Publication Date: 2013-10-09
XIAMEN YAXON NETWORKS CO LTD
View PDF7 Cites 14 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

Among them, mutexes are used, and mutexes are mainly used to protect shared resources, so that multiple threads cannot access shared resources at the same time

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Multithreading hard real-time control method based on Linux

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0025] refer to figure 1 , the specific implementation steps of the scheme of the present invention are as follows:

[0026] Step 1: Define a global mutex and initialize the mutex;

[0027] Step 2: Create a main control thread and a controlled thread. One main control thread can control one or more controlled threads at the same time. In this embodiment, there is one main control thread and one controlled thread, which is recorded as the main control thread Thread A and controlled thread B;

[0028] Step 3: Apply for a mutex lock in the main control thread A; perform signal registration in the controlled thread B, and define the corresponding received signal type and received signal processing function; the so-called "signal registration" mainly refers to the A thread registers a signal so that the thread can receive the signal in the future. As for which signal to register, that is, "signal type", this generally uses signals such as "SIGUSR1" and "SIGUSR2" provided by the ...

Embodiment 2

[0035] Step 1: Define a global mutex and initialize the mutex;

[0036] Step 2: Create a master control thread and a controlled thread. One master control thread can control one or more controlled threads at the same time. In this embodiment, there is one master control thread, which is recorded as master control thread A; There are N threads, which are recorded as controlled threads B1, ..., controlled threads BN, N≥2; the main control thread A controls N controlled threads, and each controlled thread needs to be registered as a different signal type. At the same time, each controlled thread uses its own mutex, so that it can be controlled more clearly and accurately. It is possible to separately control the suspension or recovery of different threads, and it is also possible to suspend or resume multiple threads at the same time;

[0037] Step 3: Apply for a mutex in the main control thread A, perform signal registration in the controlled thread B1, ..., and the controlled ...

Embodiment 3

[0043] Step 1: Define multiple global mutexes and initialize the mutexes;

[0044] Step 2: Create a master control thread and a controlled thread. One master control thread can control one or more controlled threads at the same time. In this embodiment, there is one master control thread, which is recorded as master control thread A; There are N threads, recorded as controlled threads B1, ..., controlled threads BN, N≥2; the main control thread A controls N controlled threads, and each controlled thread needs to be registered as a different signal type, so In order to have a clearer and more precise control. It is possible to control the suspension or recovery of different threads separately;

[0045] Step 3: Apply for a mutex in the main control thread A, perform signal registration in the controlled thread B1, ..., and the controlled thread BN, and define the corresponding received signal type and received signal processing function, and the controlled thread B1, ... , the...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a multithreading hard real-time control method based on Linux. The multithreading hard real-time control method based on Linux comprises the following steps that step 1, an overall situation mutual exclusion lock is defined and initialized; step 2 a master control thread and a controlled thread are created; step 3, a mutual exclusion lock is applied in the master control thread and signal registration is conducted in the controlled thread; step 4, the master control thread is monitored in real time, whether the controlled thread needs to be suspended or not by the master control thread in real time is detected, if the answer is positive, a step 5 is conducted; if the answer is negative, whether the controlled thread needs to be recovered or not by the master control thread is detected, and if the answer is positive, a step 6 is conducted; if the answer is negative, the step 4 is conducted in a circulating mode; step 5, the master control thread conducts the operation of suspending the controlled thread and the step 4 is conducted; step 6, the controlled thread is recovered by the master control thread; step 7, a mutual exclusion lock is applied again by the master control thread and the step 4 is conducted. The high priority of signal transmission and the characters of the mutual exclusion locks are used, so that the purposes that the controlled thread is suspended in real time and recovered in real time are achieved, and the requirement for hard real time is satisfied.

Description

technical field [0001] The invention relates to multi-thread processing, in particular to a Linux-based multi-thread hard real-time control method. Background technique [0002] In the existing Linux system development, multi-threaded development technology is basically used. And mutual control is required in multi-threading. [0003] Current general thread control method has: a, by using global variable. The A thread loops to judge the current value of the variable to switch the state, and the B thread modifies the variable value to control the A thread. This wastes resources and cannot be controlled in real time. b. Use condition variables. The thread using the condition variable can wake up the thread, but it cannot suspend the thread in real time externally, and the suspension can only be done after the thread itself runs to the suspension point. Therefore, only thread synchronization is realized, but no thread real-time control. The above existing methods cannot a...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F9/46
Inventor 陈华云郑振贵刘伟峰郑福弟
Owner XIAMEN YAXON NETWORKS CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products