CN103309812A - Allocation method and device for memory space of smart card - Google Patents
Allocation method and device for memory space of smart card Download PDFInfo
- Publication number
- CN103309812A CN103309812A CN2012100694600A CN201210069460A CN103309812A CN 103309812 A CN103309812 A CN 103309812A CN 2012100694600 A CN2012100694600 A CN 2012100694600A CN 201210069460 A CN201210069460 A CN 201210069460A CN 103309812 A CN103309812 A CN 103309812A
- Authority
- CN
- China
- Prior art keywords
- space
- dtr
- rtr
- data
- capacity
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 32
- 230000003247 decreasing effect Effects 0.000 claims description 3
- 238000012545 processing Methods 0.000 claims description 3
- 230000004888 barrier function Effects 0.000 claims 1
- 230000008859 change Effects 0.000 abstract description 3
- 239000000872 buffer Substances 0.000 description 21
- 230000008569 process Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 101150115778 DTR1 gene Proteins 0.000 description 6
- 238000012217 deletion Methods 0.000 description 3
- 230000037430 deletion Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 238000013467 fragmentation Methods 0.000 description 3
- 238000006062 fragmentation reaction Methods 0.000 description 3
- 239000012634 fragment Substances 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000011084 recovery Methods 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- 238000004891 communication Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000010926 purge Methods 0.000 description 1
Images
Landscapes
- Memory System (AREA)
- Record Information Processing For Printing (AREA)
Abstract
The embodiment of the invention discloses an allocation method and an allocation device for the memory space of a smart card, relates to the technical field of smart cards and solves the technical problem in the prior art that RTR (CLEAR_ON_RESET RAM) and DTR (CLEAR_ON_DESELECT RAM) space of the RAM of a smart card are difficult to allocate and determine. The allocation method mainly comprises the steps that a section of continuous address space in the RAM (random access memory) is allocated as the RTR and DTR space, and the initial boundaries of the RTR and DTR space in the continuous address space are set according to preset initial boundary values; when the free memory capacity of the RTR space is smaller than the capacity requested by RTR data, or when the free memory capacity of the DTR space is smaller than the capacity requested by DTR data, the boundaries are dynamically adjusted in the continuous address space to change the size of the RTR space or the DTR space.
Description
Technical Field
The invention relates to the field of smart cards, in particular to a method and a device for allocating memory space of a smart card.
Background
With the wide application of smart card technology, various cards such as bank cards, bus cards, venue entrance cards and the like can be concentrated in a security chip or an SIM card (hereinafter, referred to as smart cards) of one mobile phone, and the demand of multi-industry cooperative card issuing is driven. The multi-application card has more design and requirements in the aspects of application management, card space management, secure communication mechanism and the like. The one-card multi-application market is continuously and rapidly growing, the types of applications (applets) are increasingly diversified, the RAM (random access memory) space in the smart card which can be occupied by the applets can be dynamically loaded according to the applications, and the related space can be dynamically applied and recovered. Available RAM space is divided into two classes 1, RTR (CLEAR _ ON _ RESET RAM, RESET CLEAR): this space is erased when the smart card is reset. Multiple applets can apply for the space, and each applet can share the applied space independently once the space is applied, so that the space can also be used for sharing the memory independently. 2. DTR (CLEAR _ ON _ DESELECT RAM, cancel purge): this space is erased when the application is deselect and when the smart card is reset. Multiple applets can apply for the space, and once the space is applied, the multiple applets share the space, so the space can be also referred to as shared memory for short.
Because RAM space in a security chip or a SIM card in the current mobile phone terminal is precious and limited, the space size of RTR and DTR is limited. In the prior art, if the smart card only uses the RTR space, the RAM variable and buffer temporarily occupied by the applet when selected are monopolized once allocated, and when the number of applets is large, the probability of insufficient RAM space is large. If the smart card uses only DTR space, this requirement cannot be fulfilled for applets that apply some global RAM variables and buffers and expect to keep (e.g., state values) the space after power-up. If the smart card has both RTR and DTR spaces, the size allocation of the two spaces is difficult to determine. Because different smart card applets occupy different RTR and DTR space policies, it is difficult for a multi-applet smart card to determine a reasonable space allocation value when issuing the card. Because once the RTR and DTR spaces are allocated, the two kinds of space allocations are overlapped with each other, and the applet data is lost or even the applet is dead, which may be caused by improper processing of an operating system.
Disclosure of Invention
Embodiments of the present invention provide a method and an apparatus for allocating a memory space of a smart card, which can solve the technical problem that allocation of RTR and DTR spaces of an RAM in the smart card is difficult to determine when the card is issued, and improve utilization rate of an application space.
In order to achieve the above purpose, the embodiment of the invention adopts the following technical scheme:
a method for allocating memory space of a smart card is characterized by comprising the following steps:
designating a section of continuous address space in the RAM as RTR and DTR spaces, and setting initial boundaries of the RTR and DTR spaces in the continuous address space according to a preset initial boundary value, so that the continuous address space is divided into the initial boundaries, wherein one side of each boundary is used as the RTR space, and the other side of each boundary is used as the DTR space;
when the residual storage capacity in the RTR space is smaller than the capacity applied by the RTR data or when the residual storage capacity in the DTR space is smaller than the capacity applied by the DTR data, the size of the RTR space or the DTR space is changed by dynamically adjusting the boundary in the continuous address space, so that the RTR space can contain the RTR data or the DTR space can contain the DTR data.
Preferably, the method further comprises:
for the received RTR data, storing from a low address to a high address of an RTR space in sequence, and for the received DTR data, storing from a high address to a low address of a DTR space in sequence; or,
for received RTR data, the data is stored sequentially from the high address to the second address of the RTR space, and for received DTR data, the data is stored sequentially from the low address to the high address of the DTR space.
Further, the above-mentioned changing the size of the RTR space or the DTR space by dynamically adjusting the boundary in the continuous address space specifically includes:
calculating the size of the space needing to be increased in the RTR space, checking whether the capacity of each DTR memory section in the DTR space is remained, if the sum of the remained capacity of each DTR memory section exceeds the size of the space needing to be increased in the RTR space, adjusting the boundary line by reducing the capacity of each DTR memory section by the same amount to increase the RTR space, reducing each DTR memory section until the RTR space contains RTR data, and updating the boundary value of the adjusted boundary line in a system registry; or
Calculating the space size of the DTR section memory required to be increased of the DTR data application, checking whether the capacity of the RTR space is left, if the capacity of the RTR space is checked to be left and the size of the left capacity of the RTR space is enough to increase the space size required to be increased of each DTR section memory, adjusting the boundary line in a mode of increasing the capacity of each DTR section memory by the same amount to increase each DTR section memory and reduce the RTR space until the DTR space contains DTR data, and updating the boundary value of the adjusted boundary line in a system registry.
Further, after the RTR data is deleted from the RTR space or the DTR data is deleted from the DTR space, the method further comprises:
and performing defragmentation on the deleted RTR space or DTR space, moving the occupied RTR space or DTR space together to form a continuous address, and simultaneously enabling the addresses of the rest RTR space and the rest DTR space to be continuous at the boundary.
Further, after defragmentation, the method further comprises:
and restoring the boundary to a preset initial boundary value, and updating the position of the RTR data in the defragmented RTR space and/or the position of the DTR data in the DTR space in a registry of the system.
An apparatus for allocating memory space of a smart card, comprising:
the setting unit is used for designating a section of continuous address space in the RAM as RTR and DTR spaces, and setting initial boundaries of the RTR and DTR spaces in the continuous address space according to a preset initial boundary value, so that the continuous address space is divided into the initial boundaries, one side of each boundary is used as the RTR space, and the other side of each boundary is used as the DTR space;
and the adjusting unit is used for changing the size of the RTR space or the DTR space by dynamically adjusting the boundary line in the continuous address space when the residual storage capacity in the RTR space is smaller than the capacity size applied by the RTR data or the residual storage capacity in the DTR space is smaller than the capacity size applied by the DTR data, so that the RTR space or the DTR space can contain the RTR data or the DTR data.
Preferably, the adjusting unit includes:
the calculation module is used for calculating the size of the space needing to be increased in the RTR space and checking whether the capacity of each DTR memory section in the DTR space is remained; the distribution module is used for adjusting the boundary line in a mode of reducing the capacity of each DTR memory by the same amount when the calculation module detects that the capacity of each DTR memory section has surplus and the sum of the surplus capacity of each DTR memory section exceeds the size of the space needing to be increased in the RTR space, so that the RTR space is increased and the DTR memory section is reduced;
or, the calculation module is further configured to calculate a size of a space that needs to be increased in a DTR segment memory of the DTR data application, and check whether a capacity of the RTR space is left; and the distribution module is also used for adjusting the boundary line in a mode of increasing the capacity of each DTR memory section by the same amount when the calculation module checks that the residual capacity of the RTR space is enough to increase the space size needing to be increased for each DTR memory section, so that each DTR memory section is increased and the RTR space is reduced.
In addition, the apparatus further comprises:
a continuous space allocation unit for sequentially storing the received RTR data from a lower address to a higher address of the RTR space; for the received DTR data, it is stored in order from the high address to the low address of the DTR space.
And the fragmentation finishing unit is used for performing fragmentation finishing on the RTR space after the RTR data is deleted, moving the occupied RTR spaces together to form a continuous address, performing fragmentation finishing on the DTR space or the DTR space after the DTR data is deleted, moving the occupied DTR spaces together to form a continuous address, and simultaneously enabling the addresses of the residual RTR space and the residual DTR space to be continuous at the boundary.
And the recovery unit is used for recovering the boundary to a preset initial boundary value after the defragmentation unit finishes the defragmentation, and updating the position of the RTR data in the RTR space and/or the position of the DTR data in the DTR space after the defragmentation in the registry of the system.
In the allocation scheme of the intelligent memory space provided by the embodiment of the invention, the technical means that the RTR space and the DTR space are assigned as a section of continuous address space and the boundary line at the junction of the RTR space and the DTR space in the continuous address space is adjusted is adopted, so that the technical problem that the size allocation of the RTR space and the DTR space of the RAM in the intelligent card is difficult to determine when the card is issued in the prior art is solved, the capacity of the RTR space or the DTR space can be dynamically changed according to the size of the applied RTR data or DTR data, the memory space is allocated reasonably, and the technical effect of improving the utilization rate of the memory space is achieved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for allocating a memory space of a smart card in embodiment 1 of the present invention;
FIG. 2 is a diagram illustrating the RTR space and the DTR space as the consecutive addresses in embodiment 1 of the present invention;
fig. 3 is a schematic diagram of a manner in which a smart card stores RTR data and DTR data according to embodiment 1 of the present invention;
fig. 4 is a schematic diagram of a process of increasing an RTR space and reducing a DTR space in embodiment 1 of the present invention;
fig. 5 is a schematic diagram of a process of increasing a DTR space and reducing an RTR space in embodiment 1 of the present invention;
fig. 6 is a schematic diagram of a defragmentation process of the smart card after the application is deleted in embodiment 1 of the present invention;
FIG. 7 is a schematic diagram illustrating a process of recovering an initial boundary address after defragmentation of an intelligent card in embodiment 1 of the present invention;
fig. 8 is a schematic structural diagram of an apparatus for allocating memory space of a smart card in embodiment 2 of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention. In addition, the following embodiments are all alternatives of the present invention, and the arrangement order of the embodiments and the number of the embodiments are not related to the preferred execution order.
Example 1
The present embodiment provides a method for allocating a memory space of a smart card, as shown in fig. 1, the method includes:
101, the smart card designates a section of continuous address space in the RAM as RTR and DTR spaces, and sets initial boundaries of the RTR and DTR spaces in the continuous address space according to a preset initial boundary value, so that the continuous address space is divided into a boundary line with the initial boundary, one side of the boundary line is used as the RTR space, and the other side is used as the DTR space;
for example, the smart card shown with reference to fig. 2 specifies a continuous address space in the RAM for RTR and DTR spaces according to preset initial boundary values. For example, in the case that the smart card supports two logic channels (the smart card supports several logic channels, and there are several DTR spaces, which are not the improved part of the present invention and are not described herein), as can be seen from fig. 2, a buffer space on the left side of the boundary is an RTR space, and a DTR space on the right side of the boundary is two DTR buffers, which are DTR1 and DTR2, respectively. The size of the buffer capacity of the RTR space is N bytes, each DTR buffer has M/2bytes, and the DTR spaces formed by adjacent DTR buffers have M bytes in total.
102, the smart card stores the RTR data applied by the applet in the RTR space and the DTR data applied in the DTR space.
In the invention, the RTR data can be stored in the RTR space in a mode of sequentially storing the RTR data from a high address to a low address or randomly storing the RTR data. The DTR data may be stored in the DTR space in a sequential manner from a low address to a high address or in a random manner. However, in this embodiment, in order to implement a scheme of increasing or decreasing the RTR space capacity (or DTR space capacity) by dynamically adjusting the boundary more fully, it should be ensured that the adjacent addresses of the RTR space and the DTR space are blank as much as possible, that is, the vacant storage areas of the RTR space and/or the DTR space are connected at the boundary as much as possible. Therefore, in a preferred embodiment, step 102 may be:
for the received RTR data, storing from a low address to a high address of an RTR space in sequence, and for the received DTR data, storing from a high address to a low address of a DTR space in sequence; alternatively, for received RTR data, the data is stored sequentially from the high address to the second address of the RTR space, and for received DTR data, the data is stored sequentially from the low address to the high address of the DTR space.
As shown in fig. 2 and 3, the RTR data applied by application a and application B are stored in order from a low address to a high address of the RTR space; the DTR data applied by the application B is stored from a high address to a low address of the DTR space in sequence. However, if the DTR space is on the left side of fig. 2 and the RTR space is on the right side of fig. 2, the RTR data applied by application a and application B are stored in order from the high address to the low address of the RTR space; the DTR data applied by the application B is stored from a low address to a high address of the DTR space in sequence.
103, the smart card dynamically adjusts the size of the DTR space and the RTR space according to the size of the storage space applied by the application and the condition of the residual space of the DTR or RTR space so as to accommodate the application.
The steps can be divided into the following two cases:
when the residual storage capacity in the RTR space is smaller than the capacity applied by the RTR data, the size of the RTR space is changed by dynamically adjusting the boundary in the continuous address space, so that the RTR space can contain the RTR data. The process of adjusting the boundary line is preferably implemented as follows:
calculating the size of the space needing to be increased in the RTR space, checking whether the capacity of each DTR memory section in the DTR space is remained, if the sum of the remained capacity of each DTR memory section exceeds the size of the space needing to be increased in the RTR space, adjusting the boundary line by reducing the capacity of each DTR memory section by the same amount to increase the RTR space, reducing each DTR memory section until the RTR space contains RTR data, and updating the boundary value of the adjusted boundary line in a system registry;
in this embodiment, the adjacent addresses of the RTR space and the DTR space can be automatically and flexibly configured by dynamically adjusting the boundary between the RTR and the DTR, so as to realize buffer sharing at the adjacent addresses. For example, referring to fig. 4, when the RTR space applied by the application C exceeds the remaining storage capacity of the buffer in the RTR space of the smart card, the smart card calculates the size of the capacity that needs to be increased in the RTR space to be X bytes, and checks whether there is a remaining space in the DTR buffer. If there is remaining space, and the total amount of the remaining space of DTR1 and DTR4 exceeds X bytes, then each DTR button is reduced by X/2, and the RTR space is increased by X until the space of the application C application can be accommodated. And after the application C requests enough space and successfully installs the data, updating the new boundary line value, the occupied addresses in the adjusted RTR space and the adjusted DTR space and the address of each DTR buffer in a registry of an Operating System (OS) of the smart card.
The above adjustment method is a preferred embodiment of the present invention because it is simple and does not need to calculate or control each DTR buffer separately, but it can also be implemented by adjusting the DTR buffers separately to increase the RTR space, for example, calculating or controlling DTR1 and DTR4 separately. By checking only the remaining space of DTR4 to see if there are X bytes, if so, only the boundary needs to be moved to take Xbytes out of the buffer of DTR 4.
And when the residual storage capacity in the DTR space is smaller than the capacity applied by the DTR data, dynamically adjusting the boundary line in the continuous address space to change the size of the DTR space so that the DTR space can contain the DTR data. The process of adjusting the boundary line is preferably implemented as follows:
calculating the space size of the DTR section memory required to be increased of the DTR data application, checking whether the capacity of the RTR space is left, if the capacity of the RTR space is checked to be left and the size of the left capacity of the RTR space is enough to increase the space size required to be increased of each DTR section memory, adjusting the boundary line in a mode of increasing the capacity of each DTR section memory by the same amount to increase each DTR section memory and reduce the RTR space until the DTR space contains DTR data, and updating the boundary value of the adjusted boundary line in a system registry.
For example, referring to FIG. 5, let application D apply for a DTR space that exceeds DTR1 buffer remaining space y/2bytes in the smart card, and the smart card checks whether there is remaining space in RTR buffer. If there is remaining space and the capacity of the remaining space is sufficient and both DTR1 and DTR2 increase y/2bytes, then the RTR space is reduced by y bytes and each DTR buffer increases y/2bytes until the space for the application can be accommodated. And after the application is successfully installed, updating the new boundary line value, the addresses occupied by the applications A, B, C and D in the RTR space and the DTR space, and the address of each segment of DTR buffer after adjustment in the registry of the OS of the smart card.
In the above preferred embodiment of this embodiment, when increasing the DTR space, the RTR space is reduced, and each DTR segment increases the same space, so that the complexity of calculating or controlling the DTR buffer can be reduced, and the implementation and application are facilitated. Of course, the present embodiment may also achieve the increase of the capacity of DTR2 in other ways. For example: only the boundary is adjusted, y/2bytes can be separated from the RTR space to the DTR1, and y/2bytes do not need to be separated from the DTR 2; or whether the remaining space in DTR2 is sufficient, and if so, assigning y/2bytes of DTR2 to DTR 1. However, considering that because the DTR belongs to the shared memory, it cannot be determined whether the DTR will be occupied by other applications, it is still a preferred solution to implement the DTR by reducing the RTR space.
In addition, considering that the Applet occupies an RTR space or a DTR space, and also deletes the RTR space or the DTR space, in order to ensure the reasonable utilization and safe use of the content, the embodiment further includes the following scheme:
after RTR data is deleted from the RTR space or DTR data is deleted from the DTR space, the smart card defragments the deleted RTR space or DTR space, moves the occupied RTR space or DTR space together to form a continuous address, and simultaneously makes the addresses of the residual RTR space and the residual DTR space continuous at a boundary.
If application deletion exists in the RTR space or the DTR space, the smart card performs fragment integration on the released space, moves occupied spaces into continuous seismic spaces, places the vacant RTR space at the high address position of the RTR buffer, and places the vacant DTR space at the low address position of the DTR buffer. After the smart card is defragmented, the boundary position can be restored to a preset initial boundary value.
Taking fig. 6 and 7 as an example, when the smart card defragments after the application B is deleted from the RTR space, the B bytes occupied by the application B is moved to the position where the B bytes are continuous with the DTR space address, and the boundary is restored to the initial boundary address in fig. 2.
Further, after the defragmentation is completed and the smart card recovers the boundary to the preset initial boundary value, the smart card needs to update the position of the RTR data in the defragmented RTR space and/or the position of the DTR data in the DTR space in the registry of the system. In order to prevent power failure in the process, the relevant position information recorded by the OS registry needs to be backed up before the data position is moved, and the backed-up data is cleared after the data position is successfully moved. Thus, even if power is cut off during the moving process, the smart card can still restore the backup data to the registry of the OS after the next reset.
In the method provided by the embodiment, by adopting a mode of designating continuous address spaces as an RTR space and a DTR space and dynamically adjusting a connecting boundary between the two spaces, the problems that the size distribution of the RTR space and the DTR space of an RAM in the smart card is difficult to determine and the utilization rate of the application space is low during card sending can be solved, and the problems that after the RTR space and the DTR space are distributed, due to improper processing of an operating system, application data at the position where the two types of space distribution are overlapped with each other is lost and even the application is dead can be avoided, so that the limited storage space of the smart card can be reasonably utilized, and the technical effect of improving the utilization rate of the storage space is achieved.
Example 2
The present embodiment provides an apparatus for allocating memory space of a smart card, as shown in fig. 8, including a setting unit 81 and an adjusting unit 82.
A setting unit 81, configured to designate a segment of continuous address space in the RAM as RTR and DTR spaces, and set initial boundaries of the RTR and DTR spaces in the continuous address space according to a preset initial boundary value, so that the continuous address space is divided into boundary lines using the initial boundaries as boundary lines, where one side of the boundary lines is used as the RTR space and the other side is used as the DTR space; an adjusting unit 82, configured to, when the remaining storage capacity in the RTR space is smaller than the capacity size of the RTR data application, or when the remaining storage capacity in the DTR space is smaller than the capacity size of the DTR data application, change the size of the RTR space or the DTR space by dynamically adjusting the boundary in the continuous address space, so that the RTR space accommodates the RTR data or the DTR space accommodates the DTR data.
In a preferred embodiment, the adjusting unit 82 includes: a calculation module 821 and a distribution module 822.
A calculating module 821, configured to calculate a size of a space that needs to be increased in the RTR space, and check whether there is a remaining capacity of each segment of the DTR memory in the DTR space; the distribution module 822 is used for adjusting the boundary line in a manner of reducing the capacity of each segment of the DTR memory by an equal amount when the calculation module detects that the capacity of each segment of the DTR memory has surplus and the sum of the surplus capacity of each segment of the DTR memory exceeds the size of the space needing to be increased in the RTR space, so that the RTR space is increased and the DTR memory is reduced;
and/or the calculating module 821 is further configured to calculate a size of a space that needs to be increased in a DTR segment memory of the DTR data application, and check whether the capacity of the RTR space is left; the allocating module 822 is further configured to adjust the boundary line by increasing the capacity of each segment of the DTR memory by an equal amount when the calculating module detects that there is a surplus and the size of the surplus capacity of the RTR space is enough for the DTR memory to increase the size of the space to be increased, so that each segment of the DTR memory is increased and the RTR space is decreased.
Further, the apparatus may further include: a continuous space allocation unit 83, a fragment settling unit 84, and a recovery unit 85.
A continuous space allocation unit 83 for storing the received RTR data in order from the lower address to the upper address of the RTR space in the continuous address space set by the setting unit 81; for received DTR data, the data is stored sequentially from the top address to the bottom address of the DTR space.
A defragmentation unit 84 for defragmenting the RTR space after the deletion of the RTR data and moving the occupied RTR spaces together to form a continuous address, and for defragmenting the DTR space or the DTR space after the deletion of the DTR data and moving the occupied DTR spaces together to form a continuous address, while making the addresses of the remaining RTR space and the remaining DTR space continuous at the boundary.
And the restoring unit 85 is used for restoring the boundary to a preset initial boundary value after the defragmentation unit defragments, and updating the position of the RTR data in the defragmentation RTR space and/or the position of the DTR data in the DTR space in the registry of the system.
The device provided by this embodiment may be deployed in a smart card, to implement the method in embodiment 1, and only the security module in the smart card (for example, a SIM card) needs to be modified, a corresponding functional module is added to OS software, the smart card hardware does not need to be modified, and the software increase capacity is estimated at 2 to 3 kbytes, so the improvement is small, and the implementation is convenient and easy to popularize.
The device provided by the embodiment adopts the technical means of appointing the RTR space and the DTR space as a section of continuous address space and adjusting the boundary line of the junction of the RTR space and the DTR space in the continuous address space, thereby solving the technical problem that the size distribution of the RTR space and the DTR space of the RAM in the smart card is difficult to determine when the card is issued in the prior art, further being capable of dynamically changing the capacity of the RTR space or the DTR space according to the size of the applied RTR data or the DTR data, reasonably distributing the memory space and improving the technical effect of the utilization rate of the memory space.
The technical solution of the present invention or the portions that contribute to the prior art may be embodied in the form of software products, that is to say: even if the main body of the device, apparatus or each apparatus constituting the system according to the present invention which executes the method or implements the function is hardware, the essential part implementing the function of the present invention is a module or unit of a computer software product.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (10)
1. A method for allocating memory space of a smart card is characterized by comprising the following steps:
designating a section of continuous address space in the RAM as RTR and DTR spaces, and setting initial boundaries of the RTR and DTR spaces in the continuous address space according to a preset initial boundary value, so that the continuous address space is divided into the boundary with the initial boundaries as boundaries, wherein one side of the boundary is used as the RTR space, and the other side of the boundary is used as the DTR space;
when the residual storage capacity in the RTR space is smaller than the capacity applied for RTR data, or when the residual storage capacity in the DTR space is smaller than the capacity applied for DTR data, the size of the RTR space or the DTR space is changed by dynamically adjusting the boundary in the continuous address space, so that the RTR space accommodates the RTR data or the DTR space accommodates the DTR data.
2. The method of claim 1, further comprising:
for the received RTR data, storing from a low address to a high address of an RTR space in sequence, and for the received DTR data, storing from a high address to a low address of a DTR space in sequence; or,
for received RTR data, the data is stored sequentially from the high address to the second address of the RTR space, and for received DTR data, the data is stored sequentially from the low address to the high address of the DTR space.
3. The method according to claim 1 or 2, wherein changing the size of the RTR space or the DTR space by dynamically adjusting the barrier in the continuous address space comprises:
calculating the size of the space needing to be increased in the RTR space, checking whether the capacity of each DTR memory section in the DTR space is remained, if the sum of the remained capacity of each DTR memory section exceeds the size of the space needing to be increased in the RTR space, adjusting the boundary line in a mode of reducing the capacity of each DTR memory section by the same amount to increase the RTR space and reduce each DTR memory section until the RTR space contains the RTR data, and updating the boundary value of the adjusted boundary line in a system registry; or
Calculating the space size that DTR section memory of DTR data application needs to increase to whether the capacity in checking RTR space has the surplus, if it has the surplus to check, and the remaining capacity size in RTR space is enough every section DTR memory and all increases when the space size that needs to increase, adjust through the mode that every section DTR memory capacity is increased to the equivalent the boundary line, make every section DTR memory all increases, and the RTR space reduces, until the DTR space holds down the DTR data, and will adjust the boundary value of boundary line updates in the system registry.
4. The method for allocating memory space of a smart card according to claim 1 or 2, wherein after the RTR data is deleted from the RTR space or after the DTR data is deleted from the DTR space, the method further comprises:
and performing defragmentation on the deleted RTR space or DTR space, moving the occupied RTR space or DTR space together to form a continuous address, and simultaneously enabling the addresses of the rest RTR space and the rest DTR space to be continuous at the boundary.
5. The method of allocating memory space of a smart card of claim 4, wherein after defragmentation, the method further comprises:
and restoring the boundary to a preset initial boundary value, and updating the position of the RTR data in the defragmented RTR space and/or the position of the DTR data in the DTR space in a registry of the system.
6. An apparatus for allocating memory space of a smart card, comprising:
the device comprises a setting unit, a processing unit and a control unit, wherein the setting unit is used for designating a section of continuous address space in the RAM as RTR and DTR spaces, setting initial boundaries of the RTR and DTR spaces in the continuous address space according to a preset initial boundary value, and dividing the continuous address space into boundary lines by taking the initial boundaries as boundary lines, wherein one side of each boundary line is used as the RTR space, and the other side of each boundary line is used as the DTR space;
and the adjusting unit is used for changing the size of the RTR space or the DTR space by dynamically adjusting the boundary in the continuous address space when the residual storage capacity in the RTR space is smaller than the capacity size applied by RTR data or the residual storage capacity in the DTR space is smaller than the capacity size applied by the DTR data, so that the RTR data or the DTR data can be accommodated in the RTR space.
7. The apparatus for allocating memory space of a smart card as claimed in claim 6, further comprising:
a continuous space allocation unit for sequentially storing from a low address to a high address of an RTR space for received RTR data and from a high address to a low address of a DTR space for received DTR data; alternatively, for received RTR data, the data is stored sequentially from the high address to the second address of the RTR space, and for received DTR data, the data is stored sequentially from the low address to the high address of the DTR space.
8. The device for allocating memory space of a smart card according to claim 6 or 7, wherein the adjusting unit comprises:
the calculation module is used for calculating the size of the space needing to be increased in the RTR space and checking whether the capacity of each DTR memory section in the DTR space is remained;
the distribution module is used for adjusting the boundary line in a mode of reducing the capacity of each DTR memory section by the same amount when the calculation module detects that the capacity of each DTR memory section has surplus and the sum of the surplus capacity of each DTR memory section exceeds the size of the space needing to be increased in the RTR space, so that the RTR space is increased and the DTR memory section is reduced;
or,
the calculation module is further configured to calculate a size of a space that needs to be increased in a DTR segment memory of the DTR data application, and check whether a capacity of an RTR space is left;
the distribution module is further configured to adjust the boundary line in a manner of increasing the capacity of each segment of the DTR memory by an equal amount when the calculation module checks that there is a surplus and the size of the remaining capacity of the RTR space is enough to increase the size of the space to be increased in each segment of the DTR memory, so that each segment of the DTR memory is increased and the RTR space is decreased.
9. The device for allocating memory space of a smart card according to claim 6 or 7, further comprising:
and the defragmentation unit is used for defragmenting the RTR space after the RTR data is deleted, moving the occupied RTR spaces together to form a continuous address, defragmenting the DTR space or the DTR space after the DTR data is deleted, moving the occupied DTR spaces together to form a continuous address, and simultaneously making the addresses of the residual RTR space and the residual DTR space continuous at the boundary.
10. The apparatus for allocating memory space of a smart card as recited in claim 9, further comprising:
and the restoring unit is used for restoring the boundary to a preset initial boundary value after the defragmentation unit finishes the defragmentation, and updating the position of the RTR data in the RTR space and/or the position of the DTR data in the DTR space after the defragmentation in a registry of the system.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210069460.0A CN103309812B (en) | 2012-03-15 | 2012-03-15 | A kind of distribution method of smart card memory space and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210069460.0A CN103309812B (en) | 2012-03-15 | 2012-03-15 | A kind of distribution method of smart card memory space and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103309812A true CN103309812A (en) | 2013-09-18 |
CN103309812B CN103309812B (en) | 2016-03-30 |
Family
ID=49135059
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210069460.0A Active CN103309812B (en) | 2012-03-15 | 2012-03-15 | A kind of distribution method of smart card memory space and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103309812B (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103699493A (en) * | 2013-12-26 | 2014-04-02 | 上海柯斯软件有限公司 | System and method for controlling DTR memory space of intelligent card |
CN105279097A (en) * | 2014-07-07 | 2016-01-27 | 北京数码视讯科技股份有限公司 | Management method and equipment of invoke transient object, and smart card |
CN105426237A (en) * | 2015-11-13 | 2016-03-23 | 武汉天喻信息产业股份有限公司 | Method and system for dynamically managing JavaCard transient resources |
CN105824651A (en) * | 2015-01-06 | 2016-08-03 | 中国移动通信集团公司 | Intelligent card internal application installation method and apparatus |
CN107807846A (en) * | 2017-10-20 | 2018-03-16 | 大唐微电子技术有限公司 | The method and apparatus for distributing JavaCard transient object memory spaces |
WO2019183829A1 (en) * | 2018-03-28 | 2019-10-03 | 深圳市大疆创新科技有限公司 | Method and device for applying system chip internal storage medium space, and unmanned aerial vehicle |
CN110716934A (en) * | 2019-10-09 | 2020-01-21 | 宁波三星医疗电气股份有限公司 | Data storage method and device and electronic equipment |
CN110750211A (en) * | 2019-09-05 | 2020-02-04 | 华为技术有限公司 | Storage space management method and device |
CN115391032A (en) * | 2022-08-15 | 2022-11-25 | 上海慧程工程技术服务有限公司 | Memory optimization method for industrial Internet of things edge equipment |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040015672A1 (en) * | 2002-07-17 | 2004-01-22 | Masse Wayne P. | Method, system, and storage medium for optimizing disk space and information access |
CN1484230A (en) * | 2002-09-18 | 2004-03-24 | 建兴电子科技股份有限公司 | Dynamic memory configuring method for recording power of CDRW driver |
CN1932779A (en) * | 2006-09-20 | 2007-03-21 | 华为技术有限公司 | Method and apparatus for updating data |
US20070073962A1 (en) * | 2005-09-29 | 2007-03-29 | Tsutomu Nakamura | Accessing device |
CN101221536A (en) * | 2008-01-25 | 2008-07-16 | 中兴通讯股份有限公司 | Internal memory managing method and device of embedded system |
CN101515254A (en) * | 2008-02-18 | 2009-08-26 | 鸿富锦精密工业(深圳)有限公司 | System and method for managing storage space |
-
2012
- 2012-03-15 CN CN201210069460.0A patent/CN103309812B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040015672A1 (en) * | 2002-07-17 | 2004-01-22 | Masse Wayne P. | Method, system, and storage medium for optimizing disk space and information access |
CN1484230A (en) * | 2002-09-18 | 2004-03-24 | 建兴电子科技股份有限公司 | Dynamic memory configuring method for recording power of CDRW driver |
US20070073962A1 (en) * | 2005-09-29 | 2007-03-29 | Tsutomu Nakamura | Accessing device |
CN1932779A (en) * | 2006-09-20 | 2007-03-21 | 华为技术有限公司 | Method and apparatus for updating data |
CN101221536A (en) * | 2008-01-25 | 2008-07-16 | 中兴通讯股份有限公司 | Internal memory managing method and device of embedded system |
CN101515254A (en) * | 2008-02-18 | 2009-08-26 | 鸿富锦精密工业(深圳)有限公司 | System and method for managing storage space |
Cited By (15)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103699493A (en) * | 2013-12-26 | 2014-04-02 | 上海柯斯软件有限公司 | System and method for controlling DTR memory space of intelligent card |
CN103699493B (en) * | 2013-12-26 | 2016-07-06 | 上海柯斯软件股份有限公司 | The control system and method for smart card DTR memory headroom |
CN105279097A (en) * | 2014-07-07 | 2016-01-27 | 北京数码视讯科技股份有限公司 | Management method and equipment of invoke transient object, and smart card |
CN105279097B (en) * | 2014-07-07 | 2019-06-18 | 北京数码视讯科技股份有限公司 | A kind of management method, equipment and smart card calling transient object |
CN105824651A (en) * | 2015-01-06 | 2016-08-03 | 中国移动通信集团公司 | Intelligent card internal application installation method and apparatus |
CN105824651B (en) * | 2015-01-06 | 2019-01-01 | 中国移动通信集团公司 | A kind of smart card is interior to apply installation method and device |
CN105426237B (en) * | 2015-11-13 | 2018-11-06 | 武汉天喻信息产业股份有限公司 | A kind of method and system of dynamic management JavaCard transient state resources |
CN105426237A (en) * | 2015-11-13 | 2016-03-23 | 武汉天喻信息产业股份有限公司 | Method and system for dynamically managing JavaCard transient resources |
CN107807846A (en) * | 2017-10-20 | 2018-03-16 | 大唐微电子技术有限公司 | The method and apparatus for distributing JavaCard transient object memory spaces |
WO2019183829A1 (en) * | 2018-03-28 | 2019-10-03 | 深圳市大疆创新科技有限公司 | Method and device for applying system chip internal storage medium space, and unmanned aerial vehicle |
CN110520839A (en) * | 2018-03-28 | 2019-11-29 | 深圳市大疆创新科技有限公司 | Storage medium space application method, apparatus and unmanned plane in System on Chip/SoC |
CN110750211A (en) * | 2019-09-05 | 2020-02-04 | 华为技术有限公司 | Storage space management method and device |
WO2021043026A1 (en) * | 2019-09-05 | 2021-03-11 | 华为技术有限公司 | Storage space management method and device |
CN110716934A (en) * | 2019-10-09 | 2020-01-21 | 宁波三星医疗电气股份有限公司 | Data storage method and device and electronic equipment |
CN115391032A (en) * | 2022-08-15 | 2022-11-25 | 上海慧程工程技术服务有限公司 | Memory optimization method for industrial Internet of things edge equipment |
Also Published As
Publication number | Publication date |
---|---|
CN103309812B (en) | 2016-03-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103309812B (en) | A kind of distribution method of smart card memory space and device | |
US8805902B2 (en) | Managing snapshot storage pools | |
US20090089516A1 (en) | Reclaiming storage on a thin-provisioning storage device | |
US9183142B2 (en) | Reducing flash memory write amplification and latency | |
CN108959117B (en) | H2D write operation acceleration method and device, computer equipment and storage medium | |
WO2024113726A1 (en) | Disk array reconstruction task acceleration method and system, storage medium, and device | |
CN103678144A (en) | Data storage device and flash memory control method | |
CN112579251B (en) | Method and equipment for managing virtual machine memory | |
CN104423894A (en) | Data storage device and flash memory control method thereof | |
US20050273557A1 (en) | Storage system and method for acquisition and utilisation of snapshots | |
US20200218573A1 (en) | Memory management method, electronic apparatus, and storage device | |
CN107665098B (en) | Information processing method, storage device, and computer storage medium | |
CN104798063A (en) | Memory device and host device | |
CN106557427A (en) | The EMS memory management process and device of shared drive data base | |
CN107533435A (en) | The distribution method and storage device of memory space | |
EP4185963A1 (en) | Zone hints for zoned namespace storage devices | |
CN111338779A (en) | Resource allocation method, device, computer equipment and storage medium | |
US9946496B2 (en) | SSD with non-blocking flush command | |
CN105608013B (en) | A kind of the storage card control chip and storage card of integrated MRAM | |
CN110659248B (en) | User mode file system design method and system based on nonvolatile memory | |
US9177177B1 (en) | Systems and methods for securing storage space | |
CN109032960B (en) | Dynamic allocation method of smart card RAM and storage device of data structure | |
CN113419672B (en) | Storage capacity management method, system and storage medium | |
CN104461779B (en) | A kind of storage method of distributed data, apparatus and system | |
CN107912063A (en) | A kind of method for recovering internal storage and device |
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 |