CN106844036B - Physical equipment access method and device - Google Patents

Physical equipment access method and device Download PDF

Info

Publication number
CN106844036B
CN106844036B CN201710072859.7A CN201710072859A CN106844036B CN 106844036 B CN106844036 B CN 106844036B CN 201710072859 A CN201710072859 A CN 201710072859A CN 106844036 B CN106844036 B CN 106844036B
Authority
CN
China
Prior art keywords
distribution service
request
service request
equipment
physical
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.)
Active
Application number
CN201710072859.7A
Other languages
Chinese (zh)
Other versions
CN106844036A (en
Inventor
袁鹏
乔立君
刘德启
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Neusoft Corp
Original Assignee
Neusoft Corp
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 Neusoft Corp filed Critical Neusoft Corp
Priority to CN201710072859.7A priority Critical patent/CN106844036B/en
Publication of CN106844036A publication Critical patent/CN106844036A/en
Application granted granted Critical
Publication of CN106844036B publication Critical patent/CN106844036B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system

Abstract

The invention discloses an access method and a device of physical equipment, which relate to the technical field of computers and mainly aim to improve the access portability of application program physical equipment, and the main technical scheme of the invention is as follows: receiving a distribution service request sent by an application program, wherein the distribution service request comprises requested logic equipment; inquiring physical equipment corresponding to the logic equipment through a preset equipment mapping table, wherein the preset equipment mapping table stores the corresponding relation between the logic equipment and the physical equipment; and converting the distribution service request into actual logic equipment operation according to the running state of the physical equipment. The invention is mainly used for concurrent access of physical equipment.

Description

Physical equipment access method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for accessing a physical device.
Background
The physical device refers to a device which cannot be accessed by a plurality of threads or processes at the same time, a plurality of functions can be integrated in the physical device, each function is mapped to a logic device, and the section of code accessing the logic device in each process is called a critical section. When a thread enters a critical area, the thread lock is used for realizing the mutually exclusive access of the thread to the critical area, namely the thread lock is used for ensuring that the logic device corresponding to the critical area is used by the mutually exclusive access.
At present, when an application program is written, a process lock needs to be set according to a corresponding relationship between a physical device and a logic device, and if a thread requests access to the logic device, the process needs to set the process lock according to the corresponding relationship between the logic device and the physical device. However, when the correspondence between the physical device and the logical device is changed, the thread lock in the application program needs to be modified to adapt to the new physical device, so that the access portability of the existing application program physical device is poor.
Disclosure of Invention
In view of this, the present invention provides a method and an apparatus for accessing a physical device, and mainly aims to improve the access portability of an application physical device.
According to an aspect of the present invention, there is provided an access method of a physical device, including:
receiving a distribution service request sent by an application program, wherein the distribution service request comprises requested logic equipment;
inquiring physical equipment corresponding to the logic equipment through a preset equipment mapping table, wherein the preset equipment mapping table stores the corresponding relation between the logic equipment and the physical equipment;
and converting the distribution service request into actual logic equipment operation according to the running state of the physical equipment.
According to another aspect of the present invention, there is provided an access apparatus for a physical device, including:
the system comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for receiving a distribution service request sent by an application program, and the distribution service request comprises requested logic equipment;
the query unit is used for querying the physical equipment corresponding to the logic equipment through a preset equipment mapping table, and the preset equipment mapping table stores the corresponding relation between the logic equipment and the physical equipment;
and the conversion unit is used for converting the distribution service request into actual logic equipment operation according to the running state of the physical equipment.
Compared with the prior art that the process lock is required to be set according to the corresponding relation between the physical equipment and the logic equipment when the application program is written, the method and the device manage the distribution service request through the added equipment management layer, namely the method and the device convert the distribution service request into the actual logic equipment operation through presetting the corresponding relation between the physical equipment corresponding to the logic equipment in the equipment mapping table, so that the application program realized through the method and the device do not need to set the process lock according to the corresponding relation between the physical equipment and the logic equipment, and the portability of the access of the physical equipment of the application program is improved through the method and the device.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a flowchart illustrating an access method for a physical device according to an embodiment of the present invention;
FIG. 2 is a flow chart of another method for accessing a physical device according to an embodiment of the present invention;
fig. 3 is a block diagram illustrating an accessing apparatus of a physical device according to an embodiment of the present invention;
fig. 4 is a block diagram illustrating an access apparatus of another physical device according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In order to make the advantages of the technical solutions of the present invention clearer, the present invention is described in detail below with reference to the accompanying drawings and examples.
An embodiment of the present invention provides an access method for a physical device, as shown in fig. 1, the method includes:
101. and receiving a distribution service request sent by an application program.
Wherein, the distribution service request includes the requested logic device, i.e. the logic function requested by the application program. It should be noted that each logic device correspondingly implements a function, the application program may send one or more distribution service requests through the multithreading mechanism, each distribution service request requests execution of a logic device, and the application program implements a function corresponding to the logic device by executing the logic device in the request.
In the embodiment of the present invention, a distribution service request sent by an application program is received through an operation interface, that is, when the application program requests to access a logic device, the distribution service request corresponding to the application program is sent to the operation interface, and then the embodiment of the present invention obtains the distribution service request sent by the application program from the operation interface.
102. And querying the physical equipment corresponding to the logic equipment through a preset equipment mapping table.
And the preset device mapping table stores the corresponding relation between the logic device and the physical device. In the embodiment of the invention, the preset device mapping table is set according to the actual configuration condition of the terminal device, the terminal device comprises one or more physical devices, each physical device can integrate multiple functions, and a single function is mapped into a logic device.
It should be noted that the physical device in the embodiment of the present invention is a critical resource, that is, a device that cannot be accessed by multiple threads at the same time. When a thread accesses a physical device, other threads or processes must wait to ensure that the physical device is mutually exclusive. Physical devices such as input machines, printers, tape drives, card readers, etc. can only be accessed by a single thread.
103. And converting the distribution service request into actual logic equipment operation according to the running state of the physical equipment.
In the embodiment of the invention, after the physical device corresponding to the request logical device is inquired through the preset device mapping table, the distribution service request is converted into the actual logical device operation according to the running state of the physical device. If the physical equipment is in an idle state, executing a calling function in the distribution service request to call the logic equipment; if the physical device is in the occupied state, the thread corresponding to the distribution service request needs to wait until the physical device is converted into the idle state, and the calling function in the distribution service request can be executed to access the logic device.
Compared with the prior art that a process lock is required to be set according to the corresponding relationship between physical equipment and logical equipment when an application program is written, the method manages the distribution service request through the added equipment management layer, namely the method converts the distribution service request into actual logical equipment operation by presetting the corresponding relationship between the physical equipment corresponding to the logical equipment in the equipment mapping table, so that the application program realized by the method does not need to set the process lock according to the corresponding relationship between the physical equipment and the logical equipment, and the portability of the access of the physical equipment of the application program is improved by the method.
An embodiment of the present invention provides another access method for a physical device, as shown in fig. 2, the method includes:
201. and receiving a distribution service request sent by an application program.
For detailed description of the step 201 of receiving the distribution service request sent by the application program, reference may be made to the description of the corresponding step in fig. 1, and details of the logic device including the request in the distribution service request are not described herein again in this embodiment of the present invention.
202. And querying the physical equipment corresponding to the logic equipment through a preset equipment mapping table.
The preset device mapping table stores the corresponding relation between the logic device and the physical device, the preset device mapping table is set according to the actual configuration condition of the terminal device, the terminal device comprises one or more physical devices, each physical device can integrate multiple functions, and a single function is mapped into one logic device. In the embodiment of the present invention, if the physical device corresponding to the logical device is not queried from the preset device mapping table, the application returns to the application that the requested logical device does not have a prompt message, so as to prompt the user that the current terminal device cannot support the requested logical function.
For the embodiment of the present invention, after querying a physical device corresponding to a logical device according to a preset device mapping table, a request number corresponding to a service distribution request needs to be generated, the service distribution request is uniquely identified by the request number, the request number is sent to a request stack corresponding to the physical device, and a processing sequence of the service distribution request corresponding to each request number in the request stack is arranged according to a processing sequence of preset numbers. Wherein each physical device corresponds to a request stack. The request stack is used for receiving the distribution service request and waiting for the physical equipment service to fetch a storage container of the distribution service request.
Specifically, the arranging the processing sequence of the distribution service request corresponding to each request number in the request stack according to the processing sequence of the preset numbers includes: and arranging and processing the sequence of the distribution service requests according to the stacking time, the calling priority or the waiting duration of the distribution service requests corresponding to the request numbers in the request stack. The stacking time of the service distribution request is to process the service distribution request corresponding to each request number according to the first-in first-out mode of the request stack, and the calling priority is a calling priority level set according to the actual running condition of the application program.
203. And if the physical equipment is in an idle state, acquiring a calling mode of the distribution service request corresponding to the request number, and setting the physical equipment to be in an occupied state.
In the embodiment of the present invention, after querying the physical device corresponding to the logical device, the operating state of the physical device needs to be acquired, and if the physical device is in an idle state, the request number to be processed needs to be taken out from the request stack according to the order, then the invocation mode of the distribution service request corresponding to the request number is acquired, the physical device is set to an occupied state, and then the distribution service request is converted into an actual logical device operation according to the invocation mode of the distribution service request.
204a, if the service distribution request is synchronous call, suspending the thread corresponding to the request number, and accessing the logic device through a call function in the service distribution request.
It should be noted that the synchronous call is a blocking call in the application program, and the caller needs to return after the execution of the other party is completed, and the synchronous call is a one-way call, and is characterized in that the current thread is suspended after the call is started and starts to wait for the return, and the synchronous call is often used in the call process with shorter execution time. Therefore, when the service delivery request is a synchronous call, the thread corresponding to the request number needs to be suspended, and after the call returns a result, the thread corresponding to the request number needs to be woken up.
204b, if the distribution service request is asynchronous call, accessing the logic device through a call function in the distribution service request.
It should be noted that the asynchronous call is a method that can continue the operation without waiting for the return value of the called function, and this calling method is suitable for a long time operation or a case where the application itself cannot be suspended waiting. Therefore, when the distribution service request is an asynchronous call, the normal call is returned, and the logic device is called through the calling function in the distribution service request.
For the embodiment of the present invention, after the logic device is called by the call function in the distribution service request in step 204a or step 204b, data returned by the logic device needs to be received, where the returned data includes the request number, and if the distribution service request corresponding to the request number is a synchronous call, a thread corresponding to the request number is awakened according to the returned request number; and if the distribution service request corresponding to the request number is asynchronously called, sending the execution result of the logic device to the application program according to the callback function corresponding to the returned request number.
The embodiment of the invention provides another physical device access method, after a logical device requested by an application program is received, a preset device mapping table is used for inquiring the physical device corresponding to the logical device, if the physical device is in an idle state, a calling mode of a distribution service request is obtained, the physical device is set to be in an occupied state, and then the distribution service request is converted into actual logical device operation according to the calling mode of the distribution service request, so that the physical device access is realized. The application program in the invention does not need to set the process lock according to the corresponding relation between the physical equipment and the logic equipment, so the access portability of the physical equipment of the application program is improved by the invention.
Further, an embodiment of the present invention provides an access apparatus for a physical device, and as shown in fig. 3, the apparatus includes: a receiving unit 31, a querying unit 32, and a converting unit 33.
A receiving unit 31, configured to receive a distribution service request sent by an application program, where the distribution service request includes a requested logic device;
it should be noted that each logic device correspondingly implements a function, the application program may send one or more distribution service requests through the multithreading mechanism, each distribution service request requests execution of a logic device, and the application program implements a function corresponding to the logic device by executing the logic device in the request.
In the embodiment of the present invention, a distribution service request sent by an application program is received through an operation interface, that is, when the application program requests to access a logic device, the distribution service request corresponding to the application program is sent to the operation interface, and then the embodiment of the present invention obtains the distribution service request sent by the application program from the operation interface.
The query unit 32 is configured to query the physical device corresponding to the logical device through a preset device mapping table, where the preset device mapping table stores a correspondence between the logical device and the physical device;
in the embodiment of the invention, the preset device mapping table is set according to the actual configuration condition of the terminal device, the terminal device comprises one or more physical devices, each physical device can integrate multiple functions, and a single function is mapped into a logic device.
It should be noted that the physical device in the embodiment of the present invention is a critical resource, that is, a device that cannot be accessed by multiple threads at the same time. When a thread accesses a physical device, other threads or processes must wait to ensure that the physical device is mutually exclusive. Physical devices such as input machines, printers, tape drives, card readers, etc. can only be accessed by a single thread.
A conversion unit 33, configured to convert the distribution service request into an actual logical device operation according to the running state of the physical device.
In the embodiment of the invention, after the physical device corresponding to the request logical device is inquired through the preset device mapping table, the distribution service request is converted into the actual logical device operation according to the running state of the physical device. If the physical equipment is in an idle state, executing a calling function in the distribution service request to call the logic equipment; if the physical device is in the occupied state, the thread corresponding to the distribution service request needs to wait until the physical device is converted into the idle state, and the calling function in the distribution service request can be executed to access the logic device.
It should be noted that, for other corresponding descriptions of functional units related to an access apparatus of a physical device provided in the embodiment of the present invention, reference may be made to corresponding descriptions of the method shown in fig. 1, which are not described herein again, but it should be clear that the apparatus in the embodiment can correspondingly implement all contents in the foregoing method embodiments.
Compared with the prior art that a process lock is required to be set according to the corresponding relation between physical equipment and logical equipment when an application program is written, the access device of the physical equipment manages the distribution service request through the added equipment management layer, namely, the distribution service request is converted into actual logical equipment operation through presetting the corresponding relation between the physical equipment corresponding to the logical equipment in the equipment mapping table, so that the application program realized through the access device of the physical equipment of the application program does not need to set the process lock according to the corresponding relation between the physical equipment and the logical equipment, and the access portability of the physical equipment of the application program is improved through the access device of the application program.
Further, an embodiment of the present invention provides another access apparatus for a physical device, as shown in fig. 4, the apparatus includes: a receiving unit 41, a querying unit 42, and a converting unit 43.
A receiving unit 41, configured to receive a distribution service request sent by an application program, where the distribution service request includes a requested logic device;
a querying unit 42, configured to query a physical device corresponding to the logical device through a preset device mapping table, where a corresponding relationship between the logical device and the physical device is stored in the preset device mapping table;
a conversion unit 43, configured to convert the distribution service request into an actual logical device operation according to the running state of the physical device.
For the embodiment of the present invention, after querying the physical device corresponding to the logical device from the preset device mapping table according to the querying unit 42, further, the apparatus further includes:
a generating unit 44, configured to generate a request number corresponding to the distribution service request, where the request number is used to uniquely identify the distribution service request;
a sending unit 45, configured to send the request number to a request stack corresponding to the physical device; wherein each physical device corresponds to a request stack. The request stack is used for receiving the distribution service request and waiting for the physical equipment service to fetch a storage container of the distribution service request.
And the sorting unit 46 is configured to sort the processing sequence of the distribution service request corresponding to each request number in the request stack according to a preset number processing sequence.
Specifically, the conversion unit 43 includes:
an obtaining module 431, configured to obtain, if the physical device is in an idle state, a calling manner of a distribution service request corresponding to the request number, and set the physical device to an occupied state;
in the embodiment of the present invention, after querying the physical device corresponding to the logical device, the operating state of the physical device needs to be acquired, and if the physical device is in an idle state, the request number to be processed needs to be taken out from the request stack according to the order, then the invocation mode of the distribution service request corresponding to the request number is acquired, the physical device is set to an occupied state, and then the distribution service request is converted into an actual logical device operation according to the invocation mode of the distribution service request.
An access module 432, configured to suspend, if the distribution service request is synchronous call, a thread corresponding to the request number, and access the logic device through a call function in the distribution service request;
it should be noted that the synchronous call is a blocking call in the application program, and the caller needs to return after the execution of the other party is completed, and the synchronous call is a one-way call, and is characterized in that the current thread is suspended after the call is started and starts to wait for the return, and the synchronous call is often used in the call process with shorter execution time. Therefore, when the service delivery request is a synchronous call, the thread corresponding to the request number needs to be suspended, and after the call returns a result, the thread corresponding to the request number needs to be woken up.
The accessing module 432 is configured to access the logic device through a calling function in the distribution service request if the distribution service request is an asynchronous call.
It should be noted that the asynchronous call is a method that can continue the operation without waiting for the return value of the called function, and this calling method is suitable for a long time operation or a case where the application itself cannot be suspended waiting. Therefore, when the distribution service request is an asynchronous call, the normal call is returned, and the logic device is called through the calling function in the distribution service request.
In this embodiment of the present invention, after accessing the logic device through the accessing module 432, further, the apparatus further includes:
the receiving unit 41 is further configured to receive data returned by the logic device, where the returned data includes the request number;
a wake-up unit 47, configured to wake up a thread corresponding to the request number according to the returned request number;
the sending unit 45 is further configured to send the execution result of the logic device to the application program according to the callback function corresponding to the returned request number. And returning the data to the application layer according to the request number of the returned data, or awakening the thread corresponding to the suspended number, or assigning the data to the callback function corresponding to the number, thereby completing one calling process.
The sorting unit 46 is specifically configured to sort the order of processing the distribution service requests according to the stacking time, the call priority, or the waiting duration of the distribution service request corresponding to each request number in the request stack. The stacking time of the service distribution request is to process the service distribution request corresponding to each request number according to the first-in first-out mode of the request stack, and the calling priority is a calling priority level set according to the actual running condition of the application program.
It should be noted that, for other corresponding descriptions of functional units related to an access apparatus of another physical device provided in the embodiment of the present invention, reference may be made to corresponding descriptions of the method shown in fig. 2, which are not described herein again, but it should be clear that the apparatus in the embodiment can correspondingly implement all contents in the foregoing method embodiments.
In this embodiment of the present invention, after a physical device corresponding to a requested logical device is queried through a preset device mapping table, a service delivery request is converted into an actual logical device operation according to an operating state of the physical device. If the physical equipment is in an idle state, executing a calling function in the distribution service request to call the logic equipment; if the physical device is in the occupied state, the thread corresponding to the distribution service request needs to wait until the physical device is converted into the idle state, and the calling function in the distribution service request can be executed to access the logic device.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
It will be appreciated that the relevant features of the method and apparatus described above are referred to one another. In addition, "first", "second", and the like in the above embodiments are for distinguishing the embodiments, and do not represent merits of the embodiments.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It will be appreciated by those skilled in the art that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components of the method and apparatus for updating a self-service terminal business process according to embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (10)

1. A method for accessing a physical device, comprising:
receiving a distribution service request sent by an application program, wherein the distribution service request comprises requested logic equipment;
inquiring physical equipment corresponding to the logic equipment through a preset equipment mapping table, wherein the preset equipment mapping table stores the corresponding relation between the logic equipment and the physical equipment;
converting the distribution service request into actual logic device operation according to the running state of the physical device, wherein if the physical device is in an idle state, a calling function in the distribution service request is executed to call the logic device; if the physical device is in the occupied state, the thread corresponding to the distribution service request needs to wait until the physical device is converted into the idle state, and the calling function in the distribution service request can be executed to access the logic device.
2. The method according to claim 1, wherein after querying the physical device corresponding to the logical device according to a preset device mapping table, the method further comprises:
generating a request number corresponding to the distribution service request, wherein the request number is used for uniquely identifying the distribution service request;
sending the request number to a request stack corresponding to the physical device;
and arranging the processing sequence of the distribution service request corresponding to each request number in the request stack according to the processing sequence of the preset numbers.
3. The method of claim 2, wherein translating the dispatch service request into actual logical device operations based on the operational status of the physical device comprises:
if the physical equipment is in an idle state, acquiring a calling mode of a distribution service request corresponding to the request number, and setting the physical equipment to be in an occupied state;
if the distribution service request is synchronous calling, suspending the thread corresponding to the request number, and accessing the logic device through a calling function in the distribution service request;
and if the distribution service request is asynchronous call, accessing the logic equipment through a call function in the distribution service request.
4. The method of claim 3, wherein after the calling the logic device by the calling function in the dispatch service request, the method further comprises:
receiving data returned by the logic equipment, wherein the returned data comprises the request number;
awakening the thread corresponding to the request number according to the returned request number; or
And sending the execution result of the logic device to the application program according to the callback function corresponding to the returned request number.
5. The method according to claim 2, wherein said arranging the processing order of the distribution service requests corresponding to each request number in the request stack according to a preset number processing order comprises:
and arranging and processing the sequence of the distribution service requests according to the stacking time, the calling priority or the waiting duration of the distribution service requests corresponding to the request numbers in the request stack.
6. An access apparatus of a physical device, comprising:
the system comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for receiving a distribution service request sent by an application program, and the distribution service request comprises requested logic equipment;
the query unit is used for querying the physical equipment corresponding to the logic equipment through a preset equipment mapping table, and the preset equipment mapping table stores the corresponding relation between the logic equipment and the physical equipment;
a conversion unit, configured to convert the distribution service request into an actual logic device operation according to the running state of the physical device, where if the physical device is in an idle state, a call function in the distribution service request is executed to call the logic device; if the physical device is in the occupied state, the thread corresponding to the distribution service request needs to wait until the physical device is converted into the idle state, and the calling function in the distribution service request can be executed to access the logic device.
7. The apparatus of claim 6, further comprising:
a generating unit, configured to generate a request number corresponding to the distribution service request, where the request number is used to uniquely identify the distribution service request;
a sending unit, configured to send the request number to a request stack corresponding to the physical device;
and the sequencing unit is used for sequencing the processing sequence of the distribution service request corresponding to each request number in the request stack according to the processing sequence of the preset numbers.
8. The apparatus of claim 7, wherein the conversion unit comprises:
an obtaining module, configured to obtain, if the physical device is in an idle state, a calling manner of a distribution service request corresponding to the request number, and set the physical device to an occupied state;
the access module is used for suspending the thread corresponding to the request number and accessing the logic equipment through a calling function in the distribution service request if the distribution service request is synchronous calling;
and the access module is used for accessing the logic device through a calling function in the distribution service request if the distribution service request is asynchronous calling.
9. The apparatus of claim 8, further comprising:
the receiving unit is further configured to receive data returned by the logic device, where the returned data includes the request number;
the awakening unit is used for awakening the thread corresponding to the request number according to the returned request number;
and the sending unit is further configured to send the execution result of the logic device to the application program according to the callback function corresponding to the returned request number.
10. The apparatus according to claim 7, wherein the sorting unit is specifically configured to arrange the order of processing the distribution service requests according to a stacking time, a call priority, or a waiting duration of the distribution service request corresponding to each request number in a request stack.
CN201710072859.7A 2017-02-09 2017-02-09 Physical equipment access method and device Active CN106844036B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710072859.7A CN106844036B (en) 2017-02-09 2017-02-09 Physical equipment access method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710072859.7A CN106844036B (en) 2017-02-09 2017-02-09 Physical equipment access method and device

Publications (2)

Publication Number Publication Date
CN106844036A CN106844036A (en) 2017-06-13
CN106844036B true CN106844036B (en) 2020-03-31

Family

ID=59121909

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710072859.7A Active CN106844036B (en) 2017-02-09 2017-02-09 Physical equipment access method and device

Country Status (1)

Country Link
CN (1) CN106844036B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108459901B (en) * 2018-01-24 2019-04-23 深圳市普威技术有限公司 A kind of processing method of process lock, apparatus and system
CN110196778B (en) * 2019-05-09 2023-05-26 中国航空工业集团公司西安航空计算技术研究所 Message conversion method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101046803A (en) * 2006-03-28 2007-10-03 大唐移动通信设备有限公司 Safety management method and device of file system
CN101593131A (en) * 2008-05-28 2009-12-02 国际商业机器公司 Realize the method and apparatus of threading operation based on object pool
CN104657193A (en) * 2013-11-21 2015-05-27 华为技术有限公司 Method and device for accessing to physical resources

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101046803A (en) * 2006-03-28 2007-10-03 大唐移动通信设备有限公司 Safety management method and device of file system
CN101593131A (en) * 2008-05-28 2009-12-02 国际商业机器公司 Realize the method and apparatus of threading operation based on object pool
CN104657193A (en) * 2013-11-21 2015-05-27 华为技术有限公司 Method and device for accessing to physical resources

Also Published As

Publication number Publication date
CN106844036A (en) 2017-06-13

Similar Documents

Publication Publication Date Title
US7581047B2 (en) Usage of keyboard driver in extensible firmware interface for adding new hot keys at firmware level
CN106547612B (en) Multitasking method and device
US9858115B2 (en) Task scheduling method for dispatching tasks based on computing power of different processor cores in heterogeneous multi-core processor system and related non-transitory computer readable medium
US11210131B2 (en) Method and apparatus for assigning computing task
KR102338849B1 (en) Method and system for providing stack memory management in real-time operating systems
CN111324427B (en) Task scheduling method and device based on DSP
US9378047B1 (en) Efficient communication of interrupts from kernel space to user space using event queues
CN106775948B (en) Cloud task scheduling method and device based on priority
US20170052979A1 (en) Input/Output (IO) Request Processing Method and File Server
CN106844036B (en) Physical equipment access method and device
CN114936173B (en) Read-write method, device, equipment and storage medium of eMMC device
CN109561134B (en) Electronic device, distributed cluster service distribution method and storage medium
CN114640707A (en) Message asynchronous processing method and device, electronic equipment and storage medium
CN107045452B (en) Virtual machine scheduling method and device
CN111858035A (en) FPGA equipment allocation method, device, equipment and storage medium
CN116107772A (en) Multithreading data processing method and device, processor and electronic equipment
US11360702B2 (en) Controller event queues
WO2019178178A1 (en) Thread scheduling for multithreaded data processing environments
CN113485835B (en) Method, system, equipment and medium for realizing memory sharing under multiple scenes
CN107632893B (en) Message queue processing method and device
CN114390104A (en) Process forensics system, method, apparatus, computer device and medium
CN110673931A (en) Distributed calculation method for document synthesis, document synthesis system and control device thereof
CN102867018A (en) Method for analogue signal communication between threads in database system
US20100228748A1 (en) Data subset retrieval from a queued message
EP3343370A1 (en) Method of processing opencl kernel and computing device therefor

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
GR01 Patent grant
GR01 Patent grant