Abstract:
A program, an apparatus and a method verify a program that efficiently verifies a concurrent/parallel program, allowing interactively debugging the current/parallel program. The program causes a computer to execute a detection step that detects the function that has been altered and the function that uses a shared variable influenced by the alteration out of the program to be verified before and after the alteration and also detects the part that is influenced by the alteration, the control structure part and the other parts, a model generation step that generates a model on the basis of the outcome of the detection in the detection step and a verification step that verifies the program to be verified after the alteration by comparing the model of the program to be verified before the alteration and the model of the program to be verified after the alteration.

Description:
BACKGROUND OF THE INVENTION  
       [0001]     1. Field of the Invention  
         [0002]     This invention relates to a program, an apparatus and a method for verifying a program that verifies a concurrent program or a parallel program.  
         [0003]     2. Description of the Related Art  
         [0004]     A concurrent program or a parallel program is composed of a plurality of processes (threads). The processes may refer to and/or rewrite a shared same resource (common variable). However, when a plurality of processes is allowed to freely refer to and/or rewrite shared resources, a result that the program designer did not expect can be output by the program.  
         [0005]     Now, a parallel program will be described by way of a specific example. The parallel program of this example is composed of a definition of shared variable “shared”, a function “Process  01 ” and another function “Process  02 ”. In the accompanying drawings,  FIG. 32  illustrates a source code that is an example of definition of a shared variable in a parallel program while  FIG. 33  illustrates a source code that is an example of function Process  01  and  FIG. 34  illustrates a source code that is an example of function Process  02 . The two processes Process  01  and Process  02  share a shared variable “shared”. The parallel program is specified in such a way that the function Process  01  and the function Process  02  operate in parallel and functions a( 1 ) and b( 0 ) are invoked alternately. For example, a trace as described below can take place as that of a first parallel program. 
    1. Process  01 . Refer to shared (shared==0)     2. Process  01 . shared=1     3. Process  02 . Refer to shared (shared==1)     4. Process  02 . shared=0     5. Process  02 . b (0)     6. Process  01 . a (0)    
 
         [0012]     The trace of this example is a has an error because the order of the execution of the function a and that of the function b is inverted and the both arguments become equal to 0 and do not meet the specified requirements.  
         [0013]     A synchronizing mechanism such as MUTEX lock or semaphore is used to prevent such a problem. For example, programs can be modified by using a MUTEX lock. When a process refers or writes to a shared resource, using a synchronizing mechanism, the designed execution order is observed because another process does not interfere with it.  FIG. 35  illustrates a source code that shows an example of result of modification of the function Process  01  in the parallel program.  FIG. 36  illustrates a source code that shows an example of result of modification of the function Process  02  in the parallel program. In this example, the parts protected by lock l (from a call for locking and a call for unlocking) are sequentially executed.  
         [0014]     For example, the technique that is described in Patent Document 1 (Japanese Patent Application Laid-Open Publication No. 8-328897) is known as a related conventional technique. The parallel program operation analysis method described in the above patent document is designed to display the state of transition of each of the parallel programs that operate on a parallel computer and support the effort of identifying the cause of the error, if any.  
         [0015]     However, the number of the parts that are executed sequentially increases when a synchronizing mechanism as described above is put to use frequently. Then, the merit of the parallelism of programs will not be exploited satisfactorily. Such a situation is not desirable from the viewpoint of performance. Additionally, the operation of the synchronizing mechanism involves overhead, which by turn further reduces the performance.  
         [0016]     However, many concurrent/parallel programs are executed on assumptions. Therefore, the load of synchronous operations can be partly alleviated when the programs are altered by taking the assumptions into consideration. Then, as the load of synchronous operations is alleviated, the time that can be spent for executing processes concurrently or in parallel is increased to improve the speed of execution of the entire programs. However, to improve the speed of execution of concurrent or parallel programs so as to make them operate properly, it is necessary to conduct the job of improving the speed of execution while comparing the outcome of the programs before the alterations and that of the programs after the alterations. Then, an interactive tool such as debugger is required for the job. Particularly, it is a difficult job to identify the error that is caused by synchronism of concurrent/parallel programs.  
         [0017]     In the case of a debugger for ordinary serial programs, test data are selected in advance for the program to be debugged and the designer executes each step, observing the outcome of execution of the step. In the case of concurrent or parallel programs, the outcome of execution depends not only on the test data but also on the timing of accessing the shared resource of each process. However, debuggers for ordinary serial programs are not designed by taking such timings into consideration, therefore they are not suited for debugging concurrent/parallel programs.  
         [0018]     Debuggers specifically designed for concurrent/parallel programs are available. Such debuggers adopt a technique of feeding test data, altering the timings of execution of processes that operate concurrently or in parallel. However, since all the timings of execution of processes have to be tested with such a technique, a very long time will have to be spent for debugging.  
         [0019]     Additionally, formal verification techniques such as a model check technique are employed for debugging concurrent/parallel programs. An ordinary model check technique proceeds in a manner as described below. A model of an entire program that operates properly before an alteration such as a FSM (finite state machine) is prepared in advance. After the alteration of the program, a model of the altered program is prepared and the two models are compared by means of an equivalence verification technique or a similar technique. However, when in the case of a large scale program, the operation of preparing such a model is very time consuming and that of preparing models is also very time consuming. Therefore, the operation of interactively debugging an ordinary program has been a difficult one.  
       SUMMARY OF THE INVENTION  
       [0020]     In view of the above-identified circumstances, it is therefore the object of the present invention to provide a program, an apparatus and a method for verifying a program that efficiently verifies a concurrent/parallel program, allowing interactively debugging the current/parallel program.  
         [0021]     In an aspect of the present invention, the above object is achieved by providing a verification program of a program for causing a computer to verify a concurrent program or a parallel program composed so as to include a plurality of functions after an alteration made to the program to be verified, the verification program being adapted to cause a computer to execute: a detection step that detects the function that has been altered and the function that uses a shared variable influenced by the alteration along with the first part that includes the altered part of the altered function and the influenced part of the function using the shared variable influenced by the alteration, and the control structure part relating to the control of program processing and the second part other than the control structure part and the first part out of the program to be verified before and after the alteration made to the program to be verified; a model generation step that generates a model of the program to be verified before the alteration and a model of the program to be verified after the alteration on the basis of the control structure part, the first part and the second part detected in the detection step; and a verification step that verifies the program to be verified after the alteration by comparing the model of the program to be verified before the alteration and the model of the program to be verified after the alteration, the models being generated in the model generation step.  
         [0022]     In a verification program for verifying a program according to the invention, the detection step defines the first part as the part where the shared variable influenced by the alteration appears and the locked part of the shared variable.  
         [0023]     In a verification program for verifying a program according to the invention, the detection step adds a mark to the first part of the program to be verified.  
         [0024]     In a verification program for verifying a program according to the invention, the model generation step generates a finite state machine as model by allocating the basic blocks of the first part and the second part to a state and expressing transition on the basis of the control structure part.  
         [0025]     In a verification program for verifying a program according to the invention, the model generation step puts a plurality of states that do not contain the first part into a single state in the models.  
         [0026]     In a verification program for verifying a program according to the invention, the verification step verifies the program to be verified after the alteration firstly by comparing the model before the alteration and the model after the alteration on the altered function and, if they are found to be not equivalent as a result of comparison, comparing the model before the alteration and the model after the alteration for the model obtained by multiplication of the state of a model of the altered function and that of a model of the function using the shared variable influenced by the alteration.  
         [0027]     In a verification program for verifying a program according to the invention, the verification step detects a state that causes a predetermined error and displays the state when the model of the program to be verified before the alteration and the model of the program to be verified after the alteration are not equivalent.  
         [0028]     In a verification program for verifying a program according to the invention, the verification step detects a state that causes a predetermined error and the sequence of execution that causes the state and displays the sequence of execution when the model of the program to be verified before the alteration and the model of the program to be verified after the alteration are not equivalent.  
         [0029]     In a verification program for verifying a program according to the invention, the verification step verifies the program to be verified after the alteration, using a rule base check or a model check.  
         [0030]     In another aspect of the present invention, there is provided a verification apparatus for verifying a program that verifies a concurrent program or a parallel program composed so as to include a plurality of functions after an alteration made to the program to be verified, the verification apparatus comprising: a detecting section that detects the function that has been altered and the function that uses a shared variable influenced by the alteration along with the first part that includes the altered part of the altered function and the influenced part of the function using the shared variable influenced by the alteration, and the control structure part relating to the control of program processing and the second part other than the control structure part and the first part out of the program to be verified before and after the alteration made to the program to be verified; a model generating section that generates a model of the program to be verified before the alteration and a model of the program to be verified after the alteration on the basis of the control structure part, the first part and the second part detected by the detecting section; and a verifying section that verifies the program to be verified after the alteration by comparing the model of the program to be verified before the alteration and the model of the program to be verified after the alteration, the models being generated by the model generating section.  
         [0031]     In a verification apparatus for verifying a program according to the invention, the detecting section defines the first part as the part where the shared variable influenced by the alteration appears and the locked part of the shared variable.  
         [0032]     In a verification apparatus for verifying a program according to the invention, the detecting section adds a mark to the first part of the program to be verified and the model generating section sorts the first part from the second part by detecting the mark.  
         [0033]     In a verification apparatus for verifying a program according to the invention, the model generating section generates a finite state machine as model by allocating the basic blocks of the first part and the second part to a state and expressing transition on the basis of the control structure part.  
         [0034]     In a verification apparatus for verifying a program according to the invention, the model generating section puts a plurality of states that do not contain the first part into a single state in the models.  
         [0035]     In a verification apparatus for verifying a program according to the invention, the verifying section verifies the program to be verified after the alteration firstly by comparing the model before the alteration and the model after the alteration on the altered function and, if they are found to be not equivalent as a result of comparison, comparing the model before the alteration and the model after the alteration for the model obtained by multiplication of the state of a model of the altered function and that of a model of the function using the shared variable influenced by the alteration.  
         [0036]     In a verification apparatus for verifying a program according to the invention, the verifying section detects a state that causes a predetermined error and displays the state when the model of the program to be verified before the alteration and the model of the program to be verified after the alteration are not equivalent.  
         [0037]     In a verification apparatus for verifying a program according to the invention, the verifying section detects a state that causes a predetermined error and the sequence of execution that causes the state and displays the sequence of execution when the model of the program to be verified before the alteration and the model of the program to be verified after the alteration are not equivalent.  
         [0038]     In a verification apparatus for verifying a program according to the invention, the verification section verifies the program to be verified after the alteration, using a rule base check or a model check.  
         [0039]     In still another aspect of the invention, there is provided a verification method for verifying a program that verifies a concurrent program or a parallel program to be verified after an alteration made to the program to be verified, the verification method comprising: a detection step that detects the function that has been altered and the function that uses a shared variable influenced by the alteration out of the program to be verified before and after the alteration made to the program to be verified and also detects the first part that is the part influenced by the alteration out of the detected functions; a model generation step that sorts the control structure, the first part and the second part other than the control structure and the first part out of the functions detected in the detection step and generates a model of the program to be verified before the alteration and a model of the program to be verified after the alteration on the basis of the sorting; and a verification step that verifies the program to be verified after the alteration by comparing the model of the program to be verified before the alteration and the model of the program to be verified after the alteration, the models being generated in the model generation step.  
         [0040]     Thus, according to the invention, it is possible to conduct an interactive debugging operation by significantly reducing the time required for verifying a concurrent/parallel program and hence it is possible to remarkably improve the efficiency of developing concurrent/parallel programs. 
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0041]      FIG. 1  is a schematic block diagram of a program verification apparatus according to the invention, showing the configuration thereof as an example;  
         [0042]      FIG. 2  is a schematic illustration of a source code showing the definition of a shared variable in the first program to be verified;  
         [0043]      FIG. 3  is a schematic illustration of a source code showing function Process  1  before an alteration in the first program to be verified;  
         [0044]      FIG. 4  is a schematic illustration of a source code showing function Process  2  in the first program to be verified;  
         [0045]      FIG. 5  is a schematic illustration of a source code showing function Process  1  after an alteration in the first program to be verified;  
         [0046]      FIG. 6  is a flow chart of an example of operation of the program verification apparatus according to the invention;  
         [0047]      FIG. 7  is a flow chart of an example of operation of an alteration detection process according to the invention;  
         [0048]      FIG. 8  is a schematic illustration of a source code showing as an example the results of an alteration detection process of function Process  1  after an alteration in the first program to be verified;  
         [0049]      FIG. 9  is a schematic illustration of a source code showing as an example the results of an alteration detection process of function Process  1  before an alteration in the first program to be verified;  
         [0050]      FIG. 10  is s a schematic illustration of a source code showing as an example the results of an alteration detection process of function Process  2  in the first program to be verified;  
         [0051]      FIG. 11  is a flow chart of an example of operation of a source code sorting process according to the invention;  
         [0052]      FIG. 12  is a schematic illustration of a source code showing as an example the results of a source code sorting process of function Process  1  before an alteration in the first program to be verified;  
         [0053]      FIG. 13  is a schematic illustration of a source code showing as an example the results of a source code sorting process of function Process  2  in the first program to be verified;  
         [0054]      FIG. 14  is a schematic illustration of a source code showing as an example the results of a source code sorting process of function Process  1  after an alteration in the first program to be verified;  
         [0055]      FIG. 15  is a flow chart of an example of operation of a model generation process according to the invention;  
         [0056]      FIG. 16  is a schematic illustration of a model, showing as an example the results of state allocation in a model generation process of function Process  1  after an alteration in the first program to be verified;  
         [0057]      FIG. 17  is a schematic illustration of a model, showing as an example the results of a model generation process of function Process  1  after an alteration in the first program to be verified;  
         [0058]      FIG. 18  is a schematic illustration of a model, showing as an example the results of state allocation in a model generation process of function Process  1  before an alteration in the first program to be verified;  
         [0059]      FIG. 19  is a schematic illustration of a model, showing as an example the results of a model generation process of function Process  1  before an alteration in the first program to be verified;  
         [0060]      FIG. 20  is a schematic illustration of a model, showing as an example the results of a model generation process of function Process  2  in the first program to be verified;  
         [0061]      FIG. 21  is a flow chart of an example of operation of a verification process according to the invention;  
         [0062]      FIG. 22  is a flow chart of an example of operation of a trace generation process according to the invention;  
         [0063]      FIG. 23  is a schematic illustration of a source code showing the definition of a shared variable in the second program to be verified;  
         [0064]      FIG. 24  is a schematic illustration of a source code showing function Process  3  in the second program to be verified;  
         [0065]      FIG. 25  is a schematic illustration of a source code showing function Process  4  before an alteration in the second program to be verified;  
         [0066]      FIG. 26  is a schematic illustration of a source code showing function Process  4  after an alteration in the second program to be verified;  
         [0067]      FIG. 27  is a schematic illustration of a source code showing as an example the results of a source code sorting process of function Process  4  after an alteration in the second program to be verified;  
         [0068]      FIG. 28  is a flow chart of an example of operation of a state unfolding process according to the invention;  
         [0069]      FIG. 29  is a state transition diagram showing as an example the results of a model generation process of function Process  4  after an alteration in the second program to be verified;  
         [0070]      FIG. 30  is a state transition diagram showing as an example the results of a model generation process of function Process  3  in the second program to be verified;  
         [0071]      FIG. 31  is a state transition diagram showing as an example the results of a model generation process of function Process  4  before an alteration in the second program to be verified;  
         [0072]      FIG. 32  is a schematic illustration of a source code showing the definition of a shared variable in a parallel program;  
         [0073]      FIG. 33  is a schematic illustration of a source code showing as an example function Process  01  in a parallel program;  
         [0074]      FIG. 34  is a schematic illustration of a source code showing as an example function Process  02  in a parallel program;  
         [0075]      FIG. 35  is a schematic illustration of a source code showing as an example the results of modification of function Process  01  in a parallel program; and  
         [0076]      FIG. 36  is a schematic illustration of a source code showing as an example the results of modification of function Process  02  in a parallel program. 
     
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS  
       [0077]     Now, the present invention will be described in greater detail by referring to the accompanying drawings that illustrate preferred embodiments of the invention.  
         [0000]     (First Embodiment)  
         [0078]     In the description of this embodiment, it is assumed that a MUTEX lock is used as synchronizing mechanism and there is a data race between the shared variables as a result of an alteration made to a program.  
         [0079]      FIG. 1  is a schematic block diagram of a program verification apparatus according to the invention, showing the configuration thereof as an example. This program verification apparatus comprises an alteration detecting section  11 , a source code sorting section  12 , a model generating section  13  and a verifying section  14 .  
         [0080]     Firstly, the operation of a program verification apparatus according to the invention will be described in terms of the first program to be verified as a specific example of parallel program. The source code of the first program to be verified comprises a definition of a shared variable, a function Process  1  and another function Process  2 .  FIG. 2  is a schematic illustration of the source code showing the definition of the shared variable in the first program to be verified.  FIG. 3  is a schematic illustration of the source code showing the function Process  1  before an alteration in the first program to be verified.  FIG. 4  is a schematic illustration of the source code showing the function Process  2  in the first program to be verified.  FIG. 5  is a schematic illustration of the source code showing the function Process  1  after an alteration in the first program to be verified. As seen from the figures, there is a data race involving the shared variable shared  1  between the function Process  1  and the function Process  2  when the function Process  1  is altered.  
         [0081]      FIG. 6  is a flow chart of an example of operation of the program verification apparatus according to the invention.  
         [0082]     Firstly, the alteration detecting section  11  executes an alteration detection process of reading the program before the alteration and the program after the alteration and checking the difference between them (S 11 ).  
         [0083]      FIG. 7  is a flow chart of an example of operation of an alteration detection process according to the invention. Firstly, the alteration detecting section  11  compares the program before the alteration and the program after the alteration and identifies function J that was altered and the set of shared variables V that was influenced by the alteration (S 21 ). Then, the alteration detecting section  11  adds a mark to the part where set of shared variables V appears and the locked part in function J after the alteration (S 22 ). Thereafter, the alteration detecting section  11  adds a mark to the part where the set of shared variables V appears and the locked part in function J before the alteration (S 23 ). Subsequently, the alteration detecting section  11  identifies function K where the set of shared variables V appears from the other function (S 24 ). Then, the alteration detecting section  11  adds a mark to the part where the set of shared variables V appears and the locked part in the function K (S 25 ). Thereafter, the alteration detecting section  11  output the marked set of functions (S 26 ) and ends the process.  
         [0084]     Now, a specific example of alteration detection process will be described below.  FIG. 8  is a schematic illustration of a source code showing as an example the results of an alteration detection process of function Process  1  after an alteration in the first program to be verified. Referring to  FIG. 8 , firstly the alteration detecting section  11  identifies the function Process  1  as the only function that is altered and also the part where of the function Process  1  that is altered and subsequently adds marks “//1” through “//6” to the identified part. The alteration detecting section  11  identifies shared variable shared  1  as the shared variable that is used at the altered part.  
         [0085]      FIG. 9  is a schematic illustration of a source code showing as an example the results of an alteration detection process of function Process  1  before an alteration in the first program to be verified. Then, the alteration detecting section  11  identifies the part of the Process  1  where shared  1  appears before the alteration and adds mark “//S” to the identified part.  FIG. 10  is a schematic illustration of a source code showing as an example the results of an alteration detection process of function Process  2  in the first program to be verified. Then, the alteration detecting section  11  retrieves another process that uses variable shared  1 , identifies function Process  2  and also the part where shared  1  appears in the function Process  1  and adds mark “//S” to the identified part. As a result, the output of the alteration detecting section  11  is a set of the function Process  1  before the alteration, the function Process  1  after the alteration and the function Process  2  and the source code where marks are added to the altered parts and the parts influenced by the alterations.  
         [0086]     Subsequently, the source code sorting section  12  sorts the control structure, the part that is influenced by an alteration and the remaining part (S 12 ). The source code sorting section  12  sorts out sentences on a basic block by basic block basis, leaving the control structure and the marked sentences unsorted. A basic block is a block defined for compiler techniques and refers to a block having only an entrance and an exit for a control flow.  
         [0087]      FIG. 11  is a flow chart of an example of operation of a source code sorting process according to the invention. Referring to  FIG. 11 , firstly the source code sorting section  12  takes out a function j from a set of functions that is an output of the alteration detecting section  11  (S 31 ). Then, the source code sorting section  12  extracts the control structure from the function j and outputs it to a new extracted function j′ (S 32 ). Thereafter, the source code sorting section  12  extracts the marked part from the function j and outputs it to the extracted function j′ (S 33 ). Subsequently, the source code sorting section  12  sorts out the unmarked parts from the function j, extracts them on a basic block by basic block basis and outputs them to the extracted function j′ (S 34 ). Then, the source code sorting section  12  determines if any unprocessed function is left in the set of functions or not (S 35 ). If an unprocessed function is left (S 35 , Y), it returns to the processing step S 31 . If, on the other hand, there is not any unprocessed function left (S 35 , N), it outputs the set of extracted functions j′ as set of extracted functions (S 36 ) and ends the flow.  
         [0088]     Now, the source code sorting process will be described by way of a specific example.  FIG. 12  is a schematic illustration of a source code showing as an example the results of a source code sorting process of function Process  1  before an alteration in the first program to be verified. The basic blocks of function Process  1  before an alteration are sorted as pseudo-function AA ( ), pseudo-function BB ( ), pseudo-function CC ( ), pseudo-function DD ( ) and pseudo-function EE ( ).  FIG. 13  is a schematic illustration of a source code showing as an example the results of a source code sorting process of function Process  2  in the first program to be verified. The basic blocks of function Process  2  are sorted as pseudo-function XX ( ) and pseudo-function ZZ ( ).  
         [0089]      FIG. 14  is a schematic illustration of a source code showing as an example the results of a source code sorting process of function Process  1  after an alteration in the first program to be verified. The basic blocks of the function Process  1  after the alteration can be sorted by sorting function a ( ) and function b ( ) as pseudo-function A ( ), function d ( ) as pseudo-function B ( ), function e ( ) as pseudo-function C ( ), function I.lock ( ) through function f ( ) as pseudo-function D ( )and function h ( ) as pseudo-function E ( ).  
         [0090]     Then, the model generating section  13  transforms the result of the source code sorting process into a model (S 13 ). The type of the model may vary depending on the technique used in the verification process as will be described hereinafter, a model check is used for the verification process of this embodiment and an FSM is used as model. The model generating section  13  allocates the states of the results of the source code sorting process on a basic block by basic block basis or on a block by block basis for referring to a shared variable and additionally realizes state optimization. State optimization is a process of sorting states that do not contain any marked part as a single state. It can be realized by applying the State Minimization algorithm.  
         [0091]      FIG. 15  is a flow chart of an example of operation of a model generation process according to the invention. Referring to  FIG. 15 , firstly the model generating section  13  takes out an extracted function j′ out of a set of extracted functions that is the output of the source code sorting section  12  (S 41 ). Then, the model generating section  13  regards the part protected by a lock as basic block (S 42 ). Thereafter, the model generating section  13  traces the control structure of the extracted function j′ and takes out a basic block (S 43 ). Subsequently, the model generating section  13  determines if there is any marked part in the basic block or not (S 44 ). If there is at least a marked part (S 44 , Y), the model generating section  13  separates the marked part from the basic block and allocates it to a state (S 45 ), while it allocates the remaining parts to respective states (S 46 ) and proceeds to the processing step S 48 . If, on the other hand, there is not any marked part (S 44 , N), the model generating section  13  allocates the basic block to a state (S 47 ) and proceeds to the processing step S 48 .  
         [0092]     Then, in the processing step S 48 , the model generating section  13  determines if any unprocessed basic block is remaining or not (S 48 ). If at least an unprocessed basic block is remaining (S 48 , Y), it returns to the processing step S 43 . If, on the other hand, no unprocessed basic block is remaining (S 48 , N), the model generating section  13  realizes state optimization (S 49 ). Thereafter, the model generating section  13  determines if any unprocessed extracted function is remaining in the set of extracted functions (S 50 ). If at least an unprocessed extracted function is remaining (S 50 , Y), it returns to the processing step S 41 . If, on the other hand, no unprocessed extracted function is remaining (S 50 , N), the model generating section  13  outputs the results of state optimization as a set of FSM models (S 51 ) and ends the flow.  
         [0093]     Now, a specific example of model generation process will be described below. Firstly, the results of state allocation down to the processing step S 48  will be described.  FIG. 16  is a schematic illustration of a model, showing as an example the results of state allocation in a model generation process of function Process  1  after an alteration in the first program to be verified. The model generating section  13  allocates pseudo-function A ( ) and function c ( ) as state A, pseudo-function B ( ) as state B, pseudo-function C ( ) as state C, pseudo-function D ( ) as state D, pseudo-function E ( ) as state E, “//1”, “//2” and “//3” as state N 123  and “//4”, “//5” and “//6” as state N 456  respectively. Now, the results of state optimization in the processing step S 49  will be described below.  FIG. 17  is a schematic illustration of a model, showing as an example the results of a model generation process of function Process  1  after an alteration in the first program to be verified. Here, state A, state B, state C and state D become a single basic block and, since there is not any marked part in it, they are integrated to state A′.  
         [0094]     In a similar manner, the model generating section  13  executes a model generation process on function Process  1  and function Process  2  before an alteration.  FIG. 18  is a schematic illustration of a model, showing as an example the results of state allocation in a model generation process of function Process  1  before an alteration in the first program to be verified. Pseudo-function AA ( ), pseudo-function BB ( ), pseudo-function CC ( ), pseudo-function DD ( ) and pseudo-function EE ( )are allocated respectively to state AA, state BB, state CC, state DD and state EE and the part that is marked with “//S” is allocated to state N 1 .  FIG. 19  is a schematic illustration of a model, showing as an example the results of a model generation process of function Process  1  before an alteration in the first program to be verified. State AA, state BB, state CC and state DD become a single basic block and integrated to state AA′ because there is not any marked part in it.  
         [0095]      FIG. 20  is a schematic illustration of a model, showing as an example the results of a model generation process of function Process  2  in the first program to be verified. Pseudo-function XX ( ) and pseudo-function ZZ ( ) are allocated respectively to state XX and state ZZ and the part that is marked with “//S” is allocated to state N 2 . No change takes place as a result of state optimization.  
         [0096]     Then, the verifying section  14  executes a verification process, using the results of the model generation process (S 14 ). While techniques that can be used for a verification process include model check and rule base check, the model check technique is used for the verification process in this embodiment.  
         [0097]      FIG. 21  is a flow chart of an example of operation of a verification process according to the invention. Referring to  FIG. 21 , firstly the verifying section  14  performs a model check operation on the altered functions in the set of FSM models output from the model generating section  13  (S 61 ) and determines if the models are equivalent or not (S 62 ). If the models are equivalent (S 62 , Y), the verifying section  14  proceeds to processing step S 68 . If, on the other hand, the models are not equivalent (S 62 , N), the verifying section  14  extends the range of functions to be verified and performs a model check operation (S 63 ) so as to determine if the models are equivalent or not (S 64 ). If the models are equivalent (S 64 , Y), the verifying section  14  proceeds to processing step S 68 . If, on the other hand, the models are not equivalent (S 64 , N), the verifying section  14  displays the part that is a problem (S 66 ). Then, if possible, it adds a restriction to the operation of the program and, if necessary, inserts assertion according to the direction of the designer (S 67 ). Then, it returns to processing step S 63 . In processing step S 68 , the verifying section  14  displays that there is not any problem due to the alteration (S 68 ) and ends the flow.  
         [0098]     In the verification process, the model before an alteration and the model after the alteration are compared for a function that is altered and a model check operation is conducted. If the models are found to be equivalent as a result of the verification process, the altered part is guaranteed to behave just like before the alteration and hence it is possible to guarantee that the program does not have an error as a whole. If, on the other hand, the models are not equivalent, the program can have an erroneous behavior and hence the range of functions to be verified is extended and the functions that are detected in the alteration detection process are verified in addition to the altered functions. If no error is found as a result, it is possible to guarantee that the program does not have an error as a whole.  
         [0099]     A product of states is prepared by taking the partial order relation of the models of the functions in order to extend the scope of verification and express the mutual influence of a plurality of functions that operate concurrently and in parallel. Then, the product of states is subjected to verification with an extended scope. A known algorithm is used to obtain the product of states. Such algorithms are described in detail in Berard, B., Bidoit, M., Finkel, A., Laroussinie, F., Petit, A., Petrucci, L., Schnoebelen, P. “Systems and Software Verification Model—Checking Techniques and Tools”, Springer-Verlag, 2001.  
         [0100]     If a problem is found as a result of the verification process, a trace generation process of outputting the sequence of execution, for example, will be an effective means for showing the cause of the error in the processing step S 66 .  FIG. 22  is a flow chart of an example of operation of a trace generation process according to the invention. An FSM and the property to be verified are input to the trace generation process. In this embodiment, the property to be verified is checking if a deadlock or a data race exists or not. Firstly, the verifying section  14  searches for a state that satisfies the property to be verified in the FSM sequentially from the initial state (S 71 ) and determines if there is a state that satisfies the property to be verified (S 72 ). If there is not any state that satisfies the property to be verified (S 72 , N), the verifying section  14  determines that neither a deadlock nor a data race takes place (S 73 ) and ends the flow. If, on the other hand, there is a state that satisfies the property to be verified (S 72 , Y), the verifying section  14  outputs the sequence of execution from the initial state to the state that satisfies the property as trace (S 75 ) and ends the flow.  
         [0101]     If the scope of verification is extended again, it is possible for the designer to execute the verification process after defining restrictions on the operation of the program in the processing step S 63 . When the designer inputs them to the source code as assertion, it is easy to detect the part, if any, that does not observe the restrictions when conducting a test after the end of the debugging operation.  
         [0102]     Now, a specific example of verification process will be described below. In this example, firstly, the model of function Process  1  before an alteration and the model of function Process  1  after the alteration are compared. Since the models are not equivalent as a result, an error can occur. Therefore, the verification process is conducted once again. This time, function Process  2  that can be influenced by the alteration of function Process  1  is included. Then, as a result, it is detected that an error will occur and that an error will occur in the next step of execution. The verifying section  14  displays the outcome of detection.
 
