CN117041373A - USB-based single-channel multi-service parallel processing method and device - Google Patents

USB-based single-channel multi-service parallel processing method and device Download PDF

Info

Publication number
CN117041373A
CN117041373A CN202310779533.3A CN202310779533A CN117041373A CN 117041373 A CN117041373 A CN 117041373A CN 202310779533 A CN202310779533 A CN 202310779533A CN 117041373 A CN117041373 A CN 117041373A
Authority
CN
China
Prior art keywords
instruction
data
service
thread
processing
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.)
Pending
Application number
CN202310779533.3A
Other languages
Chinese (zh)
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 Smartchip Microelectronics Technology Co Ltd
Beijing Smartchip Semiconductor Technology Co Ltd
Original Assignee
Beijing Smartchip Microelectronics Technology Co Ltd
Beijing Smartchip Semiconductor Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Smartchip Microelectronics Technology Co Ltd, Beijing Smartchip Semiconductor Technology Co Ltd filed Critical Beijing Smartchip Microelectronics Technology Co Ltd
Priority to CN202310779533.3A priority Critical patent/CN117041373A/en
Publication of CN117041373A publication Critical patent/CN117041373A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/12Protocol engines
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • H04L67/125Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks involving control of end-device applications over a network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Information Transfer Systems (AREA)

Abstract

The application relates to the technical field of USB service processing, and provides a single-channel multi-service parallel processing method and device based on USB. The single-channel multi-service parallel processing method based on the USB comprises the following steps: after receiving a Setup data packet for triggering interrupt processing, triggering a corresponding first thread to receive an expansion instruction; when the received expansion instruction is determined to be a service instruction, processing data in the expansion instruction by a service processing thread to obtain result data; storing the result data to a designated position by adopting a second thread, and identifying the corresponding relation between the result data and an expansion instruction; and adopting a third thread to send the result data as a response to the corresponding expansion instruction. The embodiment of the application improves the data processing efficiency of the single-channel USB.

Description

