CN103246608A - Method and device for distributing storage space - Google Patents

Method and device for distributing storage space Download PDF

Info

Publication number
CN103246608A
CN103246608A CN2012100224573A CN201210022457A CN103246608A CN 103246608 A CN103246608 A CN 103246608A CN 2012100224573 A CN2012100224573 A CN 2012100224573A CN 201210022457 A CN201210022457 A CN 201210022457A CN 103246608 A CN103246608 A CN 103246608A
Authority
CN
China
Prior art keywords
capacity
storage space
difference
instruction
compared
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.)
Pending
Application number
CN2012100224573A
Other languages
Chinese (zh)
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.)
Lenovo Beijing Ltd
Original Assignee
Lenovo Beijing Ltd
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 Lenovo Beijing Ltd filed Critical Lenovo Beijing Ltd
Priority to CN2012100224573A priority Critical patent/CN103246608A/en
Publication of CN103246608A publication Critical patent/CN103246608A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for distributing a storage space. The storage space uniquely corresponds to a service at a server side, and the service is called through writing of data into the storage space and/or reading of the data from the storage space. The method comprises the steps of distributing the storage space according to a preset first capacity when initializing the storage space; and receiving a command which is used for modifying the first capacity into a second capacity, so that the storage space can be distributed again according to the second capacity at the next time when the storage space is initialized. Therefore, during operation of a system, the storage space can be distributed dynamically according to actual demands by the aid of the method and the device, the memory space of the system can be used fully and efficiently, and the operation speed of the system can be improved.

Description