XX→A′→N 123 →E→N 2 →N 456 →ZZ
 
         [0103]     Reading variable shared  1  (invoking function g) from and writing it to function Process  1  before an alteration is protected by a lock so that it is not interrupted (preempted) by function Process  2 . Additionally, when function Process  2  is protected by a lock, the value of shared variable shared  1  is incremented without fail after the function g of the function Process  1  is invoked.  
         [0104]     On the other hand, when the sequence of execution using function Process  1  after an alteration does not meet the specified requirements, both state N 123  (invocation of function g) and state N 456  (writing variable shared  1 ) are protected by a lock. State N 2  (region protected by the lock) of function Process  2  is executed in between state N 123  and state N 456 . Because lock l is released after the read of variable shared  1  in state N 123 , there is no guarantee that the value of variable shared  1  will not be modified before lock l is acquired again in state N 456 . The value of variable shared  1  is not incremented when state N 2  is executed. Therefore, the behavior is different from the behavior before the alteration.  
         [0105]     Such a behavior can be corrected when the designer defines restrictions. In the case of this program, no error occurs when an interruption (preemption) to state N 2  of function Process  2  is prohibited while function Process  1  is in state N 123 , state E or state N 456 .  
         [0000]     (Second Embodiment)  
         [0106]     This embodiment will be described below in terms of a deadlock that takes place when the sequence of synchronizing mechanism for arbitration of accesses to a shared variable is changed.  
         [0107]     The verification apparatus of this embodiment has a configuration similar to that of the first embodiment. The operation of the verification apparatus will be described in the case of using the second program to be verified, which is a specific example of parallel program. The source code of the second program to be verified comprises a definition of a shared variable, a function Process  3  and another function Process  4 .  FIG. 23  is a schematic illustration of the source code showing the definition of the shared variable in the second program to be verified.  FIG. 24  is a schematic illustration of the source code showing the function Process  3  in the second program to be verified.  FIG. 25  is a schematic illustration of the source code showing the function Process  4  before an alteration in the second program to be verified.  
         [0108]      FIG. 26  is a schematic illustration of the source code showing function Process  4  after an alteration in the second program to be verified. As shown in  FIG. 26 , the function Process  4  is altered for the locking sequence. As a result of this alteration, the locking sequence of the function Process  3  and that of the function Process  4  differs from each other when accessing the shared variable.  
         [0109]      FIG. 27  is a schematic illustration of the source code showing as an example the results of a source code sorting process of function Process  4  after an alteration in the second program to be verified. Then, pseudo-function D ( ) and pseudo-function F ( ) are allocated respectively to state D and state F by means of a model generation process. The region (marked by “//E”) that is protected by a lock is regarded as basic block and a state unfolding process is executed. In other words, in this embodiment, the following state unfolding process is executed in place of the above described processing step S 45  in a model generation process.  
         [0110]      FIG. 28  is a flow chart of an example of operation of a state unfolding process according to the invention. Referring to  FIG. 28 , firstly the model generating section  13  determines if there is a plurality of locks in a part of the basic block that is marked and separated in the processing step S 45  or not (S 81 ). If there is not a plurality of locks (S 81 , N), the model generating section  13  allocates a marked state to a state (S 82 ) as in the processing step S 45  and output an altered FSM model (S 83 ) before it ends the flow. If, on the other hand, there is a plurality of locks (S 81 , Y), the model generating section  13  allocates the states that the locks can take to the FSM (S 85 ) and also the operation protected by the locks to a state (S 86 ), makes the locks and the state of transition of the operation matches the control flow of the original basic block (S 87 ) and then outputs the altered FSM model (S 88 ) before it ends the flow.  
         [0111]     In processing step S 83 , the model generating section  13  allocates the states of the FSM to the states that the locks can take. As a result, the four states as listed below are allocated in function Process  4 . 
    state N 10 . acquisition of lock m before operation     state N 20 . acquisition of lock l before operation and after acquisition of lock m     state N 30 . release of lock l immediately after operation     state N 40 . release of lock m after operation and the release of lock l    
 
         [0116]     The operation is allocated to a state in processing step S 84 . In this case, a state is allocated between the state N 20  and the state N 30  listed above to produce the following five states. 
    state N 10 . acquisition of lock m before operation     state N 20 . acquisition of lock l before operation and after acquisition of lock m     state N 25 . operation     state N 30 . release of lock l immediately after operation     state N 40 . release of lock m after operation and the release of lock l  FIG. 29  is a state transition diagram showing as an example the results of a model generation process of function Process  4  after an alteration in the second program to be verified. Referring to  FIG. 29 , state L (U) refers to a state where the lock l is unlocked, state L ( 3 ) refers to a state where function Process  3  acquires the lock l and state L ( 4 ) refers to a state where function Process  4  acquires the lock  1 , whereas state M (U) refers to a state where the lock m is unlocked, state M ( 3 ) refers to a state where function Process  3  acquires the lock m and state M ( 4 ) refers to a state where function Process  4  acquires the lock m. Additionally, when a plurality of function is verified as objects of verification, it is expressed by the product of states. The state L (U) M ( 4 ) through the state L (U) M (U) in  FIG. 29  correspond to the state N 10  through the state N 40 . The FSM of function Process  3  and that of function Process  4  before an alteration can be obtained by following a similar sequence.  FIG. 30  is a state transition diagram showing as an example the results of a model generation process of function Process  3  in the second program to be verified.  FIG. 31  is a state transition diagram showing as an example the results of a model generation process of function Process  4  before an alteration in the second program to be verified.    
 
         [0122]     Then, the function Process  4  after an alteration is not equivalent with the function Process  4  before the alteration in processing step S 61  of the verification process. Therefore, the range of functions to be verified is extended to include function Process  3  for verification. To verify the influence of function Process  3  and function Process  4  that operate concurrently, the product of states of the two functions is prepared by taking the partial order relation and the product is verified. As a result of this model checking operation, it is found that the sequence of execution as shown below leads to a deadlock.  
         [0123]     A→D→L (3) M (U)→L (3) M (4)→deadlock  
         [0124]     The cause of the deadlock is that function Process  4  acquires lock m (state L ( 3 ) M ( 4 )) after function Process  3  acquires lock l (state L ( 3 ) M (U)). Thus, the lock l and the lock m are acquired respectively by the function Process  3  and the function Process  4 . If the function Process  3  tries to acquire the lock m, the process comes to a standstill because the function Process  4  has already acquired it. Similarly, if the function Process  4  tries to acquire the lock l, the process comes to a standstill because the function Process  3  has already acquired it. In this case, the alteration has to be undone in order to correct the error.  
         [0125]     As described above in detail, according to the invention, it is possible to remarkably reduce the time required for verification by preparing models, paying attention to the shared resources and the locks that are influenced by an alteration to a concurrent/parallel program.  
         [0126]     Furthermore, according to the invention, there is provided a program for verifying a program that causes a computer that operates as a program verification apparatus to execute the above described processing steps. More specifically, it is possible to cause a computer that operates as a program verification apparatus to execute such a program when the program is stored in a computer-readable recording medium. Computer-readable recording media that can be used for the purpose of the present invention include internal storage devices such as ROMs and RAMs that are installed in computers, portable type storage media such as CD-ROMs, flexible disks, DVD disks, magneto-optical disks and IC cards, and databases for holding computer programs as well as other computers, their databases and transmission mediums on communication lines.  
         [0127]     For the purpose of the present invention, a detection step corresponds to the alteration detection process and the source code sorting process of the above-described embodiments. A model generation step corresponds to the model generation process of the above-described embodiments. Additionally, a verification step corresponds to the verification process of the above-described embodiments and a verifying section corresponds to the alteration detecting section and the source code sorting section of the above-described embodiments.