USB-based single-channel multi-service parallel processing method and device
Technical Field
The application relates to the technical field of USB service processing, in particular to a single-channel multi-service parallel processing method based on USB, a single-channel multi-service parallel processing device based on USB, electronic equipment and a corresponding storage medium.
Background
The security chip is continuously improved in the aspects of memory capacity, CPU processing capacity, process level and the like, and the requirements of service integration are gradually met. Current schemes for processing multiple services by using a security chip mostly adopt a serial processing mode.
In the existing scheme, the security module sets different instruction lists according to different services, the security module stores instructions into the different lists according to service numbers, the security module sequentially executes the instructions in the lists according to the receiving sequence, then sequentially outputs the execution results, and the whole execution process is in a serial mode. In the serial mode, after the first instruction is executed and a response is given, the response result of the second service instruction can be waited. If the first instruction is processed for a longer time, communication is blocked, and meanwhile, the chip kernel uses a single-task operating system, so that the instruction processing efficiency is lower. Even if the multitasking operating system is used in the chip to process instructions in parallel, the processing efficiency of the whole chip cannot be improved due to communication blockage.
Disclosure of Invention
The embodiment of the application aims to provide a single-channel multi-service parallel processing method and device based on USB, which can enable a plurality of services to be processed in parallel by improving a communication mode and using a multi-task operating system, thereby improving the efficiency to the maximum extent and at least solving part of problems in the background technology.
In order to achieve the above object, the present application provides a single-channel multi-service parallel processing method based on USB, which includes: after receiving a Setup data packet for triggering interrupt processing, triggering a corresponding first thread to receive an expansion instruction; when the received expansion instruction is determined to be a service instruction, processing data in the expansion instruction by a service processing thread to obtain result data; storing the result data to a designated position by adopting a second thread, and identifying the corresponding relation between the result data and an expansion instruction; and adopting a third thread to send the result data as a response to the corresponding expansion instruction.
Preferably, the expansion instruction is obtained by: expanding the SCSI protocol instruction, and respectively determining an expansion instruction of an input direction and an output direction according to the data transmission direction; the extended instruction of the output direction is divided into a service inquiry instruction and a service instruction according to the content of the CBWCB field contained in the extended instruction.
Preferably, the sending end of the expansion instruction triggers the service processing of the receiving end by issuing the service instruction, and then obtains the response to the expansion instruction by issuing the service inquiry instruction.
Preferably, the method further comprises: determining the content in the Setup data packet according to the expansion instruction; before a transmitting end of an expansion instruction transmits the expansion instruction, a Setup data packet corresponding to the expansion instruction is transmitted.
Preferably, after the corresponding first thread receives the extended instruction, the method further comprises: and feeding back a receiving result.
Preferably, the second thread and the third thread are parallel threads.
Preferably, the method further comprises: and triggering a third thread to send result data as a response to the corresponding expansion instruction when the received expansion instruction is determined to be the service query instruction.
Preferably, the service processing threads are multiple and are respectively used for processing data of different service numbers.
Preferably, the method further comprises a fourth thread, and the fourth thread is used for distributing the data to different service processing threads according to the service numbers in the data.
Preferably, the threads cooperate with each other via semaphores and/or data state information.
Preferably, the data state information is defined as one of the following states in the set of states: the state can be used, the upper computer downlink data is filled into the user random access memory, the fourth thread acquires data through the service processing thread but not yet, the downlink data is acquired by the service processing thread, and the upper computer downlink data is abnormal.
Preferably, identifying the correspondence between the result data and the extended instruction includes: and adding a data tag to the result data to identify the corresponding relation between the result data and the expansion instruction.
Preferably, the data tag is a command block identification field in a CBW packet of the extended instruction.
The application also provides a single-channel multi-service parallel processing device based on USB, which comprises: the data receiving module is used for triggering the corresponding first thread to receive the expansion instruction after receiving the Setup data packet for triggering the interrupt processing; the business processing module is used for processing the data in the expansion instruction by the business processing thread to obtain result data when the received expansion instruction is determined to be the business instruction; the corresponding identification module is used for storing the result data to a designated position by adopting a second thread and identifying the corresponding relation between the result data and an expansion instruction; and the data sending module is used for sending the result data as a response to the corresponding expansion instruction by adopting the third thread.
Preferably, the expansion instruction is obtained by: expanding the SCSI protocol instruction, and respectively determining an expansion instruction of an input direction and an output direction according to the data transmission direction; the extended instruction of the output direction is divided into a service inquiry instruction and a service instruction according to the content of the CBWCB field contained in the extended instruction.
Preferably, the sending end of the expansion instruction triggers the service processing of the receiving end by issuing the service instruction, and then obtains the response to the expansion instruction by issuing the service inquiry instruction.
Preferably, the method further comprises: determining the content in the Setup data packet according to the expansion instruction; before a transmitting end of an expansion instruction transmits the expansion instruction, a Setup data packet corresponding to the expansion instruction is transmitted.
Preferably, after the corresponding first thread receives the extended instruction, the method further comprises: and feeding back a receiving result.
Preferably, the second thread and the third thread are parallel threads.
Preferably, the method further comprises: and triggering a third thread to send result data as a response to the corresponding expansion instruction when the received expansion instruction is determined to be the service query instruction.
Preferably, the service processing threads are multiple and are respectively used for processing data of different service numbers.
Preferably, the method further comprises a fourth thread, and the fourth thread is used for distributing the data to different service processing threads according to the service numbers in the data.
Preferably, the threads cooperate with each other via semaphores and/or data state information.
Preferably, the data state information is defined as one of the following states in the set of states: the state can be used, the upper computer downlink data is filled into the user random access memory, the fourth thread acquires data through the service processing thread but not yet, the downlink data is acquired by the service processing thread, and the upper computer downlink data is abnormal.
Preferably, identifying the correspondence between the result data and the extended instruction includes: and adding a data tag to the result data to identify the corresponding relation between the result data and the expansion instruction.
Preferably, the data tag is a command block identification field in a CBW packet of the extended instruction.
The application also provides an electronic device, comprising: at least one processor; a memory coupled to the at least one processor; the memory stores instructions executable by the at least one processor, and the at least one processor implements the steps of the single-channel multi-service parallel processing method based on USB by executing the instructions stored by the memory.
There is also provided in the present application a machine-readable storage medium having stored thereon instructions that when executed by a processor cause the processor to be configured to perform the steps of implementing the aforementioned USB-based single-channel multi-service parallel processing method.
There is also provided in the present application a computer program product comprising a computer program which, when executed by a processor, implements the steps of the aforementioned USB-based single channel multi-service parallel processing method.
The technical scheme has the following beneficial effects:
(1) The instruction can be responded quickly, the processing of the last instruction is not needed to be completed, and the instruction blocking is avoided.
(2) The processing of a plurality of services received from the same USB channel is processed in parallel in a thread mode in a multi-task system, and for time-consuming services (such as algorithm, flash write operation and the like), the simultaneous operation of the processing of the plurality of services can be realized, so that the processing efficiency of the services is improved.
(3) The receiving and transmitting process of the application layer and the processing process of the service instruction can be performed simultaneously, so that the working efficiency of the whole system is improved.
(4) The sending process is not influenced by the receiving sequence of the instructions, the instructions which are executed faster can be sent in advance, the instruction blocking is effectively reduced, and the sending efficiency is improved.
(5) Because the multiple service instructions are processed in parallel in this embodiment, the processed instruction results are returned to the HOST first, and are not returned sequentially in the order of issue, so that the problem that the results do not correspond to the issued instructions is caused. In order to solve the problems, the embodiment of the application adds the tag information to the processing result for indicating the corresponding relation with the issued instruction, thereby avoiding confusion on the corresponding relation.
Additional features and advantages of embodiments of the application will be set forth in the detailed description which follows.
Drawings
The accompanying drawings are included to provide a further understanding of embodiments of the application and are incorporated in and constitute a part of this specification, illustrate embodiments of the application and together with the description serve to explain, without limitation, the embodiments of the application. In the drawings:
FIG. 1 schematically shows a step diagram of a USB-based single-channel multi-service parallel processing method according to an embodiment of the present application;
FIG. 2 schematically illustrates an implementation diagram of a USB-based single-channel multi-service parallel processing method in an embodiment of the application;
fig. 3 schematically shows a schematic structural diagram of a USB-based single-channel multi-service parallel processing apparatus according to an embodiment of the present application.
Detailed Description
The following describes the detailed implementation of the embodiments of the present application with reference to the drawings. It should be understood that the detailed description and specific examples, while indicating and illustrating the application, are not intended to limit the application.
Fig. 1 schematically shows a step diagram of a USB-based single-channel multi-service parallel processing method according to an embodiment of the present application. As shown in fig. 1, a single-channel multi-service parallel processing method based on USB includes:
s01, triggering a corresponding first thread to receive an expansion instruction after receiving a Setup data packet for triggering interrupt processing;
s02, when the received expansion instruction is determined to be a service instruction, processing data in the expansion instruction by a service processing thread to obtain result data;
s03, storing the result data to a designated position by adopting a second thread, and identifying the corresponding relation between the result data and an expansion instruction;
and S04, sending the result data by adopting a third thread as a response to the corresponding expansion instruction.
By the above embodiment, an extended instruction is added to the CBWCB field to implement triggering of the first thread. The first thread processes the extended instruction and performs a corresponding operation according to the specific content of the extended instruction. And meanwhile, the second thread and the third thread are adopted to respectively process the data after the operation is executed and transmit the data, so that the separation of data processing and data transmission is realized. The advantages of this are: the processing procedures of the second thread and the third thread are not affected by the instruction receiving sequence, and the instruction with faster execution can be sent in advance. The correspondence relationship in the present embodiment can be such that the data sequence at the time of transmission is associated with the processing result of the second thread when the processing result is out of order. Therefore, the problem that when the multitasking operating system can process instructions in parallel, the processing efficiency of the whole chip cannot be improved due to communication blockage is solved.
Both CBW and CBWCB mentioned in this embodiment can refer to existing USB transmission technology. The CBW (Command Block Wrapper, command block packet) is a command packet sent from the USB host to the device, and is composed of 31 bytes. CBWCB is a specific command transmitted, conforming to the command specification defined in bdterface class, here SCSI. The communication environment in the present embodiment is preferably: the communication protocol adopts USB2.0, BULK transmission mode and SCSI transmission protocol.
In some alternative embodiments, the expansion instructions are obtained by: expanding the SCSI protocol instruction, and respectively determining an expansion instruction of an input direction and an output direction according to the data transmission direction; the extended instruction of the output direction is divided into a service inquiry instruction and a service instruction according to the content of the CBWCB field contained in the extended instruction. Illustratively, the multitasking COS service instruction extends the SCSI protocol instruction by expanding the CBWCB field instructions to 0xFD and 0xFE. Table 1 illustrates CBWCB fields.
Table 1-CBWCB field description
Table 2 illustrates the contents of the PACKET immediately downstream of the CBW command PACKET. The actual instruction pair sequence corresponding to HOST end is: (0 xFD,0 xFE) wherein the contents of the CBWCB field and the PACKET package are provided by the end user and the HOST middleware invokes the driver interface and is implemented in connection with the extended instruction PACKET delivery.
TABLE 2 PACKET Specification
The above 0xFD and 0xFE are merely names or examples of the extended instruction in the present embodiment, and do not represent limitations on the extended instruction. Based on the disclosure or the teaching of the present application, embodiments that employ expansion instructions to achieve corresponding effects all fall within the scope of the present application.
In some optional embodiments, the sending end of the expansion instruction triggers the service processing of the receiving end by issuing the service instruction, and then obtains the response to the expansion instruction by issuing the service inquiry instruction. Specifically, the steps from HOST issuing the service instruction to retrieving the response result are divided into two steps, wherein the first step issues the service instruction, the Device replies whether the instruction is received or not, the second step HOST resends the instruction of the query result, and the Device replies that the result data is processed.
In some alternative embodiments, the method further comprises: determining the content in the Setup data packet according to the expansion instruction; before a transmitting end of an expansion instruction transmits the expansion instruction, a Setup data packet corresponding to the expansion instruction is transmitted. Illustratively, all USB devices respond to requests by the host on the device's default control pipe using control transfers, which fall into three categories: null data requests (all information contained in the command), write requests (additional data after the command), and read requests (requiring the device to send data to the host). The request and corresponding parameters are sent to the device in a Setup packet. The host is responsible for establishing the values passed in the fields listed in the table below. Each Setup packet has 8 bytes as shown in the table below. The HOST master Device may be a PC HOST, and the slave Device may be a security chip where the multi-task COS end is located.
TABLE 3 Setup packet description
In order to effectively implement the multi-task switching of the Device end, the HOST end needs to additionally perform the following processing: before each FD and FE instruction packet is sent out, the corresponding Vendor custom Setup command packet is reissued, the custom packet can trigger the Device end USBi interrupt processing, and the Device controls the Device end thread running logic according to different custom packet commands. For example, FD instruction custom package command content is: 0x41040000 00FD0000; the FE instruction custom package command content is: 0x41040000 00FE0000; after receiving the HOST control end ep0 command, the Device USBi triggers an interrupt, receives a corresponding control command (including a Vendor custom command), and enters corresponding processing logic. For specific details of Setup not mentioned in the above embodiments reference is made to the USB specification in the prior art.
In some alternative embodiments, after the corresponding first thread receives the extended instruction, the method further comprises: and feeding back a receiving result. In the following example, H2D represents HOST to Device, D2H represents Device to HOST, and dCBWTag bytes in D2H are not shown in the example.
[ H2D ]: 00E 508000004// read 00 traffic FLASH.
[ D2H ]:00B 000// B000: the 00 service instruction is normally received.
The return status word is: (B000) the instruction has been received normally; (B001) The user receives buf fully, cannot receive the buf, and discards the data; (B004) the user data packet is very long, the data is invalid, etc.
[ H2D ]:00 51 CC// query traffic returns data.
[ D2H ]:00 9000 0004AAbbCCdd// service data.
Or (b)
[ D2H ]:00B 003// data processing is not completed and needs to wait.
When HOST down-links data to a Device, the data length is given in the CBW packet, and the Device receives data according to the length. When the Device returns data to HOST, HOST is received in maximum length (64 KB), and the Device ends with a null packet indicating the end of the data. By the implementation mode, feedback can be performed when the first thread receives the expansion instruction and is abnormal, and robustness and user friendliness of the system are improved.
In some alternative embodiments, the second thread and the third thread are parallel threads. The foregoing embodiment divides the process of sending up the USB data into two threads, namely, the second thread and the third thread, to be completed, thereby respectively implementing service arrangement and data sending. The multi-task operating system calls and processes, the service tidying thread is responsible for putting the result data into the sending buffer and adding the tag information, and the data sending thread is only responsible for sending the result to the upper computer. The processing of a plurality of services received from the same USB channel is processed in parallel in a thread mode in a multi-task system, and for time-consuming services (such as algorithm, flash write operation and the like), the simultaneous operation of the processing of the plurality of services can be realized, so that the processing efficiency of the services is improved.
In some alternative embodiments, the method further comprises: and triggering a third thread to send result data as a response to the corresponding expansion instruction when the received expansion instruction is determined to be the service query instruction. As described above, the extended instruction service query instruction in the output direction is exemplified as a 51CC instruction, and when the Device receives the 51CC instruction, the processing result is returned.
In some alternative embodiments, the service processing threads are multiple and are respectively used for processing data of different service numbers. In a multitasking operating system, different business processing threads are used to process different data, which are distinguished by business numbers. The beneficial effects of this embodiment lie in: the receiving and transmitting process of the application layer and the processing process of the service instruction can be performed simultaneously, so that the working efficiency of the whole system is improved.
In some alternative embodiments, the method further includes a fourth thread, where the fourth thread is configured to distribute the data to different service processing threads according to the service numbers in the data. The fourth thread may also be referred to as a traffic distribution thread. For example, taking two service needs to be processed as an example, in this embodiment, the Device end designs six threads of a receiving thread (same as the first thread Cheng Zuoyong described above), a service distributing thread (same as the fourth thread Cheng Zuoyong described above), a service 1 thread, a service 2 thread, and a service organizing thread (same as the second thread described above) and a sending thread (same as the third thread Cheng Zuoyong described above) to process the data issued by the HOST, where the FD thread has the highest execution authority, and the FE thread is the next time, and mainly includes the following steps:
and step 1, the receiving thread is responsible for processing the data issued from HOST, if the data is a 51CC instruction, the processing result is returned, otherwise, the data issued from HOST is stored in a user buf, and the processing is waited for.
And step 2, the service distribution thread distributes the data to different service processing threads according to the service numbers in the issued data.
And 3, processing service data with service number 1 by a service 1 thread, and putting the processed data into a user ram to wait for the FE thread to send to HOST.
And 4, processing service data with service number 2 by a service 2 thread, and putting the processed data into a user ram to wait for the FE thread to send to HOST. The order of step 3 and step 4 is changeable.
And step 5, the business arrangement thread is a gathering thread and is responsible for moving the processed data from the USER RAM to the USB RAM, and adding label information corresponding to the issuing instruction into the result data, so that the HOST end can obtain the corresponding relation between the downstream APDU instruction and the Device return data.
And step 6, the sending thread is responsible for sending the processing result of the Device service to HOST.
Through the division cooperation of the threads, the parallel data processing of the Device end is realized, and the single-channel data processing efficiency based on USB is improved. The above multiple threads are preferably executed in parallel, depending on user settings or system configuration.
In some alternative embodiments, the threads cooperate via semaphores and/or data state information. Semaphore (Semaphore), a facility used in a multi-threaded environment, can be used to ensure two or more critical code segments are not invoked concurrently. The scheme of collaboration based on data state information is also designed in the embodiment while the mechanism is adopted.
In some alternative embodiments, the data state information is defined as one of the states in the following set of states: the state can be used, the upper computer downlink data is filled into the user random access memory, the fourth thread acquires data through the service processing thread but not yet, the downlink data is acquired by the service processing thread, and the upper computer downlink data is abnormal. As an example, the data state information may be implemented in the device in the following manner. After receiving HOST downlink data, the Device end makes the following design for data status bytes in order to facilitate multithread data processing and uplink of the processed data:
00-00-00-00: idle availability; 00-00-00-10: filling downlink data of an upper computer into a user ram;00-00-00-11: the upper computer downlink data is sent out by the distribution thread to inform the service thread of the state that the user ram is taken but not taken yet; 00-00-00-12: the state that the downlink data of the upper computer is acquired by a service thread from a user ram; 00-00-00-FF: the downlink data of the upper computer is abnormal. The number of the byte bits and the specific number allocation can be correspondingly adjusted according to the actual scene.
In some optional embodiments, identifying the correspondence of the result data to the extended instruction includes: and adding a data tag to the result data to identify the corresponding relation between the result data and the expansion instruction. In this embodiment, a data tag related to the result data is used to represent the correspondence. Because the multiple service instructions are processed in parallel in this embodiment, the processed instruction results are returned to the HOST first, and are not returned sequentially in the order of issue, so that the problem that the results do not correspond to the issued instructions is caused. In order to solve the problems, the method adds tag information in the processing result for indicating the corresponding relation with the issued instruction, thereby avoiding confusion on the corresponding relation.
In some alternative embodiments, the data tag identifies a field for a command block in a CBW packet of the extended instruction. For example, when designing a 4-byte tag as an upstream downstream APDU (Application Protocol Data Unit, which is an information unit transmitted between a smart card and a smart card reader), the intention of adding the 4-byte tag in the dCBWTag field in the CBW packet of the USB is: the HOST can obtain the corresponding relation between the downlink APDU command and the Device return data.
According to the single-channel multi-service parallel processing method based on the USB in the embodiment, through various mechanisms such as an extended instruction design and a multi-task architecture design, single-channel multi-service parallel processing based on the USB is realized, and the processing efficiency is remarkably improved.
Fig. 2 schematically shows an implementation diagram of a USB-based single-channel multi-service parallel processing method according to an embodiment of the present application. As shown in fig. 2, this embodiment includes the steps of:
the upper computer issues a service instruction to generate USB interrupt; and after receiving the USB interrupt, the lower computer releases the signal quantity of the USB receiving and transmitting processing thread and triggers the receiving and transmitting thread. The lower computer determines whether the buffer USB RAM receiving the data has an idle position? And under the condition of the idle position, the lower computer stores the instruction into the USB RAM and returns successful receiving.
The following operations are performed in parallel in the multitasking operating system: the receiving thread moves the service instruction in the USB RAM to different lists in the USER RAM according to the service number; the service distribution thread distributes different services to different service processing threads; processing the instruction of each service list by the service 1 and service 2 processing threads according to the priority, and storing the response result into the USER RAM; the business arrangement thread moves the processed data from the USER RAM to the USB RAM, and puts the timestamp information in the received data into a processing result to wait for transmission; the sending thread is responsible for sending the processing result to the upper computer.
The upper computer sends a query command; and the application sending thread sends the data in the USB RAM to the upper computer.
The above embodiment provides the whole process from the sending of the service instruction to the receiving of the return data by the upper computer, and can be seen that the processing efficiency of USB data is obviously improved.
Based on the same inventive concept, the embodiment of the application also provides a single-channel multi-service parallel processing device based on USB. Fig. 3 schematically shows a schematic structural diagram of a USB-based single-channel multi-service parallel processing apparatus according to an embodiment of the present application. As shown in fig. 3, the apparatus includes: the data receiving module is used for triggering the corresponding first thread to receive the expansion instruction after receiving the Setup data packet for triggering the interrupt processing; the business processing module is used for processing the data in the expansion instruction by the business processing thread to obtain result data when the received expansion instruction is determined to be the business instruction; the corresponding identification module is used for storing the result data to a designated position by adopting a second thread and identifying the corresponding relation between the result data and an expansion instruction; and the data sending module is used for sending the result data as a response to the corresponding expansion instruction by adopting the third thread.
In some alternative embodiments, the expansion instructions are obtained by: expanding the SCSI protocol instruction, and respectively determining an expansion instruction of an input direction and an output direction according to the data transmission direction; the extended instruction of the output direction is divided into a service inquiry instruction and a service instruction according to the content of the CBWCB field contained in the extended instruction.
In some optional embodiments, the sending end of the expansion instruction triggers the service processing of the receiving end by issuing the service instruction, and then obtains the response to the expansion instruction by issuing the service inquiry instruction.
In some alternative embodiments, the apparatus further comprises: determining the content in the Setup data packet according to the expansion instruction; before a transmitting end of an expansion instruction transmits the expansion instruction, a Setup data packet corresponding to the expansion instruction is transmitted.
In some alternative embodiments, after the corresponding first thread receives the extended instruction, the method further comprises: and feeding back a receiving result.
In some alternative embodiments, the second thread and the third thread are parallel threads.
In some alternative embodiments, the apparatus further comprises: and triggering a third thread to send result data as a response to the corresponding expansion instruction when the received expansion instruction is determined to be the service query instruction.
In some alternative embodiments, the service processing threads are multiple and are respectively used for processing data of different service numbers.
In some alternative embodiments, the device further includes a fourth thread, where the fourth thread is configured to distribute the data to different service processing threads according to the service numbers in the data.
In some alternative embodiments, the threads cooperate via semaphores and/or data state information.
In some alternative embodiments, the data state information is defined as one of the states in the following set of states: the state can be used, the upper computer downlink data is filled into the user random access memory, the fourth thread acquires data through the service processing thread but not yet, the downlink data is acquired by the service processing thread, and the upper computer downlink data is abnormal.
In some optional embodiments, identifying the correspondence of the result data to the extended instruction includes: and adding a data tag to the result data to identify the corresponding relation between the result data and the expansion instruction.
In some alternative embodiments, the data tag identifies a field for a command block in a CBW packet of the extended instruction.
The specific limitation of each functional module in the USB-based single-channel multi-service parallel processing device may be referred to the limitation of the USB-based single-channel multi-service parallel processing method, which is not described herein. Each of the modules in the above-described apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In some embodiments of the present application, there is also provided an electronic device including: at least one processor; a memory coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor by performing the steps of the USB-based single channel multi-service parallel processing method described above. The control module or processor herein has the functions of numerical computation and logical operation, and has at least a central processing unit CPU, a random access memory RAM, a read only memory ROM, various I/O ports, an interrupt system, and the like, which have data processing capabilities. The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel may be provided with one or more of the methods described above by adjusting the kernel parameters. The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
In one embodiment of the present application, a machine-readable storage medium is provided having instructions stored thereon that, when executed by a processor, cause the processor to be configured to perform the steps of the aforementioned USB-based single-channel multi-service parallel processing method.
In one embodiment of the present application, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the aforementioned USB-based single channel multi-service parallel processing method.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and variations of the present application will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the application are to be included in the scope of the claims of the present application.

