CN1332305C - Module life period managing method - Google Patents

Module life period managing method Download PDF

Info

Publication number
CN1332305C
CN1332305C CNB2005100232527A CN200510023252A CN1332305C CN 1332305 C CN1332305 C CN 1332305C CN B2005100232527 A CNB2005100232527 A CN B2005100232527A CN 200510023252 A CN200510023252 A CN 200510023252A CN 1332305 C CN1332305 C CN 1332305C
Authority
CN
China
Prior art keywords
module
module object
loading
reference count
operating system
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CNB2005100232527A
Other languages
Chinese (zh)
Other versions
CN1645327A (en
Inventor
梁宇洲
苏翼鹏
陈榕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
KETAI CENTURY SCIENCE AND TECHNOLOGY Co Ltd SHANGHAI
Original Assignee
KETAI CENTURY SCIENCE AND TECHNOLOGY Co Ltd SHANGHAI
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by KETAI CENTURY SCIENCE AND TECHNOLOGY Co Ltd SHANGHAI filed Critical KETAI CENTURY SCIENCE AND TECHNOLOGY Co Ltd SHANGHAI
Priority to CNB2005100232527A priority Critical patent/CN1332305C/en
Publication of CN1645327A publication Critical patent/CN1645327A/en
Application granted granted Critical
Publication of CN1332305C publication Critical patent/CN1332305C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The present invention relates to a module life period managing method which comprises a module loading process and a module unloading process, wherein the loading process comprises the steps that an application program proposes a request of loading a module; the loading processing is carried out for the module object by an operation system according to the situation; the application program establishes a corresponding module view according to an interface pointer of the module; the unloading process comprises the steps that the module view is deleted by the application program, and a request for unloading the module is proposed; unloading processing is carried out for the module object by the operation system according to the reduction of the reference count of the module object and the situation. When the module life period managing method with the structure, loading is needed only once; simultaneously, modules can be unloaded under the condition of no reference; therefore, the modules can not be unloaded in advance; besides, the phenomenon that the modules are immediately unloaded when used by users can not happen; simultaneously, other module resources can also be allowed to quote so the existing resources are effectively utilized.

Description

Module life period managing method
Technical field
The present invention relates to the computer operating system field, particularly the operating system module management domain specifically is meant a kind of module life period managing method.
Background technology
Module all refers to the representation of executable image file (comprising executable file and dynamic base) in operating system in computer operating system.
The life cycle of legacy operating system module is by the control of module loading bin, and for example Microsoft is the loading that carries out module by LoadLibrary API, carries out the unloading of module by FreeLibrary API.These implementation methods all need initiatively calling system API Unload module of user.This will cause quoting the module resource of another process, because can't learn when unloaded the module of that process is.In addition, if after the module pointer passes to a plurality of users, will be difficult to determine when this unloads this module.If unloading in advance can cause using the user of this module to make mistakes; If last unloading, can make when not having the user to use still resources such as committed memory.
Summary of the invention
The objective of the invention is to have overcome above-mentioned shortcoming of the prior art, a kind of module life period managing method based on reference count is provided, can carry out disposable loading, can count control automatically, and safety unloads when final no external reference external reference.
In order to realize above-mentioned purpose, module life period managing method of the present invention is as follows:
This module life period managing method comprises loading process and the uninstall process of module in operating system, and its principal feature is that described loading process may further comprise the steps:
(1) application program proposes the request of loading module to operating system;
(2) operating system is searched system's global resource according to the request of application program, if this module does not exist, then carries out the loading of this module object and handles; If this module exists, then increase this module object reference count and handle, may further comprise the steps:
(a) if another module object relies on this module object to be quoted, the reference count of then this module object being preserved increases by 1;
(b) if an application program is set up module view to be quoted this module object, the reference count of then this module object being preserved increases by 1;
(3) operating system is that application program is created corresponding module view according to the dependence of this module;
(4) operating system is returned the interface pointer of corresponding module to application program;
Described uninstall process may further comprise the steps:
(1) application program proposes to reduce the request of corresponding module reference count to operating system;
(2) operating system reduces module object reference count processing accordingly according to the request of application program, may further comprise the steps:
(a) if another module object cancellation is quoted the dependence of this module object, the reference count of then this module object being preserved reduces 1;
(b) if application program removing module view cancellation to the quoting of this module object, the reference count of then this module object being preserved reduces 1;
(3) if this module object reference count meets unloading condition, removing module view then, and the unloading of carrying out module object is handled.
The loading of the module object of this module life period managing method is handled and be may further comprise the steps:
(21) operating system reads the module object of appointment according to the module name of application requests loading from storage system, and with its loading system;
(22) reference count that this module object is preserved is initially set 1;
(23), then finish the loading of this module object and handle if this module does not rely on and quotes other modules;
(24) quote other modules if this module relies on, then operating system is searched system's global resource, if this depended module does not exist, then recurrence is carried out from the loading processing of this depended module object of above-mentioned steps (21) beginning; If this depended module exists, then increase this depended module object reference counting and handle, all dispose until all depended modules, then finish the loading of this module object and handle.
The storage system of this module life period managing method can be file system or other memory devices.
The unloading of the module object of this module life period managing method is handled and be may further comprise the steps:
(31) this module object is unloaded and reclaims its shared system resource from system;
(32), then finish the unloading of this module object and handle if this module does not rely on and quotes other modules;
(33) if relying on, this module quotes other modules, then operating system reduces the processing of depended module object reference counting, and judge whether this depended module object reference counting meets unloading condition, if meet unloading condition, then recurrence is carried out from the unloading processing of this depended module object of above-mentioned steps (31) beginning, all dispose until all depended modules, then finish the unloading of this module object and handle.
The module object unloading condition of this module life period managing method for this module object preserve reference count be 0.
The module of this module life period managing method can be executable file in the operating system or dynamic link library.
Adopted the module life period managing method of this invention,, and adopted the module view mode that it is quoted, therefore only needed disposable loading because module is to be loaded in the global space; Simultaneously because this method is based on reference count, therefore module is only when quoting, just can be unloaded, make that module can be not unloaded in advance, and can be unloaded immediately when not having the user to use, also can allow to quote other module resource simultaneously, thereby effectively utilize existing resource.
Description of drawings
Fig. 1 is that module object and module view concern synoptic diagram.
Fig. 2 is the process flow diagram of module loading process of the present invention.
Fig. 3 is the process flow diagram of module uninstall process of the present invention.
Fig. 4 be have between the module object of dependence and and module view between concern synoptic diagram.
Embodiment
In order more to be expressly understood technology contents of the present invention, describe in detail especially exemplified by following examples.
See also shown in Figure 1ly, main resource has two in the module life period management: module object (Module), module view (Module View).Module object is intrasystem global resource, when the process load-on module, need quote the module object of the overall situation and it is mapped in the virtual address space of process, and we call module view to process to this adduction relationship of module object.
Module object and module view are the relations of one-to-many, a module may be loaded by a plurality of processes simultaneously, only can be loaded once (loading for the first time) but same module object is actual before unloading, later process load request just makes the reference count of module object increase.But different processes all can be created module view separately in process when loading same module, these module views have kept quoting module object.
See also shown in Figure 2ly again, this figure is the module loading process, and wherein application program proposes the request of loading module to operating system by calling system APIEzLoadModule ().The module name that operating system is loaded according to request loads the module of appointment from file system or other equipment, and returns the interface pointer of this module.At this moment, the reference count of module is 1.
Use if the module interface pointer is passed to other users, user of then every transmission will add 1 to the reference count of module.When no longer needing to use the module interface pointer, reduce the reference count of a module.
If the reference count of module is 0, will enter the module uninstall process.
In loading process,, then can cause the module that loadings recursively relied on if any relying on other modules, and a reference count (reference count to institute's Depending module adds 1) of reservation institute Depending module.
See also shown in Figure 3ly again, this figure is the module uninstall process, wherein, if find that the reference count of this module is 0 when reducing the module reference count, will carry out the module unloading.
Uninstall process probably can be in two steps:
(1) unloads this module and recovery system resource;
(2) module that is relied on is reduced by a reference count.
For (2) step (reducing the reference count of institute's Depending module), might cause chain module unloading.
" with glad " operating system is the loading that carries out module by EzLoadModule API, just quote its reference count added 1 (calling the AddRef method of IModule interface) for much more every one, whenever less one just quote its reference count subtracted 1 (calling the Release method of IModule interface).When reference count is 0, carry out the unloaded operation of module automatically.
See also shown in Figure 4ly again, this chart is understood the adduction relationship between this intermodule and module and module view, and the life cycle of module object is managed based on reference count.A module object may be referred to by two aspects: the one, and module view, the 2nd, depend on other module object of this module object.
As can be seen from the figure, module object for c.dll, its reference count is kept by module object b.dll and module view c.dll, the reference count of module object b.dll is kept by module object a.dll and module view b.dll, and the reference count of module object a.dll is then kept by module view a.dll.
Simultaneously, also use similar reference count relation between the module view, module view b.dll has kept the reference count of module view c.dll, module view a.dll has kept the reference count of module view b.dll, and the reference count of module view a.dll is then kept by the requestor who loads a.dll.
Above-mentioned reference count relation has guaranteed that module object and module view can be according to the reference count relation by correct loading and unloadings.When the reference count of module view a.dll is zero, it will discharge the reference count of module view b.dll and module object a.dll, thereby cause chain reference count reaction on the reference count chain, finally uninstall whole module chain.
In this instructions, the present invention is described with reference to its certain embodiments.But, still can make various modifications and conversion obviously and not deviate from the spirit and scope of the present invention.Therefore, instructions and accompanying drawing are regarded in an illustrative, rather than a restrictive.

Claims (7)

1, a kind of module life period managing method comprises loading process and the uninstall process of module in operating system, it is characterized in that described loading process may further comprise the steps:
(1) application program proposes the request of loading module to operating system;
(2) operating system is searched system's global resource according to the request of application program, if this module does not exist, then carries out the loading of this module object and handles; If this module exists, then increase this module object reference count and handle, may further comprise the steps:
(a) if another module object relies on this module object to be quoted, the reference count of then this module object being preserved increases by 1;
(b) if an application program is set up module view to be quoted this module object, the reference count of then this module object being preserved increases by 1;
(3) operating system is that application program is created corresponding module view according to the dependence of this module;
(4) operating system is returned the interface pointer of corresponding module to application program;
Described uninstall process may further comprise the steps:
(1) application program proposes to reduce the request of corresponding module reference count to operating system;
(2) operating system reduces module object reference count processing accordingly according to the request of application program, may further comprise the steps:
(a) if another module object cancellation is quoted the dependence of this module object, the reference count of then this module object being preserved reduces 1;
(b) if application program removing module view cancellation to the quoting of this module object, the reference count of then this module object being preserved reduces 1;
(3) if this module object reference count meets unloading condition, removing module view then, and the unloading of carrying out module object is handled.
2, module life period managing method according to claim 1 is characterized in that, the loading of described module object is handled and be may further comprise the steps:
(21) operating system reads the module object of appointment according to the module name of application requests loading from storage system, and with its loading system;
(22) reference count that this module object is preserved is initially set 1;
(23), then finish the loading of this module object and handle if this module does not rely on and quotes other modules;
(24) quote other modules if this module relies on, then operating system is searched system's global resource, if this depended module does not exist, then recurrence is carried out from the loading processing of this depended module object of above-mentioned steps (21) beginning; If this depended module exists, then increase this depended module object reference counting and handle, all dispose until all depended modules, then finish the loading of this module object and handle.
3, module life period managing method according to claim 2 is characterized in that, described storage system is file system or other memory devices.
4, module life period managing method according to claim 1 is characterized in that, the unloading of described module object is handled and be may further comprise the steps:
(31) this module object is unloaded and reclaims its shared system resource from system;
(32), then finish the unloading of this module object and handle if this module does not rely on and quotes other modules;
(33) if relying on, this module quotes other modules, then operating system reduces the processing of depended module object reference counting, and judge whether this depended module object reference counting meets unloading condition, if meet unloading condition, then recurrence is carried out from the unloading processing of this depended module object of above-mentioned steps (31) beginning, all dispose until all depended modules, then finish the unloading of this module object and handle.
5, module life period managing method according to claim 4 is characterized in that, described module object unloading condition for this module object preserve reference count be 0.
6, module life period managing method according to claim 1 is characterized in that, described module object unloading condition for this module object preserve reference count be 0.
7, module life period managing method according to claim 1 is characterized in that, described module is executable file or the dynamic link library in the operating system.
CNB2005100232527A 2005-01-12 2005-01-12 Module life period managing method Expired - Fee Related CN1332305C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005100232527A CN1332305C (en) 2005-01-12 2005-01-12 Module life period managing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005100232527A CN1332305C (en) 2005-01-12 2005-01-12 Module life period managing method

Publications (2)

Publication Number Publication Date
CN1645327A CN1645327A (en) 2005-07-27
CN1332305C true CN1332305C (en) 2007-08-15

Family

ID=34875810

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005100232527A Expired - Fee Related CN1332305C (en) 2005-01-12 2005-01-12 Module life period managing method

Country Status (1)

Country Link
CN (1) CN1332305C (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100357889C (en) * 2006-08-03 2007-12-26 上海科泰世纪科技有限公司 Method for managing long-distance structural components service cycle with class as unit
CN100464299C (en) * 2006-08-08 2009-02-25 北京飞天诚信科技有限公司 Method for updating computer software
CN114510334A (en) * 2022-02-16 2022-05-17 阿波罗智能技术(北京)有限公司 Class instance calling method and device, electronic equipment and automatic driving vehicle

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6003095A (en) * 1996-10-31 1999-12-14 International Business Machines Corporation Apparatus and method for demand loading a dynamic link library
US6385567B1 (en) * 1997-07-31 2002-05-07 Microsoft Corporation Program-module substitution in a program loader for multiple-platform emulation
JP2002149411A (en) * 2000-11-09 2002-05-24 Nec Microcomputer Technology Ltd Multi-function smart card and method for managing the same
CN1512340A (en) * 2002-12-31 2004-07-14 北京科泰世纪科技有限公司 Packaging method for intelligent pointer of calling structure object function

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6003095A (en) * 1996-10-31 1999-12-14 International Business Machines Corporation Apparatus and method for demand loading a dynamic link library
US6385567B1 (en) * 1997-07-31 2002-05-07 Microsoft Corporation Program-module substitution in a program loader for multiple-platform emulation
JP2002149411A (en) * 2000-11-09 2002-05-24 Nec Microcomputer Technology Ltd Multi-function smart card and method for managing the same
CN1512340A (en) * 2002-12-31 2004-07-14 北京科泰世纪科技有限公司 Packaging method for intelligent pointer of calling structure object function

Also Published As

Publication number Publication date
CN1645327A (en) 2005-07-27

Similar Documents

Publication Publication Date Title
US9292437B2 (en) Optimizing virtual memory allocation in a virtual machine based upon a previous usage of the virtual memory blocks
US8984530B2 (en) Queued message dispatch
US20140156735A1 (en) Distributed processing method and information processing apparatus
WO2003102772A3 (en) Business continuation policy for server consolidation environment
WO2012134692A2 (en) Techniques to manage file conversions
CN110196770B (en) Cloud system memory data processing method, device, equipment and storage medium
US20120185593A1 (en) License redistributing method, moderator and license controlling system thereof
WO2016118504A1 (en) Memory descriptor list caching and pipeline processing
CN1332305C (en) Module life period managing method
CN109726007A (en) A kind of container layout quota management method and device and container arranging system
US20080307014A1 (en) Compressing files using a minimal amount of memory
CN112749062A (en) Server program monitoring method and device, computer equipment and storage medium
CN110889880A (en) Map processing method, device, equipment and storage medium
US20170147508A1 (en) Device, system and method of accessing data stored in a memory
JP5981050B2 (en) Application program management apparatus and management method
CN111090627B (en) Log storage method and device based on pooling, computer equipment and storage medium
US20060031607A1 (en) Systems and methods for managing input ring buffer
JP4838884B2 (en) Software-based spread spectrum signal processing
CN113037871A (en) Conference call recovery method, device, system, electronic equipment and readable storage medium
CN113760318A (en) Information processing method, information processing apparatus, server, and storage medium
US8046543B2 (en) Selectively retaining a topmost subpool expansion to prevent thrashing
CN112950106B (en) Stock stocking method and device for transfer vehicle, electronic equipment and storage medium
US20170099350A1 (en) Apparatus and method for transmitting mass data
CN113259261B (en) Network flow control method and electronic equipment
CN117407186A (en) Task execution method, device, electronic equipment and computer storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20070815

Termination date: 20200112