Be used for distributing the method and apparatus of a storage space
Technical field
The present invention relates to field of computer technology, more specifically, the present invention relates to a kind of for the method and apparatus that distributes a storage space.
Background technology
In recent years, the electronic equipment such as panel computer (PAD), mobile phone, multimedia player, PDA(Personal Digital Assistant) is universal all the more.In the use of various electronic equipments, the distribution of storage space is of paramount importance beyond doubt.
In the prior art, in order to accelerate system speed, application for the storage space of same type, usually take the mode of carrying out in batch, namely during the initialization of system, rule of thumb estimate the memory headroom of the same capability that obtains to all memory allocation of same type, the memory headroom of 1M for example, and each storage space is not handled respectively, and after entering operational process, their memory headroom also can't dynamically be adjusted according to actual needs.
In practice, owing to the several particular memory space in the storage space of considering same type may be increasing along with the quantity of information that increasing of application causes needs to be preserved, so we need distribute the memory headroom of larger capacity, for example memory headroom of 4M for all storage spaces of this type.At this moment, suppose always to co-exist in the storage space of 40 same types in system, the memory headroom of 2 specific memory space requirement 4M is wherein only arranged, all the other 38 storage spaces do not need the memory headroom of 4M and only need the memory headroom of 1M to get final product.Yet, in the case, owing to all will cooperating these 2 specific memory spaces, remaining 38 storage space is assigned with the memory headroom of 4M, thus will waste the memory headroom of 38 * (4M-1M)=114M, and finally cause the travelling speed of system slack-off.
Summary of the invention
In order to solve the problems of the technologies described above, according to an aspect of the present invention, provide a kind of for the method for distributing a storage space, described storage space is served corresponding to one of server end uniquely, by writing data to described storage space and/or reading data from described storage space, call described service, it is characterized in that, described method comprises: when described storage space is carried out initialization, distribute described storage space according to first capacity that sets in advance; And receive for described first capacity is revised as the instruction of second capacity, in order to when described storage space being carried out initialization, redistribute described storage space according to described second capacity next time.
According to a further aspect in the invention, provide a kind of for the equipment that distributes a storage space, described storage space is served corresponding to one of server end uniquely, by writing data to described storage space and/or reading data from described storage space, call described service, it is characterized in that, described equipment comprises: allocation units, be used for when described storage space is carried out initialization, distributing described storage space according to first capacity that sets in advance; And the command reception unit, be used for receiving the instruction that is used for second capacity that described first capacity is revised as, so that when described storage space being carried out initialization, described allocation units are redistributed described storage space according to described second capacity next time.
Compared with prior art, employing is according to the method and apparatus for distribution one storage space of the present invention, can when initialization, come the memory allocated space according to the capacity that sets in advance, adjust this capacity then according to actual needs, so that when initialization next time, redistribute described storage space according to the capacity after adjusting.Therefore, in the operational process of system, the present invention can be according to actual needs memory allocated space dynamically, in order to utilize the memory headroom of system fully, efficiently, thus the travelling speed of Hoisting System.
Other features and advantages of the present invention will be set forth in the following description, and, partly from instructions, become apparent, perhaps understand by implementing the present invention.Purpose of the present invention and other advantages can realize and obtain by specifically noted structure in instructions, claims and accompanying drawing.
Description of drawings
Accompanying drawing is used to provide further understanding of the present invention, and constitutes the part of instructions, is used from explanation the present invention with embodiments of the invention one, is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 illustrates according to of the present invention for the method for distributing a storage space.
Fig. 2 illustrates according to of the present invention for the equipment that distributes a storage space.
Fig. 3 illustrates the method that is used for distributing a storage space according to first embodiment of the invention.
Fig. 4 illustrates the equipment that is used for distributing a storage space according to first embodiment of the invention.
Fig. 5 illustrates the method that is used for distributing a storage space according to second embodiment of the invention.
Fig. 6 illustrates the method that is used for distributing a storage space according to third embodiment of the invention.
Fig. 7 illustrates the equipment that is used for distributing a storage space according to third embodiment of the invention.
Fig. 8 illustrates the method that is used for distributing a storage space according to fourth embodiment of the invention.
Embodiment
Describe in detail with reference to the accompanying drawings according to each embodiment of the present invention.Here, it should be noted that in the accompanying drawings, identical Reference numeral is given had ingredient identical or similar structures and function basically, and will omit being repeated in this description about them.
Hereinafter, will describe according to of the present invention for the method and apparatus that distributes a storage space with reference to Fig. 1 and 2.
Fig. 1 illustrates according to of the present invention for the method for distributing a storage space.
The method according to this invention is used for distributing a storage space, and described storage space corresponding to a service of server end, by writing data to described storage space and/or reading data from described storage space, calls described service uniquely.Particularly, described method comprises:
In step S110, when described storage space is carried out initialization, distribute described storage space according to first capacity that sets in advance; And
In step S120, receive for described first capacity is revised as the instruction of second capacity, in order to when described storage space being carried out initialization, redistribute described storage space according to described second capacity next time.
Fig. 2 illustrates according to of the present invention for the equipment 200 that distributes a storage space.
Equipment 200 according to the present invention is used for distributing a storage space, and described storage space corresponding to a service of server end, by writing data to described storage space and/or reading data from described storage space, calls described service uniquely.Particularly, described equipment 200 comprises:
Allocation units 210 are used for distributing described storage space according to first capacity that sets in advance when described storage space is carried out initialization; And
Command reception unit 220 is used for receiving the instruction that is used for second capacity that described first capacity is revised as, so that when described storage space being carried out initialization, described allocation units are redistributed described storage space according to described second capacity next time.
This shows, employing is according to the method and apparatus for distribution one storage space of the present invention, can when initialization, come the memory allocated space according to the capacity that sets in advance, adjust this capacity then according to actual needs, so that when initialization next time, redistribute described storage space according to the capacity after adjusting.Therefore, in the operational process of system, the present invention can be according to actual needs memory allocated space dynamically, in order to utilize the memory headroom of system fully, efficiently, thus the travelling speed of Hoisting System.
Below, be that example illustrates according to embodiments of the invention with the mechanism of the Binder in Android (Android) system.
Android is a kind of open source code operating system based on Linux, is mainly used in portable electric appts.Binder mechanism is that the Android system is peculiar, and it is one of communication (IPC) mode between the Android system process.From a structural point, Android Binder uses server/customer end (server/client) communication mode, namely process provides service such as video/audio decoding, Video Capture, address book inquiry, network connection as server, and a plurality of processes are initiated services request as user end to server, to obtain needed service.That is to say, in the Android system, can create a plurality of Binder, wherein each Binder is uniquely corresponding to a service of server end, for example, the one Binder is corresponding to an active manager service (ActivityManagerService), and the 2nd Binder is corresponding to Package Manager service (PackageManagerService) etc.; By in a Binder or the 2nd Binder, writing data and/or from them, read data respectively, call ActivityManagerService or PackageManagerService, thereby comings and goings or routine package are managed.
In the prior art, when in the Android system, creating a plurality of Binder, can only come to distribute a fixing and identical memory headroom to each Binder according to a B parameter INDER_VM_SIZE (Binder virtual memory size), for example, the present value of set BINDER_VM_SIZE 1M-8k normally.Along with increasing of in portable electric appts, using, some Binder (for example, with ActivityManagerService and PackageManagerService corresponding first and second Binder respectively) need the quantity of information of preservation to become increasing, make the memory headroom of 1M-8k become and can't satisfy the normal demand of system; Simultaneously, the canned data amount may not produce any variation in other a plurality of (for example, 38) Binder.Yet, owing to do not exist in the prior art for the method and apparatus to different Binder difference storage allocation spaces, so (for example at this moment can only increase the value of B parameter INDER_VM_SIZE, be increased to 4M-32k), and all distribute the memory headroom of 4M-32k to all (2+38=40) Binder.Obviously, this will cause taking the memory headroom of 38 * ((4M-32k)-(1M-8k))=114M-912k more, thereby cause the not rich portable electric appts of memory headroom may be difficult to operate normally, finally cause system slack-off, even lose response.
Therefore, in one embodiment of the invention, the method and apparatus that adopt to be used for distributes a storage space is solved the problems referred to above that the memory headroom at the Binder of Android system distributes.
Hereinafter, will the method and apparatus that be used for to distribute a storage space according to first embodiment of the invention be described with reference to figure 3 and 4.
Fig. 3 illustrates the method that is used for distributing a storage space according to first embodiment of the invention, and Fig. 4 illustrates the equipment 200 that is used for distributing a storage space according to first embodiment of the invention.
The illustrated method that is used for distribution one storage space according to first embodiment of the invention of Fig. 3 can be applied to the illustrated equipment 200 of Fig. 4, when the actual data capacity that writes exceeds the capacity that sets in advance of this storage space in storage space with box lunch, equipment 200 is according to actual needs dynamically to Binder memory allocated space, thus the stability of Hoisting System and reliability.
With Fig. 2 illustrated according to of the present invention for the equipment 200 that distributes a storage space similarly, illustrated as Fig. 4, also comprise according to the equipment 200 of first embodiment of the invention: command reception unit 220 and allocation units 210.In addition, this equipment 200 also comprises: detect generation unit 230, be used for receiving for before described first capacity is revised as the instruction of second capacity in described command reception unit, when writing data to described storage space, detect the write error that first capacity that the capacity whether exist owing to described data exceeds described storage space produces, if and have a said write mistake, then generate the instruction that is used for second capacity that described first capacity is revised as, and described second capacity is to determine according to the capacity of described data.
Illustrated as Fig. 3, comprise according to the method for be used for distributing a storage space of first embodiment of the invention:
In step S310, when described storage space is carried out initialization, distribute described storage space according to the initial capacity that sets in advance.
When to the portable electric appts that uses Android operating system (such as, panel computer, mobile phone etc.) when carrying out the start operation, framework in the Android system (framework) be used for to be determined for a plurality of service-creations demand of a plurality of Binder one to one with it, Java this locality is called (JNI) and is created described Binder then, and to they storage allocation spaces.
For example, framework determine for first service (for example, ActivityManagerService) create a Binder and for second service (for example, PackageManagerService) demand of establishment the 2nd Binder, Java this locality is called and is created this first and second Binder then, and comes respectively to they storage allocation spaces according to first and second initial capacities that are used for this first and second Binder that set in advance.
Wherein, for example, can be according to forms such as form, file or data blocks, with first initial capacity that is used for first and second Binder that sets in advance and the storer that second initial capacity is stored in this portable electric appts.Below, be example with the form, reference table 1 is described particularly according to the first embodiment of the present invention.
In one example, these two initial capacities that set in advance can be different, and are for example as shown in table 1, and first initial capacity that is used for a Binder is 2M-16k, and second initial capacity that is used for the 2nd Binder is 1M-8k.
Table 1
Sequence number The Binder title The capacity that sets in advance
1 The one Binder 2M-16k
2 The 2nd Binder 1M-8k
... ... ...
Therefore, in the equipment 200 according to first embodiment of the invention, when described first and second Binder are carried out initialization, allocation units 210 from the form of first initial capacity that for example is used for storage and sets in advance and second initial capacity (for example, table 1) reads the numerical value of first and second initial capacities in, thereby come respectively to distribute to a Binder and the 2nd Binder the memory headroom of 2M-16k and 1M-8k accordingly.
Obviously, in another example, depend on actual needs, this first initial capacity that sets in advance also can be identical with second initial capacity, for example all is 2M-16k, so that allocation units 210 distribute identical memory headroom to first and second Binder.
In step S320, when writing data to described storage space, detect the write error that initial capacity that the capacity whether exist owing to described data exceeds described storage space produces.
After JNI has successfully created this first and second Binder, the Android system is according to the corresponding relation between Binder and the service, by kernel (Kernel) Binder that creates is managed, and monitoring is for the accessing operation of Binder (for example, write and/or read operation).
As mentioned above, in the Android system, call ActivityManagerService by writing data to a Binder, perhaps call PackageManagerService by writing data to the 2nd Binder.
For example, in the equipment 200 according to first embodiment of the invention, when when writing data to a Binder and call ActivityManagerService, detect generation unit 230 and detect and whether exist owing to the capacity that writes data exceeds the write error that the capacity of the memory headroom of a described Binder produces.If there is the said write mistake, execution in step S330 then; If there is no said write mistake, then this method end.
In step S330, generate the instruction that is used for described initial capacity is revised as current capacity, and described current capacity is to determine according to the capacity of described data.
In the equipment 200 according to first embodiment of the invention, if detecting generation unit 230 detects and exists owing to the capacity that writes data exceeds the write error that the capacity of the memory headroom of a described Binder produces, for example, if it is 3M that detection generation unit 230 detects the capacity that writes data of a Binder, it greater than first initial capacity of a Binder (namely, 2M-16k), then this moment, will overflowing of data appear writing in a Binder.At this moment, detecting generation unit 230 generates for described first initial capacity (that is, 2M-16k) is revised as the instruction of the first current capacity.Wherein, the described first current capacity is to determine according to the capacity of described data, and for example, this first current capacity can be more than or equal to the capacity that writes data.
Preferably, this first current capacity can be to be that step-length increases progressively with 1M-8k, and just greater than or equal to write the capacity of data.Particularly, when the capacity that writes data was 3M, the first current capacity can not value be 3M-24k, but value is 4M-32k, in order to avoid cause overflowing when writing data.In addition, when the capacity that writes data was 4M-32k, the first current capacity then can be 4M-32k.
In addition, if it is 256k that detection generation unit 230 detects the capacity that writes data of the 2nd Binder, it less than second initial capacity of the 2nd Binder (namely, 1M-8k), then it thinks that the memory headroom that distributes to the 2nd Binder is suitable, and needn't carry out any modification to the capacity of the 2nd Binder.
In step S340, receive for described initial capacity is revised as the instruction of current capacity, in order to when described storage space being carried out initialization, redistribute described storage space according to described current capacity next time.
In the equipment 200 according to first embodiment of the invention, command reception unit 220 receives and is used for first initial capacity of a described Binder (namely from detecting generation unit 230,2M-16k) be revised as the first current capacity (namely, instruction 4M-32k), and with the first current capacity storage in aforesaid form.
Thus, when described first and second Binder being carried out initialization, described allocation units 210 can come respectively to distribute to a Binder and the 2nd Binder the memory headroom of 4M-32k and 1M-8k according to the amended first current capacity and the second original initial capacity next time.
This shows, employing is according to the method and apparatus that is used for distributing a storage space of first embodiment of the invention, can when initialization, come the memory allocated space according to the capacity that sets in advance, detect then and whether have write error, and adjust the capacity of this storage space according to the capacity that writes data, so that when initialization next time, redistribute described storage space according to the current capacity after adjusting.Therefore, in the operational process of system, the present invention can come dynamically memory allocated space according to the capacity that writes data, in order to farthest guarantee the reasonable utilization of internal memory.
Hereinafter, will further describe the method and apparatus that be used for to distribute a storage space according to second embodiment of the invention with reference to figure 5.
Fig. 5 illustrates the method that is used for distributing a storage space according to second embodiment of the invention.
Be with illustrated equipment 200 differences according to first embodiment of the invention of Fig. 4, in the equipment 200 according to second embodiment of the invention, detecting generation unit 230 is used for receiving for before described first capacity is revised as the instruction of second capacity in described command reception unit, when reading data from described storage space, detect and whether have read error, described read error is that first capacity that the capacity owing to described data when writing described data exceeds described storage space produces, if and have a described read error, then generate the instruction that is used for second capacity that described first capacity is revised as, and described second capacity is to determine according to the capacity of described data.
Illustrated as Fig. 5, according to the step S510 in the method for second embodiment of the invention, S530 and S540 with identical according to the step S310 in the method for second embodiment of the invention, S330 and S340.Yet, illustrated according to the step S320 in the method for first embodiment of the invention differently with Fig. 3, comprise according to the method for second embodiment of the invention:
In step S520, when reading data from described storage space, detect whether there is read error.
Particularly, for example, in the equipment 200 according to second embodiment of the invention, when reading data from a Binder, detect generation unit 230 and detect and whether exist because the capacity of described data when writing described data exceeds the read error that first capacity of described storage space causes generation when reading.
For example, when writing data to a Binder, if the capacity that writes data of a Binder is 3M, it greater than first initial capacity of a Binder (namely, 2M-16k), then this moment, in a Binder, will overflowing of data occur writing, and will in the memory headroom of a Binder, store invalid incomplete data.When reading this Binder subsequently, will from a Binder, obtain this invalid data, thereby produce read error.Have described read error if detection generation unit 230 detects, then execution in step S530 is used for described first initial capacity (that is, 2M-16k) is revised as the instruction of the first current capacity of determining according to the capacity of described data in order to generate; If there is no described read error, then this method end.
This shows, employing is according to the method and apparatus that is used for distributing a storage space of second embodiment of the invention, can when initialization, come the memory allocated space according to the capacity that sets in advance, detect then and whether have read error, and the capacity of described data is adjusted the capacity of this storage space when writing described data, so that when initialization next time, redistribute described storage space according to the current capacity after adjusting.Therefore, in the operational process of system, replace and detect write error, the present invention can detect read error, thereby comes dynamically memory allocated space according to the actual capacity of data.
Apparently, can also carry out combination with first embodiment according to a second embodiment of the present invention, make when detecting for a certain reason and not when having write the overflow error that its capacity produces greater than the data of storage space volume, can be additionally or detect the read error of these data further, thereby guarantee more reliably to check out whether the capacity of storage space conforms to actual demand, so that the capacity in memory allocated space dynamically.
Hereinafter, will the method and apparatus that be used for to distribute a storage space according to third embodiment of the invention be described with reference to figure 6 and 7.
Fig. 6 illustrates the method that is used for distributing a storage space according to third embodiment of the invention, and Fig. 7 illustrates the equipment 200 that is used for distributing a storage space according to third embodiment of the invention.
The illustrated method that is used for distribution one storage space according to third embodiment of the invention of Fig. 6 can be applied to the illustrated equipment 200 of Fig. 7, exceed in fact employed capacity when too much with the capacity that sets in advance of convenient storage space, equipment 200 is according to actual needs dynamically to Binder memory allocated space, thus the stability of Hoisting System and reliability.
With Fig. 2 illustrated according to of the present invention for the equipment 200 that distributes a storage space similarly, illustrated as Fig. 7, also comprise according to the equipment 200 of third embodiment of the invention: command reception unit 220 and allocation units 210.In addition, this equipment 200 also comprises: detect generation unit 230, be used for receiving for before described first capacity is revised as the instruction of second capacity in described command reception unit, by described first capacity is deducted described storage space the actual capacity that uses, generate difference to be compared, described difference to be compared and threshold difference are compared, if described difference to be compared exceeds threshold difference, then generate to be used for will described first capacity being revised as the instruction of second capacity, and described second capacity is to determine according to the capacity of described storage space institute reality use.Wherein, this detection generation unit 230 comprises: difference processing element 2310 and instruction generate parts 2330.
Illustrated as Fig. 6, comprise according to the method for be used for distributing a storage space of third embodiment of the invention:
In step S610, when described storage space is carried out initialization, distribute described storage space according to the initial capacity that sets in advance.
In the equipment 200 according to first embodiment of the invention, to with first the service (for example, ActivityManagerService) and second the service (for example, when PackageManagerService) Dui Ying first and second Binder carry out initialization, allocation units 210 read the numerical value of first and second initial capacities from the form of first initial capacity that is used for storage and sets in advance and second initial capacity, thereby distribute for example memory headroom of 4M-32k and 3M-24k to a Binder and the 2nd Binder respectively.
In step S620, by described initial capacity is deducted described storage space the actual capacity that uses, generate difference to be compared; And described difference to be compared and threshold difference are compared.
In the equipment 200 according to first embodiment of the invention, detect generation unit 230 and generate difference to be compared, and described difference to be compared and threshold difference are compared.
For example, in detecting generation unit 230, difference processing element 2310 deducts the capacity of their institute's reality uses by first and second initial capacities with a described Binder and the 2nd Binder, generates first and second differences to be compared.Suppose a Binder and the 2nd Binder the actual capacity that uses all be 1M.In the case, it is 4M-32k-1M=3M-32k that difference processing element 2310 draws the first to be compared difference corresponding with a Binder, and the second to be compared difference corresponding with the 2nd Binder equals 3M-24k-1M=2M-24k.
In addition, difference processing element 2310 compares described difference to be compared and threshold difference.If described difference to be compared exceeds threshold difference, then execution in step S630; If described difference to be compared does not exceed threshold difference, then this method finishes.
In step S630, generate to be used for described initial capacity is revised as the instruction of current capacity, and described current capacity is to determine according to the capacity of the actual use of described storage space institute.
In the equipment 200 according to first embodiment of the invention, if the difference processing element 2310 in the detection generation unit 230 is judged difference to be compared and exceeded threshold difference, then instruction generates parts 2330 and generates the instruction that is used for described initial capacity is revised as current capacity.
For example, when threshold difference is set to 2M-16k, as mentioned above, the first to be compared difference 3M-32k corresponding with a Binder exceeded this threshold difference, and instruction generates parts 2330 and generates the instruction that is used for the first current capacity that first initial capacity of a Binder is revised as.Wherein, the described first current capacity be according to a Binder the actual capacity that uses determine that preferably, this first current capacity can be to be that step-length increases progressively with 1M-8k, and just greater than or equal the capacity of the actual use of Binder institute.Particularly, a Binder the actual capacity that uses when being 1M, the first current capacity can not value be 1M-8k, but value is 2M-16k, in order to avoid cause overflowing when writing data.
In addition, because the second to be compared difference 2M-24k corresponding with the 2nd Binder do not exceed this threshold difference, think that the memory headroom that distributes to the 2nd Binder is suitable so detect generation unit 230, and needn't carry out any modification to the capacity of the 2nd Binder.
Especially, in a preferred version, illustrated as Fig. 7, detect generation unit 230 and also comprise a counter unit 2320, be used for creating the one or more counters corresponding with one or more Binder difference, for example, create first counter corresponding with a Binder and second counter corresponding with the 2nd Binder.
Therewith accordingly, in the method for this embodiment according to the present invention, if difference processing element 2310 is judged described difference to be compared and exceeded threshold difference in step S620, then make described counter add one, and described counter and threshold number are compared.If described counter exceeds threshold number, then execution in step S630 generates the instruction that is used for described initial capacity is revised as current capacity so that instruction generates parts 2330; Otherwise this method finishes.
For example, when threshold difference is set to 2M-16k and threshold number and is set to 2, as mentioned above, the first to be compared difference 3M-32k corresponding with a Binder exceeded this threshold difference, so counter unit 2320 is revised as 1 and store this value with the value of first counter from 0, and with the value of this first counter and threshold number (being set to 2) relatively.Because this moment, this counter did not exceed threshold number as yet, so generating parts 2330, instruction do not carry out any processing.When initialization next time, if a Binder the actual capacity that uses remain 1M, first namely corresponding with the Binder difference to be compared still equals 3M-32k and has exceeded this threshold difference again, then counter unit 2320 is revised as 2 with the value of first counter from 1, and value and the threshold number (for example, 2) of this first counter are compared.Because this moment, this counter exceeded threshold number, so generating parts 2330, instruction generates the instruction that is used for described initial capacity is revised as current capacity.
Need to prove, although be that example is illustrated with unique threshold difference and unique threshold number above, but obviously, wherein also can a plurality of threshold difference be set accordingly with the difference a plurality of to be compared of a plurality of Binder, and/or with a plurality of counters of a plurality of Binder a plurality of threshold number be set accordingly; And a plurality of differences to be compared and a plurality of threshold difference are compared respectively, and/or a plurality of counters and a plurality of threshold number are compared respectively, thereby between a plurality of Binder, generate for the instruction that described initial capacity is revised as current capacity with different criterions.
In step S640, receive for described initial capacity is revised as the instruction of current capacity, in order to when described storage space being carried out initialization, redistribute described storage space according to described current capacity next time.
In the equipment 200 according to first embodiment of the invention, command reception unit 220 receives and is used for first initial capacity of a described Binder (namely from detecting generation unit 230,4M-32k) be revised as the first current capacity (namely, instruction 2M-16k), and with the first current capacity storage in aforesaid form.
This shows, employing is according to the method and apparatus that is used for distributing a storage space of third embodiment of the invention, can when initialization, come the memory allocated space according to the capacity that sets in advance, whether the capacity that detects storage space when reality is used then exists redundancy, and when having redundancy, adjust the capacity of this storage space, so that when initialization next time, redistribute described storage space according to the current capacity after adjusting.Therefore, in the operational process of system, the present invention can come dynamically memory allocated space according to the capacity of the actual data that write in storage space, in order to utilize the memory headroom of system fully, efficiently, thus the stability of Hoisting System and reliability.
Hereinafter, will further describe the method and apparatus that be used for to distribute a storage space according to fourth embodiment of the invention with reference to figure 8.
Fig. 8 illustrates the method that is used for distributing a storage space according to fourth embodiment of the invention.
Be with illustrated equipment 200 differences according to third embodiment of the invention of Fig. 7, in the equipment 200 according to fourth embodiment of the invention, the counter unit 2320 that detects in the generation unit 230 is used for creating one or more counters, described one or more counter correspond respectively to after initialization each time described storage space the actual different capabilities that uses, if described difference to be compared exceeds threshold difference, then make the described counter corresponding with the capacity of current described storage space institute reality use add one, and described counter and threshold number are compared.
Illustrated as Fig. 8, according to the step S810 in the method for fourth embodiment of the invention, S830 and S840 with identical according to the step S610 in the method for third embodiment of the invention, S630 and S640.Yet, illustrated according to the step S620 in the method for third embodiment of the invention differently with Fig. 6, comprise according to the method for fourth embodiment of the invention:
In step S820, by described initial capacity is deducted described storage space the actual capacity that uses, generate difference to be compared; Described difference to be compared and threshold difference are compared; Create one or more counters, described one or more counters correspond respectively to after initialization each time described storage space the actual different capabilities that uses; If described difference to be compared exceeds threshold difference, then make the described counter corresponding with the capacity of current described storage space institute reality use add one; And described counter and threshold number are compared.
Below, be example with the form still, reference table 2 is described a fourth embodiment in accordance with the invention particularly.
Table 2
For the sake of clarity, be that example describes with a Binder only below.
Particularly, for example, in the detection generation unit 230 according to the equipment 200 of fourth embodiment of the invention, difference processing element 2310 deducts the capacity of the actual use of institute for the first time by first initial capacity with a described Binder, generates primary first difference to be compared.
As shown in table 2, suppose that allocation units 210 initially distribute the memory headroom of 4M-32k to a Binder, and the capacity of a Binder actual use of institute for the first time is 1M.In the case, to draw the primary first to be compared difference corresponding with a Binder (below, abbreviate as for the first time difference to be compared) be 4M-32k-1M=3M-32k to difference processing element 2310.
Counter unit 2320 is created one or more counters, and described one or more counters correspond respectively to the different capabilities of Binder institute reality use initialization each time after.For example, counter unit 2320 is created a counter I corresponding with the capacity 1M of institute's reality use for the first time.
For example, when threshold difference is set to 2M-16k, as mentioned above, the first time corresponding with a Binder, difference 3M-32k to be compared exceeded this threshold difference, then counter unit 2320 makes the counter I corresponding with the capacity 1M of institute's reality use for the first time add one, that is, the value of this hour counter I is changed to 1 from 0.And value and the threshold number (for example, being set to 2) of counter I are compared, because this moment, this counter did not exceed threshold number as yet, do not carry out any processing so instruction generates parts 2330.
When a Binder being carried out initialization next time, owing to do not adjust its capacity, so allocation units 210 still initially distribute the memory headroom of 4M-32k for the second time to a Binder, and suppose that the capacity of a Binder actual use of institute for the second time is 8k.In the case, to draw the secondary first to be compared difference corresponding with a Binder (below, abbreviate as for the second time difference to be compared) be 4M-32k-8k=4M-40k to difference processing element 2310.Counter unit 2320 is created a counter J corresponding with the capacity 8k of institute's reality use for the second time.And because the second time to be compared difference 4M-40k corresponding with a Binder exceeded this threshold difference, then counter unit 2320 makes the counter J corresponding with the capacity 8k of institute's reality use for the second time add one, that is, the value of this hour counter J is changed to 1 from 0.And value and the threshold number (being set to 2) of counter J are compared, because this moment, this counter did not exceed threshold number as yet, still do not carry out any processing so instruction generates parts 2330.
When another carries out initialization to a Binder, owing to still do not adjust its capacity, so allocation units 210 still initially distribute the memory headroom of 4M-32k for the third time to a Binder, and suppose that the capacity of a Binder actual use of institute for the third time remains 8k.In the case, to draw for the third time the first to be compared difference corresponding with a Binder (below, abbreviate difference to be compared for the third time as) be 4M-32k-8k=4M-40k to difference processing element 2310.Because counter unit 2320 has been created the counter J corresponding with the capacity 8k of institute actual use, so 2320 needs of counter unit upgrade this counter J, and need not to create again.And because difference 4M-40k to be compared has exceeded this threshold difference for the third time, then counter unit 2320 makes the counter J corresponding with the capacity 8k of institute reality use add one, that is, the value of this hour counter J is changed to 2 from 1.And value and the threshold number (being set to 2) of counter J are compared, because this moment, this counter exceeded threshold number, generate the instruction that is used for described initial capacity is revised as current capacity so instruction generates parts 2330.The current capacity of the one Binder can be to be that step-length increases progressively with 1M-8k, and just greater than or equal a Binder the actual capacity that uses.For example, a Binder the actual capacity that uses when being 8k, this current capacity can value be 1M-16k.
Especially, in a preferred version of a fourth embodiment in accordance with the invention, counter unit 2320 can be not used in creates the one or more counters correspond respectively to the different capabilities of Binder institute reality use initialization each time after; But on the contrary, this counter unit 2320 be used for creating with increase progressively by step-length with 1M-8k and just greater than or equal a Binder the corresponding counter of the current capacity of capacity of reality use.
Below, reference table 3 is described the preferred version of a fourth embodiment in accordance with the invention particularly.
Table 3
Figure BDA0000133489850000151
For example, suppose a Binder for the first time the actual capacity that uses of institute be 1M (as mentioned above, current capacity can value is 2M-16k), then at this moment create a counter X corresponding with the current capacity of 2M-16k, and counter X be changed to 1 from 0.Suppose a Binder for the second time the actual capacity that uses of institute be 8k (as mentioned above, current capacity can value is 1M-8k), then at this moment create a counter Y corresponding with the current capacity of 1M-8k, and counter Y be changed to 1 from 0.The one Binder for the third time the actual capacity that uses be 16k (as mentioned above, current capacity still can value is 1M-8k), then this moment the counter Y corresponding with the current capacity of 1M-8k is changed to 2 from 1.Because this moment, this counter exceeded threshold number (for example, being set to 2), so generating parts 2330, instruction generates the instruction that is used for described initial capacity is revised as current capacity 1M-8k.
This shows, employing is according to the method and apparatus that is used for distributing a storage space of fourth embodiment of the invention, can when initialization, come the memory allocated space according to the capacity that sets in advance, whether the capacity that detects storage space when reality is used then exists redundancy, and exist when redundant, do not adjusting the capacity of this storage space immediately, but when this redundancy takes place with certain probability, just adjust the capacity of this storage space, so that when initialization next time, redistribute described storage space according to the current capacity after adjusting.Therefore, in the operational process of system, the present invention can avoid adjusting continually the capacity of this storage space, thereby more stably comes dynamically memory allocated space according to the capacity of the actual data that write in storage space.
Although in the above will the Binder mechanism that be applied to the Android system for the method and apparatus that distributes a storage space according to the present invention being to understand the present invention the example, yet, those skilled in the art can be understood that, the invention is not restricted to this, but can be applied in the assigning process of any storage space of in any system, carrying out.
Describe each embodiment of the present invention in the above in detail.Yet, it should be appreciated by those skilled in the art that without departing from the principles and spirit of the present invention, can carry out various modifications to these embodiment, combination or sub-portfolio, and such modification should fall within the scope of the present invention.

