System for extending software calls to functions on another processor by means of a communications buffer5404519Abstract A method is provided for adding extended functions to a multiprocessor system, specifically, functions that may be called from programming running on a first processor and executed by a second processor. A set of generic entry point commands is provided. Each extended function is associated with an entry point command, that is appropriate for the function's argument format and return requirements, if any. Each entry point command invokes a communications routine that handles the transfer of argument data and return values, if any, between processors. Claims What is claimed is: Description TECHNICAL FIELD OF THE INVENTION
______________________________________
void cmd (cmd.sub.-- number, length, arg.sub.-- 1, arg.sub.-- 2,
. . . arg.sub.-- n);
short cmd.sub.-- number;
short length;
short arg.sub.-- 1, arg.sub.-- 2, . . . arg.sub.-- n;
______________________________________
2. Standard Command with Return This entry point is similar to the Standard Command, except that after calling the subprogram, the first processor waits for the command to finish, and then fetches and returns the return value. The value is returned to the DX:AX registers. An implementation is:
______________________________________
unsigned long ret (cmc.sub.-- number, length,
arg.sub.-- 1, arg.sub.-- 2, . . . arg.sub.-- n);
short cmd.sub.-- number;
short length;
short arg.sub.-- 1, arg.sub.-- 2, . . . arg.sub.-- n;
______________________________________
3. Standard Memory Send Command This entry point is used with functions that require information in the form of an array or structure. The length is in bytes rather than words. The ptr argument is a far pointer into host memory. The contents of the pointer are downloaded into the communications buffer. An implementation is:
______________________________________
void psnd (cmd.sub.-- number, length, ptr)
short cmd.sub.-- number;
short length;
char far *ptr;
______________________________________
4. Standard Memory Return Command This entry point is used with functions that return information in the form of an array or structure. The length, in bytes, is sent as the first element in the command buffer and invokes the function. The function writes the return data into the communications buffer at the word following the length. An implementation is:
______________________________________
unsigned long pget (cmd.sub.-- number, length, ptr);
short cmd.sub.-- number;
short length;
char far *ptr;
______________________________________
5. Standard String This entry point is similar to the Standard Memory Send Command, but instead of sending a pointer with a known length, it sends a null terminated string. In this case, the communications buffer has no length entry as the first word. Successive bytes of the buffer contain the characters in ptr with a null (zero) terminator. An implementation is:
______________________________________
void pstr (cmd.sub.-- number, ptr);
short cmd.sub.-- number;
char far *ptr;
______________________________________
6. Altered Memory Return Command This entry point is used with functions that send and return information in the form of an array or structure. The entry point combines the functionality of the psnd and pget entry points to send the contents of a pointer of length in bytes, which is then modified by the function. When the function ends, the data is returned to the memory of the first processor pointed to by ptr. An implementation is:
______________________________________
unsigned long palt (cmd.sub.-- number, length, ptr);
short cmd.sub.-- number;
short length;
char far *ptr;
______________________________________
7. Send/Return Memory Command This entry point is used with functions that send information in an array or structure and return information to a different array or structure. It is similar to the Altered Memory Return Command, except that data is returned to a different area of host memory. An implementation is:
______________________________________
unsigned long ptrx (cmd.sub.-- number, send.sub.-- length,
send.sub.-- ptr, return.sub.-- length, return.sub.-- ptr);
short cmd.sub.-- number;
short send.sub.-- length;
char far *send.sub.-- ptr;
short *return.sub.-- length;
char far *return.sub.-- ptr;
______________________________________
8. Mixed Immediate and Pointer Command This entry point combines immediate and pointer data. The first parameter after the command number is the number of words to send in the same manner as cmd. Following the number of words, are the words themselves, i.e., the immediate data, on the stack. After the immediate data, is a count of the number of pointers to send. Each pointer is preceded by a count of the number of bytes contained in the array or structure that the pointer is pointing to. An implementation is:
______________________________________
void pcmd (cmd.sub.-- number, num.sub.-- words, word1,
word2, . . ., wordn, num.sub.-- ptrs, cnt1, ptr1,
ptr2, . . ., cntn, ptrn)
short cmd.sub.-- number;
short num.sub.-- words;
short word1;
short word2;
.
.
short num.sub.-- ptrs;
short cnt1;
char far *ptr1;
short cnt2;
char far *ptr2;
.
.
.
short cntn
char far *ptrn;
______________________________________
FIG. 1A illustrates the logic involved in selecting an entry point as a function of return requirements and argument formats. In FIG. 1A, entry points 1-8 correspond to the entry point examples set out above. In step 14, the user defines the function to match the selected entry point. In other words, the function's arguments and return requirements are coded in accordance with the selected entry point. Immediate formats are designed to be used when a function needs to pass only a small number of arguments. In this case, the value of each argument is placed in the communications buffer with a pointer to fetch them. Indirect reference formats are designed to be used when the function passes a large number of arguments. In this situation, the arguments are assembled into an array in memory and passed sequentially to the communications buffer, with a pointer to the array to fetch them from the buffer. Step 15 is programming instructions associated with each entry point to ensure that the communications system correctly transfers the extended function's identifier and its argument data, and any return values. The following examples illustrate code in accordance with part of step 15, for two of the above described entry points, for extracting argument data from a communications buffer. The data.sub.-- ptr is a pointer to a communications buffer, which is described in connection with FIGS. 4a, 4b, and 4c. The corresponding examples of function calls are described below in connection with Step 16.
______________________________________
Standard Command
move A0,*-SP,1 ; save A0
move *-A14,A8,1 ; get data.sub.-- ptr
setf 16,1,0 ; get field size 0 to 16
; bits
move *A8+,A0,0 ; get arg.sub.-- 1 into A0
move *A8,A8,1 ; get arg.sub.-- 2 into A8
Standard Memory Send Command
move *-A14,A11,1 ; get data.sub.-- ptr
setf 16,1,0 ; set field size 0 to 16
; bits
move *A11+,A10,0 ; first word is number
; of bytes the post
; increment of All
; means that it is
; now a pointer to
; arg.sub.-- 2 [0]
srl 2,A10 ; convert to arg.sub.-- 1
______________________________________
Table 1 explains the move, setf, and srl instructions. The first example, the Standard Command, passes two immediate sixteen bit arguments. The second example, the Standard Memory Send Command, uses indirect memory passing.
TABLE 1
__________________________________________________________________________
MOVE Rs, Rd Move - Register to Register
Operation: Rs .fwdarw. Rd
Move the contents of the source register into the
destination
register. It is not necessary for the registers to be
in the same
file.
MOVE Rs, *Rd [.F] Move Field - Register to Indirect
Operation: field in Rs .fwdarw. field in *Rd
Move a field from the source register into a memory
location
specified by the contents of the destination register.
MOVE Rs, *Rd+ [.F]
Move Field - Register to Indirect (Postincrement)
Operation: field in Rs .fwdarw. field in *Rd
Rd + field size .fwdarw. Rd
Move a field from the source register into a memory
location
specified by the contents of the destination register.
After the
move, increment the contents of Rd by the field size.
MOVE Rs, - *Rd [.F]
Move field - Register to Indirect (Predecrement)
Operation: Rd - field size .fwdarw. Rd
field in Rs .fwdarw. field in *Rd
Decrement the contents of Rd by the field size. Move a
field from
the source register into a memory location specified by
the
contents of the destination register.
MOVE Rs, *Rd(offset) [.F]
Move Field - Register to Indirect with Offset
Operation: field in Rs .fwdarw. field in * (Rd +
offset)
Move a field from the source register into a memory
location. The
destination address is formed by adding an offset to
the contents
of the destination register.
MOVE Rs, @DAddress [.F]
Move Field - Register to Absolute
Operation: field in Rs .fwdarw. field in memory
Move a field from the source register into the
specified
destination address.
MOVE *Rs, Rd [.F] Move Field - Indirect to Register
Operation: field in *Rs .fwdarw. field in Rd
Move a field from contents of a memory address into the
destination
register. The source address is specified by the
contents of the
source register.
MOVE *Rs, *Rd [.F]
Move Field - Indirect to Indirect
Operation: field in *Rs .fwdarw. field in *Rd
Move a field from the contents of a memory address into
another
memory address. The source address is specified by the
contents of
the source register, and the destination address is
specified by
the contents of the destination register.
MOVE *Rs+, Rd [.F]
Move Field - Indirect (Postincrement) to Register
Operation: field in *Rs .fwdarw. field in Rd
Rs + field size .fwdarw. Rs
Move a field from the contents of a memory address into
the
destination register. The source address is specified
by the
contents of the source register. After the move,
increment the
contents of the source register by the field size.
MOVE *Rs+,*Rd+ [.F]
Move Field - Indirect (Postincrement) to Indirect
(Postdecrement)
Operation: field in *Rs .fwdarw. field in *Rd
Rs + field size .fwdarw. Rs
Rd + field size .fwdarw. Rd
Move a field from the contents of a memory address into
another
memory address. The source address is specified by the
contents of
the source register, and the destination address is
specified by
the contents of the destination register. After the
move,
increment the contents of both the source register and
the
destination register by the field size.
MOVE -*Rs, Rd [.F]
Move Field - Indirect (Predecrement) to Register
Operation: Rs - field size .fwdarw. Rs
field in *Rs .fwdarw. field in Rd
Decrement the contents of the source register by the
field size.
Move a field from the contents of a memory address into
the
destination register. The source address is specified
by the
contents of the source register.
MOVE -*Rs, Rd [.F]
Move Field - Indirect (Predecrement) to Indirect
(Predecrement)
Operation: Rs - field size .fwdarw. Rs
Rd - field size .fwdarw. Rd
field in *Rs .fwdarw. field in *Rd
Decrement the contents of both the source register and
the
destination register by the field size. Move a field
from the
contents of a memory address into another memory
address. The
source address is specified by the contents of the
source register
and the destination address is specified by the
contents of the
destination register.
MOVE *Rs(offset), Rd [.F]
Move Field - Indirect with Offset to Register
Operation: field in *(Rs - offset) .fwdarw. field in
Rd
Move a field from the contents of a memory address into
the
destination register. The source address is formed by
adding an
offset to the contents of the source register.
MOVE *Rs(offset), *Rd+ [.F]
Move Field - Indirect with Offset to Indirect
(Postincrement)
Operation: field in *)Rs + offset) .fwdarw. field in
(Rd
Move a field from the contents of a memory address into
the
destination register. The source address is formed by
adding an
offset to the contents of the source register. After
the move,
increment the contents of the destination register by
the field
size.
MOVE *Rs(offset), *Rd(offset) [.F]
Move Field - Indirect with Offset to Indirect with
Offset
Operation: field in *(Rs + offset) .fwdarw. field in
*(Rd + offset)
Move a field from the contents of a memory address into
another
memory address. The source address is formed by adding
an offset
to the contents of the source register, and the
destination address
is formed by adding an offset to the contents of the
destination
register.
MOVE @SAddress, Rd [.F]
Move Field - Absolute to Register
Operation: field in source address .fwdarw. field in
Rd
Move a field from the contents of the specified memory
address into
the destination register.
MOVE @SAddress, *Rd+ [.F]
Move Field - Absolute to Indirect (Postincrement)
Operation: field in source address .fwdarw. field in
*Rd
Rd + field size .fwdarw. Rd
Move a field from the contents of the specified source
address into
the memory address specified by the contents of the
destination
register. After the move, increment the contents of
the
destination register by the field size.
MOVE @SAddress, @DAddress [.F]
Move Field - Absolute to Absolute
Operation: field in source address .fwdarw. field in
destination address
Move a field from the contents of the specified source
address into
the specified destination address
SETF FS, FE [.F] Set Field Parameters
Operation: (FS, FE) .fwdarw. ST
Load the values specified for the field size and field
extension
bits into the status register. The remainder of the
status
register is not affected.
SRL K, Rd Shift Right Logical - Constant
Operation: right-shift Rd by K .fwdarw. Rd
Right-shift the contents of the destination register by
the value
of K. (K specified=s a value between 0-31.) Os are
shifted into the
MSBs of Rd. and the last bit shifted out is shifted
into the carry
bit.
SRL Rs, Rd Shift Right Logical - Register
Operation: right-shift Rd by Rs .fwdarw. Rd
Right-shift the contents of the destination register by
the 2s
complement value of the 5 LSBs in the source register.
(The 5 LSBs
of the source register specify a value between 0-31:
Step 16 is adding a function call to the main program of the host processor. A means for invoking the appropriate entry point when the function is called is required, which in the preferred embodiment is accomplished with a preprocessor that directs the programming to the entry point when the extended function is called. The following examples illustrate the function calls for several of the above described entry point commands. Standard Command The function has two actual parameters, arg.sub.-- 1 of 16 bits and arg.sub.-- 2 of 32 bits. The word count, 3, is the sum of one word for the short argument and two words for the long argument. #define function.sub.-- name (arg.sub.-- 1, arg.sub.-- 2) cmd (FUNCTION.sub.-- NAME, 3, (short) (arg.sub.-- 1) , (long) (arg.sub.-- 2)) Standard Memory Send Command The function's arg.sub.-- 1 has 4 bytes of data. #define function.sub.-- name (arg.sub.-- 1, arg.sub.-- 2) psnd (FUNCTION.sub.-- NAME, (short) (4*(arg.sub.-- 1)), (short far*) (arg.sub.-- 2). Standard Memory Return Command The function's arg.sub.-- 1 has 4 bytes of data. #define function name (arg.sub.-- 1, arg.sub.-- 2) pget (FUNCTION.sub.-- NAME, (short) (4* (arg.sub.-- 1)) (char far*) (arg.sub.-- 2)) As a result of the above steps, a module containing at least one extended function may now be compiled and linked to the main program. It may be loaded to the subprocessor system such that during run time, the main program calls the function, which is then executed by the subprocessor, with this exchange of processors being invisible to the computer user. FIG. 1 also illustrates another aspect of the invention, which is a method of supplying extended functions for use with a multiprocessor system. In other words, a set of functions may be prepared by one programmer in accordance with steps 11-14, with the step of integrating the functions inte the program left to another programmer. An example of this situation might be when extended functions are supplied as a library to an applications programmers, who may then use whatever extended functions are desired for a particular application program. FIG. 2 illustrates another aspect of the invention, a method of using a multiprocessor computer system to execute a single program having extended functions. As distinguished from the method of FIG. 1, the method of FIG. 2 is a run time process, which is implemented with computer programming. The method is used while running, on a first processor, a main program having at least one subprogram to be executed by a second processor. This subprogram is compiled and loaded to the second processor, which may occur any time before execution. Basically, the steps of the method of FIG. 2 include first calling the extended function from the main program. This call directs the programming to an entry point of communications programming, which handles the communication of data, used by and returned from the function, between the host processor and the subprocessor. The method of FIG. 2 is for use on a multiprocessor system having a communication means. FIG. 2 is best understood with reference to FIG. 3, which is a block diagram of a computer system having both a host processor system 310 and a subprocessor system 320. Processors 311 and 321 each have their own memory, 312 and 322. A communication means between the two processors is embodied by bus 330 and communications buffer 323. Bus 330 is bidirectional and provides a sixteen bit data path and nine control lines. Communications buffer 323 can be accessed by both processor systems 310 and 320. In the preferred embodiment, communications buffer 323 is a storage structure, having separate locations for host messages and subprocessor messages and other data. Other hardware implementations of a communications storage means are possible, with the primary requirement being that each processor 311 and 321 has access to memory space, including parameter space for handshaking between processors, function identification space to identify the function being called, and data space to pass command arguments and additional data. The configuration shown in FIG. 3 is only one of numerous means for providing interprocessor communications, and other means are easily developed. Furthermore, although FIG. 3 shows the two processor systems, 310 and 320, as having separate memories 312 and 322, the communications means may be a shared memory. The multiprocessor system of FIG. 3 operates with various standard peripheral devices, notably a display 340, mass storage 350, and input devices 360, such as a keyboard or mouse. An I/O circuit 313 is used to communicate information in appropriate form between these input and output devices and the other parts of host system 310, via a host system bus 314. Display 340 and input devices 360 permit a user to interact with the host processor system 310. If subprocessor system 320 is used for graphics tasks, display 340 may be coupled to processor 321 rather than to host system 310. Referring again to FIG. 2, step 21 is calling an extended function. Ae indicated above, the initial call is from a main program running on host processor system 310, but the extended function definition resides in memory 322 of subprocessor system 320. The call must be directed to subprocessor system 320. Thus, in step 21, the call in the main program directs the host processor to an entry point of communications programming, the latter being programmed Eo transfer data consistent with the properties of the function. In the C language embodiment, the call may be in the form of the preprocessor function calls described above in connection with step 16 with FIG. 1. This syntax is especially useful in the preferred embodiment, for redefining the function call as a call to the entry point, using an entry point command. Step 22 is initiating communications between the two processor systems 310 and 320. This step involves using the communications programming and communications buffer 323 to perform handshaking routines. These handshaking routines are known in the art, and include the passing of messages to indicate busy, idle, or message waiting conditions. Although, as indicated above, the memory space used to exchange data between processors is described herein as a communications buffer 323, any mutually accessible form of memory space could be used. Step 23 is loading the extended function's identifier and its argument data into communications buffer 323, using communications programming invoked at the entry point and executed by the host. If the implementation of step 13 above is used, the argument data of an entry point command consists of the identifier and a means for accessing the argument data of the extended function. Step 23 may be referred to as "uploading" extended function data into the mutually accessible memory space, i.e., communications buffer 323. Again, a unique aspect of the invention is that the communications code for passing the extended function's data is in response to an entry point associated with the extended function's properties. FIGS. 4a, 4b, and 4c illustrate data in communications buffer 323 for the entry points Standard, Standard Memory Send, and Standard Memory Return, respectively. The data is consistent with the examples of step 16 of FIG. 1, described above. Step 24 is loading the extended function data from the communications buffer 323 into subprocessor system 320. Step 24 is illustrated in detail in FIG. 5. The function's identifier is moved to subprocessor memory 322 and decoded so that the proper extended function is called. With respect to the function's argument data, the subprocessor system 320 receives a single argument on the stack that is a pointer to the communications buffer 323 where the argument data of the extended function is stored. This embodiment is in accordance with the examples above, which were described in connection with step 15 of FIG. 1. Step 24 may be referred to as "downloading" the extended function data from the memory space, i.e., communications buffer 323. Subprocessor 321 may then execute the function. The pointer generated in step 24 is used to retrieve the function's argument data from communications buffer 323 into the local variables of the extended function. Although not shown in FIG. 2, additional steps may involve returning values to host processor system 310 and modifying values used by host processor 311. In accordance with the examples set out above in connection with Step 13 of FIG. 1, it can be seen that each entry point is associated with communications programming that instructs subprocessor 321 how to transfer the return values and where to put them if the function's return requirements, and its associated entry point, call for these tasks to be performed. FIG. 5 is a flow diagram illustrating Step 24 of the run time method, including its substeps and subsequent steps that occur on the subprocessor system 320. As explained above, Steps 52-56 comprise executing the function and if an entry point associated with a return value has been used, the method includes waiting for and returning this value. A feature of the invention is that, to enhance run time speed, subprocessor system 320 does not check the size of the argument data being transferred to communications buffer 323. However, if large amounts of data are expected to be transferred, and buffer 323 is a fixed size, programming is needed to ensure that the data being transferred does not overflow communications buffer 323. For example, a routine may be created to check the size of the parameters and download them to the subprocessor system 320 if they will fit. If they will not fit, the programming attempts to allocate a temporary buffer from the heap pool to store the parameters. If the allocation is not successful, an error function is invoked. One implementation of an overflow prevention enhancement is an additional set of entry points, to be used when the argument data has the potential of being too large for communications buffer 323 . These entry points have the same function as those above, but invoke additional programming that makes a preliminary pass through the argument data to check its size. If the data will not fit, the programming attempts to allocate a temporary buffer from the heap pool to store the parameters. Another aspect of the invention is a multiprocessor computer system, which permits functions called from a main program running on a first processor system 310 to be executed by a second processor 321. Each one of a set of entry point commands is associated with various function properties. Each entry point command invokes communications programming that enables processors 311 and 321 to exchange data needed by processor 321 to identify, call, and execute the function. These entry points may be implemented with the programming described above in connection with FIGS. 1 and 2. Although the invention has been described with reference to specific embodiments, this description is not meant to be construed in a limiting sense. Various modifications of the disclosed embodiment, as well as alternative embodiments of the invention, will become apparent to persons skilled in the art upon reference to the description. It is, therefore, contemplated that the appended claims will cover such modifications that fall within the true scope of the invention.
|
Same subclass Same class Consider this |
||||||||||
