Font Size: a A A

The Design And Implementation Of The Parallel C Language Based On The Techniques Of Multithread And RPC

Posted on:2006-09-10Degree:MasterType:Thesis
Country:ChinaCandidate:X H ZouFull Text:PDF
GTID:2168360155453119Subject:Computer system architecture
Abstract/Summary:PDF Full Text Request
High-speed development of the modern science technique and computer network has pushed the development of the parallel computation greatly. Parallel computation is transferring from traditional, special, and super computer platform to the system that is constituted by cheaper, universal, loose coupling, and with single or multiple processors personal computers or workstations. Aiming at this trend of development, this paper designs a parallel program language, Parallel C Language, to implement parallel computation on distributed system, and writing the conversion program from the Parallel C Language program to ANSI C Language program. In order to implement parallel computation, this paper adopts the technique of multithread and remote procedure call. The Parallel C Language is the simple extending of ANSI C Language, which adds some sign sentences to ANSI C Language. Programming parallel application with this language belongs to apparent parallel program. Users use this language to write parallel programs, and the parallel sections of the computation task are partitioned to different nodes of the distributed system. Users specify which tasks are processed in parallel and which node is used to process one task. They needn't comprehend how to implement parallel computation concretely, which is completed by conversion program. The writing of the conversion program is the key and core of this paper's work. Conversion program preprocesses the Parallel C Language program, and combines the techniques of multithread and RPC to construct files needed to implement RPC. In client terminal client main program file, we respectively create one thread for every task to be processed in parallel, and every thread executes remote procedure call. The corresponding remote node processes the task and returns the result to the client terminal. It is namely that we use multithread technique to implement the concurrence of the subtasks of the client terminal, and use RPC technique to distribute the subtasks and execute them in parallel on remote server nodes. Rpcgen is RPC auto-program tool. Using rpcgen to construct RPC application, users only need program RPC specification file, client terminal client main program file, and server terminal server program file (procedures). Large network program details, such as the sending and receiving of RPC messages, the dynamically mapped of the port and the conversion of XDR data, is hided by RPC program packages, RPC client terminal stub file and RPC server terminal stub file, which simplify the program by users. Basing the principle of rpcgen constructing RPC application, in this paper, the conversion program parses the Parallel C Language source program and abstracts the interrelated contents to constructs RPC specification file, RPC client main program file and RPC server program file. Because the conversion program is universal to all Parallel C Language source program, we introduce the template mechanism. It is that we make the frames of RPC files fixed and abstract the corresponding contents to fill the frames. And the elaborate codes depend on the concrete user programs. The language definition of Parallel C Language departs from its implementing mechanism and inserts some sign sentences in ANSI C Language program. In users Parallel C Language programs, sign sentences, #parac_program_name, #parac_program_version, #parac_program_num , give the remote program name, the remote program version, and the remote program number, which are needed by conversion program to construct RPC files. RPC allows only two parameters, one input parameter and one output parameter, so in user program when functions which process tasks on remote nodes have multiple input or output parameters, we should encapsulate them to a structure separately. These structures and constant used in program are defined between the sign sentences #parac_const_para_define_begin and #parac_const_para_define_end. The conversion program abstracts thesedefinitions about parameter type and constant and put them in a head file included by RPC files. The functions to process tasks on remote nodes are defined between #parac_function_define_begin and #parac_function_define_end . In conversion program, we create a chain about functions. The contents of a node are the return value type, function name and input parameter type of a function. To simplify the construct of interface functions of RPC server, conversion program copies the definition of these functions completely to RPC server file, and a corresponding function is nested in a RPC server procedure body .The sentence #parac_call() specifies which subtask is processed in parallel and which node is used to process it. When parsing this sentence, conversion program creates a thread in client main file (pthread_create()), and the thread calls a procedure on remote node specified by user in the sentence. Sequential #parac_call() sentences correspond to creating threads in series .These threads are used to implement the concurrence of subtasks on RPC client terminal. In conversion program we create a function_call chain and the contents of a node are the parameters of a sentence #parac_call(). #parac_wait() corresponds to sentence #parac_call() which has the same sequence number. When parsing this sentence, conversion program makes a thread exit or return a result(pthread_join()) in client main file and scans the function_call chain to get the output parameter name of a node with the same sequence number. If it is not NULL, the return result of the thread will be evaluated to the output parameter. In user program, sequential sentences #parac_call() or sequential sentences #parac_wait() can appear more than one time, so as to implement the parallel process of subtasks step by step. Conversion program parses the Parallel C Language programs and abstracts the corresponding contents to constructs RPC files needed. A user programs parallel application with the Parallel C Language, then the conversion program preprocesses the program to generate RPC files. Compiling RPC specification file to get another four files about RPC. These four files and the c Language files generated by preprocessing are allocated on...
Keywords/Search Tags:Distributed system, Parallel, Multithread, Remote procedure call
PDF Full Text Request
Related items