Claims (12)

1. method of be used for distributing a storage space, described storage space corresponding to a service of server end, by writing data to described storage space and/or reading data from described storage space, calls described service uniquely, it is characterized in that described method comprises:
When described storage space is carried out initialization, distribute described storage space according to first capacity that sets in advance; And
Receive for described first capacity is revised as the instruction of second capacity, in order to when described storage space being carried out initialization, redistribute described storage space according to described second capacity next time.
2. according to the method for claim 1, it is characterized in that before the step of described reception for the instruction that described first capacity is revised as second capacity, described method also comprises:
When writing data to described storage space, detect the write error that first capacity that the capacity whether exist owing to described data exceeds described storage space produces; And
If there is the said write mistake, then generate describedly for the instruction that described first capacity is revised as second capacity, and described second capacity is to determine according to the capacity of described data.
3. according to the method for claim 1, it is characterized in that before the step of described reception for the instruction that described first capacity is revised as second capacity, described method also comprises:
When reading data from described storage space, detect whether to have read error, described read error be that first capacity that capacity owing to described data when writing described data exceeds described storage space produces; And
If there is described read error, then generate describedly for the instruction that described first capacity is revised as second capacity, and described second capacity is to determine according to the capacity of described data.
4. according to the method for claim 1, it is characterized in that before the step of described reception for the instruction that described first capacity is revised as second capacity, described method also comprises:
By described first capacity is deducted described storage space the actual capacity that uses, generate difference to be compared;
Described difference to be compared and threshold difference are compared; And
If described difference to be compared exceeds threshold difference, then generate described for the instruction that described first capacity is revised as second capacity, and described second capacity be according to described storage space the actual capacity that uses determine.
5. according to the method for claim 4, it is characterized in that, if difference described to be compared exceeds threshold difference, then generates and describedly comprise for the step that described first capacity is revised as the instruction of second capacity:
Create counter;
If described difference to be compared exceeds threshold difference, then make described counter add one;
Described counter and threshold number are compared; And
If described counter exceeds threshold number, then generate described for the instruction that described first capacity is revised as second capacity.
6. according to the method for claim 4, it is characterized in that, if difference described to be compared exceeds threshold difference, then generates and describedly comprise for the step that described first capacity is revised as the instruction of second capacity:
Create one or more counters, described one or more counters correspond respectively to after initialization each time described storage space the actual different capabilities that uses;
If described difference to be compared exceeds threshold difference, then make the described counter corresponding with the capacity of current described storage space institute reality use add one;
Described counter and threshold number are compared; And
If described counter exceeds threshold number, then generate described for the instruction that described first capacity is revised as second capacity.
7. equipment that be used for to distribute a storage space, described storage space corresponding to a service of server end, by writing data to described storage space and/or reading data from described storage space, calls described service uniquely, it is characterized in that described equipment comprises:
Allocation units are used for distributing described storage space according to first capacity that sets in advance when described storage space is carried out initialization; And
The command reception unit is used for receiving the instruction that is used for second capacity that described first capacity is revised as, so that when described storage space being carried out initialization, described allocation units are redistributed described storage space according to described second capacity next time.
8. according to the equipment of claim 7, it is characterized in that described equipment also comprises:
Detect generation unit, be used for receiving for before described first capacity is revised as the instruction of second capacity in described command reception unit, when writing data to described storage space, detect the write error that first capacity that the capacity whether exist owing to described data exceeds described storage space produces, if and have a said write mistake, then generate describedly for the instruction that described first capacity is revised as second capacity, and described second capacity is to determine according to the capacity of described data.
9. according to the equipment of claim 7, it is characterized in that described equipment also comprises:
Detect generation unit, be used for receiving for before described first capacity is revised as the instruction of second capacity in described command reception unit, when reading data from described storage space, detect and whether have read error, described read error is that first capacity that the capacity owing to described data when writing described data exceeds described storage space produces, if and have a described read error, then generate describedly for the instruction that described first capacity is revised as second capacity, and described second capacity is to determine according to the capacity of described data.
10. according to the equipment of claim 7, it is characterized in that described equipment also comprises:
Detect generation unit, be used for receiving for before described first capacity is revised as the instruction of second capacity in described command reception unit, by described first capacity is deducted described storage space the actual capacity that uses, generate difference to be compared, described difference to be compared and threshold difference are compared, if described difference to be compared exceeds threshold difference, then generate described for the instruction that described first capacity is revised as second capacity, and described second capacity be according to described storage space the actual capacity that uses determine.
11. the equipment according to claim 10 is characterized in that, described detection generation unit comprises:
The difference processing element, be used for receiving for before described first capacity is revised as the instruction of second capacity in described command reception unit, by described first capacity is deducted described storage space the actual capacity that uses, generate difference to be compared, and described difference to be compared and threshold difference are compared;
Counter unit is used for creating counter, if described difference to be compared exceeds threshold difference, then makes described counter add one, and described counter and threshold number are compared; And
Instruction generates parts, exceeds threshold number if be used for described counter, then generates described for the instruction that described first capacity is revised as second capacity.
12. the equipment according to claim 10 is characterized in that, described detection generation unit comprises:
The difference processing element, be used for receiving for before described first capacity is revised as the instruction of second capacity in described command reception unit, by described first capacity is deducted described storage space the actual capacity that uses, generate difference to be compared, and described difference to be compared and threshold difference are compared;
Counter unit, be used for creating one or more counters, described one or more counter correspond respectively to after initialization each time described storage space the actual different capabilities that uses, if described difference to be compared exceeds threshold difference, then make the described counter corresponding with the capacity of current described storage space institute reality use add one, and described counter and threshold number are compared; And
Instruction generates parts, exceeds threshold number if be used for described counter, then generates described for the instruction that described first capacity is revised as second capacity.
CN2012100224573A 2012-02-01 2012-02-01 Method and device for distributing storage space Pending CN103246608A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2012100224573A CN103246608A (en) 2012-02-01 2012-02-01 Method and device for distributing storage space

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2012100224573A CN103246608A (en) 2012-02-01 2012-02-01 Method and device for distributing storage space