Claims (20)

1. A single-channel multi-service parallel processing method based on USB is characterized by comprising the following steps:
after receiving a Setup data packet for triggering interrupt processing, triggering a corresponding first thread to receive an expansion instruction;
when the received expansion instruction is determined to be a service instruction, processing data in the expansion instruction by a service processing thread to obtain result data;
storing the result data to a designated position by adopting a second thread, and identifying the corresponding relation between the result data and an expansion instruction;
and adopting a third thread to send the result data as a response to the corresponding expansion instruction.
2. The method of claim 1, wherein the expansion instruction is obtained by:
expanding the SCSI protocol instruction, and respectively determining an expansion instruction of an input direction and an output direction according to the data transmission direction;
the extended instruction of the output direction is divided into a service inquiry instruction and a service instruction according to the content of the CBWCB field contained in the extended instruction.
3. The method of claim 2, wherein the sending end of the expansion instruction triggers the service processing of the receiving end by issuing the service instruction, and the response to the expansion instruction is obtained by issuing the service inquiry instruction.
4. The method according to claim 1, wherein the method further comprises:
determining the content in the Setup data packet according to the expansion instruction;
before a transmitting end of an expansion instruction transmits the expansion instruction, a Setup data packet corresponding to the expansion instruction is transmitted.
5. The method of claim 1, wherein after the corresponding first thread receives the extended instruction, the method further comprises: and feeding back a receiving result.
6. The method of claim 1, wherein the second thread and the third thread are parallel threads.
7. The method of claim 6, wherein the method further comprises:
and triggering a third thread to send result data as a response to the corresponding expansion instruction when the received expansion instruction is determined to be the service query instruction.
8. The method of claim 1, wherein the service processing threads are plural and are each configured to process data of a different service number.
9. The method of claim 8, further comprising a fourth thread for distributing data to different traffic processing threads based on the traffic number in the data.
10. The method of claim 9, wherein the threads cooperate via semaphores and/or data state information.
11. The method of claim 10, wherein the data state information is defined as one of the following states in the set of states: the state can be used, the upper computer downlink data is filled into the user random access memory, the fourth thread acquires data through the service processing thread but not yet, the downlink data is acquired by the service processing thread, and the upper computer downlink data is abnormal.
12. The method of claim 1, wherein identifying the correspondence of the result data to an extended instruction comprises:
and adding a data tag to the result data to identify the corresponding relation between the result data and the expansion instruction.
13. The method of claim 12, wherein the data tag identifies a field for a command block in a CBW packet of the extended instruction.
14. A single-channel multi-service parallel processing device based on USB, the device comprising:
the data receiving module is used for triggering the corresponding first thread to receive the expansion instruction after receiving the Setup data packet for triggering the interrupt processing;
the business processing module is used for processing the data in the expansion instruction by the business processing thread to obtain result data when the received expansion instruction is determined to be the business instruction;
the corresponding identification module is used for storing the result data to a designated position by adopting a second thread and identifying the corresponding relation between the result data and an expansion instruction; and
and the data sending module is used for sending the result data as a response to the corresponding expansion instruction by adopting the third thread.
15. The apparatus of claim 14, wherein the expansion instruction is derived by:
expanding the SCSI protocol instruction, and respectively determining an expansion instruction of an input direction and an output direction according to the data transmission direction;
the extended instruction of the output direction is divided into a service inquiry instruction and a service instruction according to the content of the CBWCB field contained in the extended instruction.
16. The apparatus of claim 15, wherein the sender of the expansion instruction triggers a service process at the receiver by issuing the service instruction, and the response to the expansion instruction is obtained by issuing the service inquiry instruction.
17. The apparatus of claim 14, wherein the second thread and the third thread are parallel threads.
18. The apparatus of claim 14 further comprising a fourth thread for distributing data to different traffic processing threads based on traffic numbers in the data.
19. An electronic device, comprising: at least one processor;
a memory coupled to the at least one processor;
wherein the memory stores instructions executable by the at least one processor, the at least one processor implementing the steps of the USB-based single channel multi-service parallel processing method of any one of claims 1 to 13 by executing the instructions stored by the memory.
20. A machine-readable storage medium having instructions stored thereon that when executed by a processor cause the processor to be configured to implement the USB-based single-channel multi-service parallel processing method of any one of claims 1 to 13.
CN202310779533.3A 2023-06-28 2023-06-28 USB-based single-channel multi-service parallel processing method and device Pending CN117041373A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310779533.3A CN117041373A (en) 2023-06-28 2023-06-28 USB-based single-channel multi-service parallel processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310779533.3A CN117041373A (en) 2023-06-28 2023-06-28 USB-based single-channel multi-service parallel processing method and device

