Embodiment
Below in conjunction with accompanying drawing preferred implementation of the present invention is described, should be appreciated that, the embodiments described herein only is illustrative effect, those skilled in the art are under instruction of the present invention, can also make amendment to the present invention, conversion, and these modifications or conversion all can not break away from principle of the present invention.
Fig. 1 has schematically shown the figure according to the structure between the kernel of prior art in process and operating system.In the existing computer system, have a plurality of application programs usually and moved simultaneously, the kernel of the application program of operation (process) and computer system carries out alternately, thereby finishes the interactive operations such as transmission, processing of data.
In accompanying drawing 1, schematically shown an individual process, for example process 1.This process context (Process Context) is divided into two parts, and one is the user's space in user model, and another is the process record in kernel mode.
In the system shown in Fig. 1, in user model, for example in the user's space of process 1, comprising: information such as the storehouse of process 1, code and data; One or more dynamic link library/function libraries (DLL/Lib) 110 (Dynamic-Link Library); A kernel interface that is connected with kernel 120, by this kernel interface 120, each process can be carried out with the process recording section 130 in the operating system alternately.In the kernel mode shown in the accompanying drawing 1, comprising: a process recording section 130, wherein write down a plurality of processes, for example process 1, process 2 ... the process record of each among the process n.In the process of the process shown in Fig. 11 record, comprise the resource index 131 of process 1, the essential information 132 of process 1, and the context 133 working time of process 1.Specifically, the essential information 132 of process 1 for example comprises title, parent process, memory database address of process 1 etc.; The resource index 131 of process 1 for example comprises by all shared resources of process, and it is by obtaining the resource index information of described relevant resource occupation alternately with system resource part 135; Write down each the thread TC 1 in the process 1 working time in the context 133, TC 2 ..., the thread context of TC m, for example register value, timer setting, priority or the like.In addition, in kernel mode, also comprise a kernel portion 140 and some drivers 150, wherein in kernel portion 140, for example further can comprise file system management 141, I/O management 142, internal memory/virtual memory management 143... process/thread is managed 144 functional parts such as grade.More than the relevant portion that relates to prior art of the present invention is described, should be understood that for illustrative purposes some simplification have been done by the system shown in the accompanying drawing 1.
According to the present invention, a kind of method and corresponding system that can carry out the dormancy processing to individual process proposed.With reference to the accompanying drawings 2, wherein schematically shown structural drawing according to process sleeping/waking of the present invention system.
In process sleeping/waking according to the present invention system 200, mainly comprise: original read/write driver (RRWD) 230; Wrapper (Wrapper) 240; System interface patch parts (Shell patch SP) 210; Preferably, can also comprise backup/restoration parts (BRC) 250.In this external process sleeping system, also comprise one first external memory storage 240 (for example, the hard disk of support ordinary file system, or the storer on the hard disk), be used to preserve the file of sleeping process; An internal storage 260 (internal memory) has wherein been preserved the process context data that calls for central processing unit (CPU); And external backup storer 270 is as backup database (for example, supporting the hard disk of ordinary file system), is used to preserve the file of the sleeping process of backup.
The following specifically describes according to each functions of components in the process sleeping/waking of the present invention system 200 and the corresponding method step realized.Particularly, below with process 1 be example describe according to of the present invention to individual process dormancy disposal route and corresponding system and the process of dormancy waken up to continue to use the method and the corresponding system of this process.Similarly, the method according to this invention and system can realize a plurality of processes whiles or the dormancy of order implementation process are handled and corresponding process wake up process.
There are three class data to handle.RRWD dumps to hard disk (saving as file) with the process context from internal memory, and, revise the process content to continue to use the process of dormancy.BRC will use backup database to come the process of backup/restoration dormancy.
I, original read/write driver (Raw Read/Write Driver RRWD)
The described original read/write driver 230 of design is a kernel driver according to the present invention, is used to read/revise whole address spaces of all consumer process/threads and hangs up/wake up all consumer process/threads.Described original read/write driver 230 with wherein stored contextual internal storage 260 reciprocations of process, on the one hand, when individual process is carried out sleep operation, the process context data of being preserved in the storer 260 is read, and dump in the storer 240 on the hard disk as the file of a sleeping process, on the other hand, when sleeping process is carried out wake operation, Wrapper context in storer 260 is made amendment to be used for the wake operation of sleeping process, as shown in Figure 2.
Especially, carrying out according to of the present invention when individual process is carried out dormancy and handled, RRWD 230 can be with each process, and for example the file as a sleeping process 1 dumps in the hard disk of computer system process 1 all contexts in internal memory by carrying out following steps.Referring to accompanying drawing 3, wherein be schematically illustrated in the process of sleeping process, the synoptic diagram of contextual process of the process 1 of dormancy is wanted in unloading:
(1) RRWD 230 dumps to all the elements in 1 user's space of the process in the internal memory respectively in the hard disk of computing machine.All the elements in the user's space of process 1 comprise: the code of the storehouse of process 1, process 1, the data of process 1 and process 1 corresponding address in internal memory; Dynamic link library (DLL)/Lib, kernel interface.
(2) RRWD record dumps on the hard disk by shared all resources of process 1 and with it.Wherein, comprise by process 1 all shared resources: the essential information of process 1, for example comprise title, parent process of process 1 etc., and about the resource description of process 1 (for example content of resource index and shared resource).
(3) RRWD arrives hard disk with context spool working time of process 1.Wherein, comprised each the thread TC 1 in the process 1 working time of process 1 in the context, TC2 ..., the thread context of TC m, for example register value, timer setting, priority or the like.
Should be understood that the unloading of above three partial data order on the life period not, can carry out successively, also can carry out simultaneously.
As shown in Figure 3, when individual process being carried out in the process of dormancy, after the step of hard disk, can there be the file of a sleeping process 1 in the context spool of process in the internal memory 1 in hard disk.Comprise in the file of this sleeping process 1:
(1), wherein, title, parent process, memory database address of process 1 etc. have been write down in the essential information of process 1 about the data of process 1 essential information and resource description; And the resource description data of process 1 have comprised the content of resource index and shared resource;
(2) about context data working time of process 1, wherein, context data working time of process 1 has comprised each the thread TC 1 in the process 1, and TC 2 ..., the thread context of TC m, for example register value, timer setting, priority or the like;
(3) data of describing about the user's space of process 1 wherein, as mentioned above, have write down process 1 in all the elements of its user's space and the address that is associated.
In addition, in the process of the process of dormancy being waken up according to the present invention, RRWD can revise the context of Wrapper.It reverts to sleeping process by internally depositing into direct modification of row with context working time of Wrapper.The description that detailed process is described in reference to the Wrapper part is elaborated.
II、Wrapper
Wrapper is a kind of vertical application that is used to carry out to the processing of sleeping process, and it is designed to part and revises its context as target process, comprising process title, user's space, system resource, Thread Count; And utilize RRWD to revise remaining information then, comprise thread context, parent process, priority, and at last remove the Wrapper code and realize wake up process sleeping process from user's space.Wrapper will read the unloading file of sleeping process and when Wrapper moves, and be the context of sleeping process with himself contextual modifications.
Wrapper moves when the user wishes to recover to use sleeping process.As shown in Figure 2, Wrapper and the storer 240 in hard disk carry out alternately, and by the sleeping process file of being preserved in the reference-to storage 240, and the context of Wrapper is set to the context of sleeping process.Its course of work is by carrying out detailed description as described below referring to accompanying drawing 4:
Referring to accompanying drawing 4, wherein show when Wrapper is loaded into internal memory the context mirror image of Wrapper process in internal memory.For simplicity's sake, storehouse, code and the data of Wrapper process constructed according to the invention shown in the single square frame, and are supposed also that here Wrapper has only a thread herein.
Similarly, in the Wrapper context shown in Figure 4, can see that in user model, the user's space of Wrapper also comprises: the storehouse of Wrapper, code and data; And and kernel between kernel interface.And Wrapper is in kernel mode, comprised the shared resource of Wrapper, shared resource index, essential information and working time context.
(1) essential information of recovery sleeping process
Wrapper at first recovers the essential information of process 1 according to the file that dumps to the sleeping process in the hard disk in the process to the individual process dormancy.That is to say,, the essential information of Wrapper is revised as the content of process 1, for example process title according to the content of the sleeping process 1 in the sleeping process file of unloading in the hard disk.
Referring to accompanying drawing 5, wherein schematically shown according to the present invention in the sleeping process wakeup process, in the step of the essential information of Wrapper recovery sleeping process, the contextual synoptic diagram of process 1 and Wrapper.
By this step, can see after comparative drawings figs 4 and accompanying drawing 5: by at first recovering the essential information of process 1, the initial Wrapper context shown in the accompanying drawing 4 becomes the process 1﹠amp shown in the current accompanying drawing 5; The context of Wrapper.
(2) recover the shared system resource of sleeping process
Wrapper is from dumping to the process to the individual process dormancy in the file of the sleeping process in the hard disk, and inquiry is by the shared whole system resources of sleeping process and use the system resource of described sleeping process again.
Referring to accompanying drawing 6, wherein schematically shown according to the present invention in the sleeping process wakeup process, Wrapper recovers in the step of the shared system resource of sleeping process, the contextual synoptic diagram of process 1 and Wrapper.
By this step, after comparative drawings figs 5 and accompanying drawing 6, can further obtain: at the process 1﹠amp shown in the accompanying drawing 6; In the context of Wrapper, the initial shared system resource of Wrapper has become the shared system resource of sleeping process 1, and the resource index among the initial Wrapper also become the resource index of sleeping process 1.
In addition, preferably,, then point out user's fault and withdraw from wakeup process sleeping process if current system can not satisfy the demand of whole resource application.
(3) user's space of recovery sleeping process
Wrapper finds out the idle address space in the user's space of sleeping process, and current code is moved to idle address space.
Except that the kernel interface module,, read all the elements in the user's space of sleeping process and cover on the corresponding address of Wrapper user's space from process, dumping in the file of the sleeping process in the hard disk to the individual process dormancy.
Referring to accompanying drawing 7, wherein schematically shown according to the present invention in the sleeping process wakeup process, in the step of the user's space content of Wrapper recovery sleeping process, the contextual synoptic diagram of process 1 and Wrapper.
By this step, after comparative drawings figs 6 and accompanying drawing 7, can further obtain: at the process 1﹠amp shown in the accompanying drawing 7; In the context of Wrapper, the most contents of sleeping process 1 under user model, for example storehouse of process 1, code, data, and the content of the DLL/Lib of process 1 has all obtained recovery.
(4) thread context of recovery sleeping process
In this step, Wrapper dumps in the file of the sleeping process in the hard disk from the process to the individual process dormancy, reads the number of threads of sleeping process 1, and starts identical number of threads.
Then, Wrapper hangs up all threads to system's application, comprises main thread.
After this step, the context of Wrapper is partly reverted to the context of sleeping process.Then, RRWD is the contextual modifications of each thread the context of dormancy thread, and recovers some key messages, for example parent process etc.
Last step is to remove the content of Wrapper from user's space.At this moment, originally the process context of Wrapper is replaced by the context of process 1 fully, and i.e., the sleeping process context is recovered fully.If all threads of RRWD wakeup process 1, then sleeping process will be continued to use.
Referring to accompanying drawing 8, wherein schematically shown according to the present invention in the sleeping process wakeup process, in the step of all thread context of Wrapper recovery sleeping process, the contextual synoptic diagram of process 1 and Wrapper.
By this step, after comparative drawings figs 7 and accompanying drawing 8, can further obtain: at the process 1﹠amp shown in the accompanying drawing 8; In the context of Wrapper, initially only have a thread and return to and realize that sleeping process 1 all threads are recovered fully by Wrapper.That is to say, after the step of finishing accompanying drawing 8, realized waking up and can make sleeping process after obtaining waking up, be continued to use sleeping process.
III backup/restoration parts (Backup ﹠amp; Restore Component BRC)
In a preferred embodiment of the invention, can also comprise backup/restoration parts (BRC), be used for preserving all process contexts automatically with cycle regular hour, so that computer system break down or the situation of closing unusually under, the content that can utilize the latest content of the process of being preserved to come recovering process or sleeping process.These parts can trigger by timer or User Preferences (preference), and for example, it will call RRWD every five minutes automatically to preserve all process contexts.When computer starting, if last the closing of computing machine is unusual, computer crashes and when restarting for example, then it can recover last all contexts of process of preserving according to user's setting.
As shown in Figure 2, BRC and storer 240 carry out alternately, are saved in automatically in the backup database 270 with the sleeping process file that will dump in process dormancy processing procedure in the hard disk at interval at regular intervals.
IV.Shell Patch (system interface patch) (SP).
SP is the patch (patch) of desktop platform that is used for call back function (call back) function of Linux (for example Gnome) or Windows Explorer (form browser).It concentrates in user interface (UI) design: can be when the user imports hot key (for example " Alt-F5 "), triggering is used for the dormancy of current process to be handled, and if the user import another hot key (for example " Ctrl-Tab ") then can list all sleeping process in the hard disk.It increases by one in Shell will trigger the context menu item that continues to use the appointment process.
Refer again to accompanying drawing 2, SP provides interface mutual between process sleeping system and the operating system.By described SP, the user can select to treat the process of dormancy or process to be waken up; When the user selected certain to wait to have a holiday process, SP was by calling RRWD to implementing thread sleep; When the user selected to treat wakeup process, SP woke up to continue use sleeping process by selecting Wrapper and RRWD, and when needs backed up all process contexts, SP came backup process etc. by selecting BRC.
Below by with reference to the accompanying drawings 2 and in conjunction with the accompanying drawings the process flow diagram of 9-12 concrete steps according to process sleeping/waking process of the present invention are described.
Accompanying drawing 9 schematically shows the process flow diagram according to process sleep procedure of the present invention.Referring to accompanying drawing 9, at first when the process sleep procedure that starts individual process, in step S905, RRWD will hide all windows that (minimizing) specifies the process that will carry out dormancy.Then, in step S910, RRWD should the appointment process hang up by all threads of hanging up this process.Then in step S915, RRWD will specify the context spool of process of dormancy in the hard disk of computing machine.Particularly, in this step, RRWD dumps to the context of following appointment sleeping process in the hard disk of computing machine: (1) dumps to all the elements in the user's space of appointment process in the internal memory in the hard disk of computing machine, for example, all the elements in the user's space of appointment process comprise: storehouse, code, the data of specifying process; Dynamic link library (DLL)/Lib, kernel interface.(2) inquiry dumps on the hard disk by shared all resources of appointment process and with it.Wherein, all resources shared by the appointment process comprise: the essential information of specifying process, for example comprise the title, parent process, address space inlet of appointment process etc., and about specifying the resource description of process, for example the content of resource index and shared resource.(3) will specify the process status information of process, for example working time, context spool was to hard disk.Wherein, comprised each the thread TC 1 in the process described working time in the context, TC 2 ..., the thread context of TC m, for example register value, timer setting, priority or the like.At last, in step S920, stop this process, i.e. process dormancy success, and discharge all shared resources of this appointment process.
Accompanying drawing 10 schematically shows the process flow diagram according to sleeping process wakeup process of the present invention.Referring to accompanying drawing 10, the simple course of work of sleeping process wakeup process is as follows.In step S1005, Wrapper will recover the sleeping process context.In the contextual step of described recovery sleeping process, further comprise following substep: (1) recovers the essential information of sleeping process.That is to say, according to the content of the sleeping process in the sleeping process file of unloading in the hard disk, revise its essential information, for example the process title; (2) recover the shared system resource of sleeping process; (3) user's space of recovery sleeping process; (4) the time context that resumes operation comprises the context of each thread; (5) recover other essential information, for example parent process (if available); And (6) RRWD removes the Wrapper code by discharging the shared address area of Wrapper from user's space.Then, after successfully realizing the contextual step of described recovery sleeping process, in step S1010, RRWD will wake this sleeping process up.And in step S1015, RRWD will show all windows of sleeping process at last.Thus, successfully realized waking up to sleeping process.
Accompanying drawing 11,12 schematically shows the process flow diagram according to process backup/restoration process of the present invention.This process backup/restoration process is the additional and expanded function of process sleep procedure preferably, it is in the process of the process of carrying out dormancy, automatically the content that will dump in the process sleep procedure on the hard disk is carried out automated back-up by certain time interval, and computer system break down or the situation of closing unusually under, the content that can utilize the latest content of the process of being preserved to come recovering process or sleeping process.
Referring to accompanying drawing 11, the simple course of work of process backup is as follows:
At first, in step S1105, carry out calling to the process sleep procedure.In this step, be actually process has been carried out process dormancy all processes (Fig. 9 description).Next, in step S1110, the process unloading file that BRC will preserve on hard disk and backup in the nonvolatile memory by the All Files that process is opened.And, computer run break down or the situation of closing unusually under, in step S1115, the calling process wakeup process, promptly the process described of Figure 10 successfully realizes backup thus.
Accompanying drawing 12 schematically shows the process flow diagram according to process rejuvenation of the present invention.Referring to accompanying drawing 12, the simple process process that process is recovered is as follows:
At first in step S1205, BRC will duplicate All Files to the original position from backup database, and it is with Overwrite existing files.That is to say the All Files that the process unloading file on the recovery hard disk and this process are opened.
Then, in step S1210, BRC is by the calling process wakeup process, i.e. the process of Figure 10 description is come recovering process.
Below in conjunction with the accompanying drawings, each embodiment of method and system according to the process sleeping/waking that the present invention is directed to individual process is described in detail, but above these embodiment only are examples, and those skilled in the art can make variations and modifications within the spirit and scope of the present invention.Therefore, the invention is not restricted to these embodiment, scope of the present invention is limited by the claim of enclosing and is as the criterion.