Publications (1)

Publication Number Publication Date
CN103246608A true CN103246608A (en) 2013-08-14

Family

ID=48926138

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2012100224573A Pending CN103246608A (en) 2012-02-01 2012-02-01 Method and device for distributing storage space

Country Status (1)

Country Link
CN (1) CN103246608A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1752949A (en) * 2004-09-24 2006-03-29 上海贝尔阿尔卡特股份有限公司 Internal storage management system and method
CN101149703A (en) * 2007-10-10 2008-03-26 中兴通讯股份有限公司 Fixed EMS memory management method
EP2040399A1 (en) * 2006-06-29 2009-03-25 Huawei Technologies Co., Ltd. An optical burst switching network based burst packet transmitting system and the method thereof
CN101515242A (en) * 2009-03-16 2009-08-26 中兴通讯股份有限公司 Method and system for searching and rewriting the task of internal memory

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1752949A (en) * 2004-09-24 2006-03-29 上海贝尔阿尔卡特股份有限公司 Internal storage management system and method
EP2040399A1 (en) * 2006-06-29 2009-03-25 Huawei Technologies Co., Ltd. An optical burst switching network based burst packet transmitting system and the method thereof
CN101149703A (en) * 2007-10-10 2008-03-26 中兴通讯股份有限公司 Fixed EMS memory management method
CN101515242A (en) * 2009-03-16 2009-08-26 中兴通讯股份有限公司 Method and system for searching and rewriting the task of internal memory

Similar Documents

Publication Publication Date Title
US8954487B2 (en) Management server and method for providing cloud computing service
WO2019205371A1 (en) Server, message allocation method, and storage medium
US20170192819A1 (en) Method and electronic device for resource allocation
KR102077149B1 (en) Method for managing memory and apparatus thereof
US20180144009A1 (en) Partitioning and Rebalancing Data Storage
US20100088448A1 (en) Virtual computing accelerator and program downloading method for server-based virtual computing
US8695079B1 (en) Allocating shared resources
EP3195128B1 (en) Memory management in virtualized environment
CN103763209A (en) Scheduling method and device of CDN servers
US9229762B2 (en) Host providing system and host providing method
CN113849312A (en) Data processing task allocation method and device, electronic equipment and storage medium
CN108073423A (en) A kind of accelerator loading method, system and accelerator loading device
WO2024066828A1 (en) Data processing method and apparatus, and device, computer-readable storage medium and computer program product
CN113407298A (en) Method, device and equipment for realizing message signal interruption
CN103369038A (en) PaaS (platform as a service) management platform and method
CN102419753A (en) Information processing equipment, information processing method and information processing system
CN116069493A (en) Data processing method, device, equipment and readable storage medium
CN105677481A (en) Method and system for processing data and electronic equipment
CN113127430A (en) Mirror image information processing method and device, computer readable medium and electronic equipment
CN115562871A (en) Memory allocation management method and device
CN103246608A (en) Method and device for distributing storage space
CN112604267B (en) Game processing method, system, device, equipment and medium
CN111078407B (en) Memory management method and device, storage medium and electronic equipment
CN113703906A (en) Data processing method, device and system
CN112839071A (en) Training system, training data access method and device, electronic device and 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
RJ01 Rejection of invention patent application after publication

Application publication date: 20130814

RJ01 Rejection of invention patent application after publication