Publications (1)

Publication Number Publication Date
CN117041373A true CN117041373A (en) 2023-11-10

Family

ID=88637945

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310779533.3A Pending CN117041373A (en) 2023-06-28 2023-06-28 USB-based single-channel multi-service parallel processing method and device

Country Status (1)

Country Link
CN (1) CN117041373A (en)

Similar Documents

Publication Publication Date Title
KR100268565B1 (en) System and method for queuing of tasks in a multiprocessing system
US5265261A (en) Method and system for network communications using raw mode protocols
US4937737A (en) Process transparent multi storage mode data transfer and buffer control
US20040083481A1 (en) System and method for transferring data between virtual machines or other computer entities
CN112347015B (en) Communication device and method between heterogeneous multiprocessors of system on chip
US7640549B2 (en) System and method for efficiently exchanging data among processes
CN115185880B (en) Data storage method and device
CN108829529A (en) Virutal machine memory sharing method, device, computer equipment and storage medium
US10929332B2 (en) USB transmission device and transmission method
KR20150056373A (en) Multi-thread processing apparatus and method with sequential performance manner
US8775709B2 (en) Method for recognizing a card reader with multiple card holders and method for communicating between a host and the card reader and system thereof
US6901459B2 (en) Protocol for transmitting a plurality of multiple exchange logic flow of command/response pairs on a single physical exchange channel between master and slave and corresponding system for controlling and monitoring execution of applets
CN117041373A (en) USB-based single-channel multi-service parallel processing method and device
CN115361345B (en) Data flow control method and device based on single bus information transmission and communication system
CN113826081A (en) Method for transmitting message in computing system and computing system
CN112291336A (en) Multichannel parallel data loading method of ARINC429 network card
CN113760559A (en) Dual-core communication method and electronic equipment
US6128689A (en) System for exchanging data through data memory area of common memory in synchronous and asynchronous modes
CN114911632B (en) Method and system for controlling interprocess communication
US10270715B2 (en) High performance network I/O in a virtualized environment
CN108140005B (en) System and method for providing file information in a memory system protocol
CN113767368A (en) Resource acquisition method, related device and computer storage medium
CN112311695B (en) On-chip bandwidth dynamic allocation method and system
Franke et al. MPI on IBM SP1/SP2: Current status and future directions
KR20150048028A (en) Managing Data Transfer

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination