Summary of the invention
The problem existing for prior art, fundamental purpose of the present invention is to provide a kind of avoiding that cpu resource is caused more greatly and taken, so that causes the optimization method based on rdesktop under Godson platform (SuSE) Linux OS that cannot start graphic user interface.
For achieving the above object, the invention provides a kind of optimization method based on rdesktop under Godson platform (SuSE) Linux OS, the method comprises the steps S1-S7:
S1, on the machine based on Godson platform, open the frame buffering of (SuSE) Linux OS kernel and support, make up environment;
S2, graphics process storehouse DirectFB is transplanted in this on machine based on Godson platform;
S3, under (SuSE) Linux OS, create the display layer that a test pattern card contains, create first type surface, off-screen surfaces and mouse;
S4, the background that window is set, size and location parameter, and the background based on this window, size and location parameter create client window at first type surface;
S5, creating handle, event buffer and the message buffer on this surface, client window place, is that event buffer and message buffer create filec descriptor;
S6, monitor the filec descriptor of all message buffers and event buffer;
S7, use double buffering technology are realized mapping operation and demonstration.
Further, this step S2 transplants graphics process storehouse DirectFB in this and on machine based on Godson platform, comprises the steps S21-S28:
S21, obtain the source code bag of graphics process storehouse DirectFB;
S22, build crossstool chain;
S23, compiling is set required environmental variance is installed;
The source code bag that this step S21 obtains is installed in S24, compiling;
S25, new file system of documenting that this step S24 compiling is installed;
S26, file system programming that this step S25 is made are to the machine based on Godson platform;
S27, operation resolution chart are processed the sample of storehouse DirectFB;
If S28 stable testing is by restarting this machine based on Godson platform, the test of reruning, if test is still stablized and passed through, has transplanted so; Otherwise repeating step S21~S27 is until transplanted.
Step S25 makes a new file system and specifically comprises following steps S251-S254:
S251, the graphics process storehouse DirectFB after cross compile is positioned over to root file system catalogue;
S252, DirectFB program required library file path in graphics process storehouse is set;
The device file that S253, establishment frame buffering drive;
S254, link terminal, obtain the image file of file system.
Further, the filec descriptor that this step S6 monitors all message buffers and event buffer comprises following steps S61-S66:
S61, connection client and terminal server;
S62, the filec descriptor of message buffer and event buffer is joined to the filec descriptor set of monitoring;
S63, judge that whether message buffer is readable, if message buffer is readable, enter step S64, otherwise if message buffer is not readable, event buffer is readable, enters step S65;
S64, the message of message buffer is passed to message processing program carry out, after being disposed, enter step S62;
S65, call local event and process function and process the event in event buffer;
S66, judge whether user asks to exit client after being disposed, if so, close client, if not, enter step S62.
Further, step S7 is used double buffering technology to realize mapping operation and demonstration comprises following steps S71-S76:
S71, in internal memory, open up stack region;
The off-screen surfaces of S72, pinning window, articulates off-screen surfaces and this stack region, and off-screen surfaces is made as to read-write mode;
S73, the view data of utilizing drawing function that needs are drawn write the stack region of opening up in described internal memory;
S74, write rear release off-screen surfaces;
S75, the district of cutting out that need to carry out memory copying is set;
S76, first type surface and off-screen surfaces are carried out to constantly upset and exchange, show in turn first type surface and off-screen surfaces content, realize the demonstration of first type surface and off-screen surfaces and export.
With respect to prior art, first, the present invention for to spin off rdesktop from the X Window of C/S structure, the graphic user interface (GUI) of selecting graphics process storehouse DirectFB to use as exploitation, and graphics process storehouse DirectFB is transplanted in the machine based on Godson platform to some basic functions of the realization of realization, mapping operation and the demonstration of the client window initialization under supplementary X Window system, event and message circulation simultaneously etc.; Secondly, the present invention processes three aspects from communication mechanism, demonstration output and local event rdesktop is optimized, make to reach optimal performance in RDP (RDP) client can be little at storage space, memory size is few and CPU processing power is not strong Godson terminal, make interface program working time, EMS memory occupation and video display effect have performance by a relatively large margin to improve, while having avoided because of use rdesktop, take too much cpu resource, the problem that causes graphic user interface to start.
Embodiment
Below in conjunction with accompanying drawing, describe the specific embodiment of the present invention in detail.
Rdesktop is a client-side program of accessing Windows remote desktop under Unix/Linux, little based on Godson terminal storage space, the feature that memory size is few and CPU processing power is not strong, should abandon using "large and all inclusive" graphic user interface, therefore the optimization method embodiment that the present invention is based on rdesktop under Godson platform (SuSE) Linux OS carries out suitable modification to the RDP client rdesktop under Linux on the machine based on Godson platform, cutting (drawing function that calls X Windows in rdesktop X layer is replaced with the drawing function in the DirectFB of graphics process storehouse) and optimization, make RDP client on the machine based on Godson platform, reach optimal performance objective.
As shown in Figure 1, be the process flow diagram of an a kind of embodiment of optimization method based on rdesktop under Godson platform (SuSE) Linux OS of the present invention, the embodiment of this optimization method comprises following steps S1-S7:
S1, on the machine based on Godson platform, open the frame buffering (Frame Buffer) of (SuSE) Linux OS kernel and support, make up environment.Machine that should be based on Godson platform refer to Godson 2H machine, integrated CPU, graphic process unit, and the Godson 2H development board of north bridge and South Bridge chip; In addition, frame buffering (Frame Buffer) is to appear at the central a kind of USBDI of 2.2.xx kernel, this interface by display device abstract be frame buffer zone, can regard a reflection of display memory as, after being mapped to the process address space, just can directly carry out read-write operation, and read-write operation can immediate response on screen, the device file of this driver is generally/dev/fb0 ,/dev/fb1 etc.;
S2, graphics process storehouse DirectFB is transplanted in this on machine based on Godson platform.Wherein graphics process storehouse DirectFB be one for the shape library of Embedded System Design, operate in the (SuSE) Linux OS that frame buffering (Frame Buffer) support is provided, can on being used, the least possible resource provide maximum hardware acceleration performance, to strengthen the graphing capability of embedded system; DirectFB is a complete hardware abstraction layer, supports translucent window and Multi-level display technology based on Linux frame buffering (Frame Buffer) realization, and the functions such as Hardware graphics acceleration drafting and input processing are provided.
S3, under (SuSE) Linux OS, create the display layer that a test pattern card contains, create first type surface, off-screen surfaces and mouse, the surface wherein being shown by current screen is called first type surface, and the surface not shown by current screen is called off-screen surfaces;
S4, the background that window is set, size and location parameter, and the background based on this window, size and location parameter create client window at this first type surface.Concrete grammar is: background, size and location parameter that window is set; These parameters are inserted to window_desc variable, in window_desc variable, except background, size and the location parameter of window, also comprise the ID of parent window, the ID on flags (field confirmation), color space, surface, pixel format etc. parameter; Using window_desc variable as the parameter that creates client window and client window background, generate client window.Preferably, use 256 looks as the color depth of application, the pixel format of client window and client window background is set to DSPF_LUT8, so that client window and client window background can normally show, in addition, in window_desc variable, use flags (field confirmation) to represent the parameter that needs are paid close attention to.
S5, creating handle, event buffer and the message buffer on this surface, client window place, is that event buffer and message buffer create filec descriptor.The handle creating is for the upset of client window first type surface and two padded surfaces of off-screen surfaces, these two padded surfaces, one of them is first type surface (primary surface), it is a part for display memory, another one is called off-screen surfaces (off screen surface), it is that one section of region in internal memory is used for preserving the image that need to be buffered, and its content can be shown never, and upset realizes by flip function; Event buffer is for storing the local event that client window receives, and the local event receiving will be sent to application program and process; The filec descriptor of message buffer is for constantly being detected by select function in Message Processing and to the arrival of application notification event.
S6, monitor the filec descriptor of all message buffers and event buffer, the filec descriptor that is about to all message buffers all adds eavesdropping target, to meet client, the message buffer of a plurality of windows is monitored, wherein process RDP message and local event and all adopt the multiplexing model of I/O.The concrete methods of realizing of preferred this step is: after RDP client is carried out initial work and is successfully tentatively connected with terminal server, the program circuit of client has just entered a while function circulation, this circulation constantly obtains message or event, then to rely on select function judgement be message or event and give corresponding handling procedure, until user closes after this client, circulates and just exit.
S7, use double buffering technology are realized mapping operation and demonstration.Use double buffering technology can solve well the problem of screen flicker in drawing, and improve the efficiency of drawing output.Utilize graphics process storehouse DirectFB, double buffering technology can be realized with the upset (Flip) of first type surface and off-screen surfaces, utilize Flip function that first type surface and off-screen surfaces are carried out to constantly upset and exchange, show in turn first type surface and off-screen surfaces content.Because just changing surperficial pointer, the mode of utilizing Flip function to overturn do not have to change content wherein, so speed is faster in memory copying mode.
As shown in Figure 2, step S2 transplants graphics process storehouse DirectFB in this and on machine based on Godson platform, specifically comprises the steps S21-S28:
S21, obtain the source code bag of graphics process storehouse DirectFB.Source code bag has comprised zlib-1.2.5.tar.bz2, freetype 2.3.5.tar.bz2, libpng-1.2.40.tar.bz2, jpegsrc.v6b.tar.gz, DirectFB-1.3.0.tar.gz and DirectFB-examples-1.2.0.tar.gz;
S22, build crossstool chain.Concrete grammar is: by under unzip to/opt of the instrument chain gcc-3.4.6.tgz catalogue of the cross compile of Godson platform standard, then the environmental variance of crossstool chain is set.Under linux system/and opt catalogue is generally used for depositing the catalogue of putting to the extra mounting software of main frame, generally puts the software of some tests, convenient debugging, delete;
S23, compiling is set required environmental variance is installed.Concrete grammar is: (1) creates installation directory; (2) installation path, library file path and header file path are set; (3) configuration information file path is set;
The source code bag that S24, compiling installation steps S21 obtain.Zlib-1.2.5, freetype 2.3.5, libpng-1.2.40, jpegsrc.v6b, DirectFB-1.3.0 and DirectFB-examples-1.2.0 are installed in i.e. compiling;
S25, new file system of documenting that step S24 compiling is installed.As shown in Figure 3, step S25 makes a new file system and specifically comprises following steps S251-S254:S251, enters in root file system ramdisk, and the graphics process storehouse DirectFB after cross compile is positioned over to root file system catalogue ramdisk; S252, DirectFB program required library file path in graphics process storehouse is set; The device file that S253, establishment frame buffering (frame buffer) drive; S254, link terminal, obtain the image file ramdisk-cramfs.img of file system.
S26, file system programming that this step S25 is made are to the machine based on Godson platform.Concrete grammar is: (1) powers on to Godson 2H machine; (2) start-up parameter is set, by start-up parameter, the position that the file system of Godson 2H machine is deposited is set, the type of file system (as cramfs, yaffs etc.), resolution of video card etc., start-up parameter is for example as g console=tty root=/dev/sda1 rootfs=yaffs video=sm501fb:1280*800-24@60, by tftp file system mirror file ramdisk-cramfs.img programming to the disk subregion of Godson; (3) complete after input command reboot restart Godson 2H machine;
S27, the file system operation resolution chart that enters Godson 2H machine are processed the sample of storehouse DirectFB;
If S28 stable testing is by restarting this machine (Godson 2H machine) based on Godson platform, the test of reruning, if test is still stablized and passed through, has transplanted so; Otherwise repeating step S21~S27 is until transplanted.
As shown in Figure 4, the filec descriptor that this step S6 monitors all message buffers and event buffer comprises following steps S61-S66:
S61, connection client and terminal server;
S62, the filec descriptor of message buffer and event buffer is joined to the filec descriptor set that select function is monitored;
S63, when select function listens to buffer zone and has fresh content, select function can return to one and be greater than 0 value, this value representation has how many buffer zones to have fresh content; Then utilize that FD_ISSET is grand judges whether a filec descriptor is in and has in the filec descriptor set that fresh content arrives; If it is readable to have listened to buffer zone, judge that whether RDP message buffer is readable, if message buffer is readable, enter step S64, otherwise, if message buffer is not readable, illustrate that event buffer is readable, enter step S65;
S64, the message processing program that the message of message buffer is passed to outside the circulation of while function are carried out, and enter step S62 after being disposed;
S65, call local event and process function DFB_process_Events and process the event in event buffer;
S66, judge whether user asks to exit client after being disposed, if so, close client, if not, enter step S62.
As shown in Figure 5, step S7 is used double buffering technology to realize mapping operation and demonstration, and preferably this step is used Lock function to read and write the data of first type surface and off-screen surfaces: Lock function needs following four parameters: (1) points to the pointer thiz that needs Lock surface; The mode of (2) identifier declaration Lock, be readable, can write or both all can; The pointer ret_ptr that (3) one sections of sensings are used for the internal memory that articulates with surface, is used the pointer that points to BS as actual parameter in program, BS is the stack region of opening up in internal memory in order to realize double buffering; (4) bit plane of ret_pitch presentation surface, because adopting the display mode of 256 looks, so the value of ret_pitch is made as 8.Use double buffering technology realizes mapping operation and demonstration comprises following steps S71-S76:
S71, in internal memory, open up stack region;
S72, when needs carry out mapping operation, application program is pinned the off-screen surfaces of (Lock) window, off-screen surfaces and described stack region is articulated, and off-screen surfaces is made as to read-write mode;
S73, the view data of utilizing drawing function that needs are drawn write the stack region of opening up in described internal memory.Because the stack region of opening up in internal memory and off-screen surfaces articulate, so to the writing namely the writing of off-screen surfaces of the stack region of opening up in internal memory, writing is at this moment that the Pixel arrangement according to target region carries out, to each the pixel assignment in region;
S74, write rear release (Unlock) off-screen surfaces;
S75, use that set_region function setup need to carry out memory copying cut out district (Clip);
S76, call flip function first type surface and off-screen surfaces are carried out to constantly upset and exchange, show in turn first type surface and off-screen surfaces content, realize the demonstration of first type surface and off-screen surfaces and export.
Take ui_screenblt function as example, its function is that a rectangular area on window is copied to another place, so first program should arrange an interim region of memory temp, come storage source rectangular area, then the content in temp is copied in target rectangle region.Here to the read-write operation in target rectangle region, be to use get_pixel and set_pixel function, these two functions can complete respectively the read and write of stack region to opening up in the internal memory pixel value on assigned address.
More than introduced a kind of optimization method based on rdesktop under Godson platform (SuSE) Linux OS.The present invention is not limited to above embodiment, and any technical solution of the present invention that do not depart from only carries out to it improvement or change that those of ordinary skills know, within all belonging to protection scope of the present invention.