CN100336392C - Data storage managing method of set-top box - Google Patents

Data storage managing method of set-top box Download PDF

Info

Publication number
CN100336392C
CN100336392C CNB2003101169555A CN200310116955A CN100336392C CN 100336392 C CN100336392 C CN 100336392C CN B2003101169555 A CNB2003101169555 A CN B2003101169555A CN 200310116955 A CN200310116955 A CN 200310116955A CN 100336392 C CN100336392 C CN 100336392C
Authority
CN
China
Prior art keywords
buffer pool
memory cell
memory
space
top box
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CNB2003101169555A
Other languages
Chinese (zh)
Other versions
CN1625248A (en
Inventor
刘新伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
BEIJING ZHONGSHILIAN DIGITAL SYSTEM Co Ltd
Original Assignee
BEIJING ZHONGSHILIAN DIGITAL SYSTEM Co 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 BEIJING ZHONGSHILIAN DIGITAL SYSTEM Co Ltd filed Critical BEIJING ZHONGSHILIAN DIGITAL SYSTEM Co Ltd
Priority to CNB2003101169555A priority Critical patent/CN100336392C/en
Publication of CN1625248A publication Critical patent/CN1625248A/en
Application granted granted Critical
Publication of CN100336392C publication Critical patent/CN100336392C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Abstract

The present invention discloses a data storing and managing method of a set-top box. Firstly, using data in storing space is judged; if the data is frequently used and occupies large storing space, storing space allocated to the data which is frequently used and occupies little storing space is directly used when a system is initialized, and the allocation of the storing space is finished; if the data is not frequently used and occupies small storing space, a storing unit is allocated from a buffer pool comprising a plurality of storing units of the same size; after being used, the storing unit is returned to the buffer pool. The present invention allocates fixed space to the data which is frequently used and occupies large storing space, small storing space not frequently used is allocated by a method of repeated use in the buffer pool, and fragments appearing in the storing space are reduced. The using efficiency of the storing space is increased, and the using conditions of the storing space can be better monitored by some statistical functions.

Description

A kind of data storage and management method of set-top box
Technical field
The present invention relates to a kind of data storage and management method, especially a kind of data storage and management method that is applied to digital TV set-top box belongs to the digital television techniques field.
Background technology
In digital TV set-top box, the storage of data and the management that data are stored are important link.The storage of data is divided into two kinds in digital TV set-top box: memory and memory storage.Because the capacity of digital TV set-top box memory is very limited, as it not being managed effectively, is easy to occur the situation of insufficient memory.
In digital TV set-top box, existing memory allocation mechanism is by the precedence of operating system according to the memory space application, with matching principle at first, distributes successively.According to such distribution mechanism, the distribution and the release of the frequent memory space that may occur along with system's run duration can form a large amount of, discontinuous fragment in whole memory space.When applying for a large amount of continuous memory spaces, although total the free memory sum that the residual memory space total amount does not exceed, but can't satisfy the distribution requirement owing to continuous memory space inadequate, cause the storage resources exhaustion of system.If can take a kind of method, reduce the generation of memory space fragment as far as possible, can improve a lot to the utilization ratio of memory space.
Summary of the invention
The technical problem to be solved in the present invention is a kind of management method of storage of set-top box, reduces fragment, improves the service efficiency of memory space.
A kind of data storage management way of set-top box comprises the steps:
Step 1, system initialization, often the data allocations memory space that takies a large amount of memory spaces that uses;
The data of step 2, the memory space that uses when request for often use take the data of a large amount of memory spaces the time, directly use the memory space that when system initialization, distributes, finish the distribution of memory space;
When the data of step 3, the memory space that uses when request are data non-common, that take a small amount of memory space, from the Buffer Pool that comprises a plurality of big or small same memory cell, distribute a memory cell, after this memory cell uses up, give back Buffer Pool.
The present invention is by the data that take the bulk memory space to frequent use, fixed allocation; To memory space non-common, fritter, adopt the interior nonexpondable method of Buffer Pool to distribute, promptly, do different distribution and processing according to the size and the frequent degree of use of the memory space of being applied for, reduce the fragment that memory space occurs, improved the service efficiency of memory space; And can pass through some debug function and statistical function, the operating position of memory space in the monitoring system better.
Description of drawings
Fig. 1 is the flow chart of the inventive method embodiment.
Embodiment
Below in conjunction with drawings and Examples technical scheme of the present invention is elaborated:
The data of set top box memory management method of present embodiment as shown in Figure 1, comprises the steps:
Step 1, system initialization, often the data allocations memory space that takies a large amount of memory spaces that uses;
The data of step 2, the memory space that uses when request for often use take the data of a large amount of memory spaces the time, directly use the memory space that when system initialization, distributes, finish the distribution of memory space;
When the data of step 3, the memory space that uses when request are data non-common, that take a small amount of memory space, from the Buffer Pool that comprises a plurality of big or small same memory cell, distribute a memory cell, after this memory cell uses up, give back Buffer Pool.
For the programmer, the data that take a large amount of memory spaces that where can use frequent use are clearly, therefore, can be when system initialization, earlier that the data of this part are required memory allocation is good, and it is existed always, does not discharge.
Such as, in the decoding and reduction treatment process of the set-top box of Digital Television to vision signal, the buffer-stored for the video data before and after the set-top box processes will take a large amount of memory spaces, and whole set-top box duration of work, and this memory space exists always.Memory space just can be allocated in advance when system initialization hereto.This also is that the set-top box storage space management of Digital Television is different from common storage space management part.
To this processing method of bulk memory space commonly used, avoided the frequent distribution and the release of memory space in program operation process, reduce the chance that produces fragment.When initialization, because there is not fragment, be met easily for the demand of big memory block, improve program reliability.And in running, can reduce the time that spends because of memory allocation, improve operational efficiency.
In the step 3 of the present invention, the data that take a small amount of memory space to non-frequent use, adopt nonexpondable distribution method in the Buffer Pool, can reduce the number of times of direct memory allocation and release like this, thereby reduced the risk of distributing failure, and, thereby reduced the interior fragment of memory space with the unit of a bigger Buffer Pool as direct memory allocation.
Because the memory cell of a Buffer Pool is that size is identical, same specification, so in order to adapt to different demands, immediate memory cell is distributed to caller, the memory cell size should be different, therefore, produce the Buffer Pool of different size.
The memory cell specification is 32 bytes, 64 bytes, 128 bytes or 2 nByte, n is a natural number, n 〉=8.Adopt 2 nByte is that because in most cases the memory space that system's application is used generally all is 2 as the specification of memory cell nByte.
If caller need apply for that less than 30 bytes of memory spaces, then the memory space of actual allocated should be in the memory cell specification be the Buffer Pool of 32 bytes; And the memory space of size between 32 bytes and 64 bytes then is distributed in the Buffer Pool that the memory cell specification is 64 bytes, and this needs with caller are determined the memory cell that will distribute, is also referred to as the matching process of memory cell.
The size of each Buffer Pool is identical, is generally 2K or 4K byte, according to different demands and may be different; The fragment and the waste that distribute and add up but also reduce memory space had so not only been made things convenient for.For example, the Buffer Pool in the middle of certain has discharged owing to not re-using, and so, because the size of each Buffer Pool is identical, just can distribute new Buffer Pool in the space that it is available.
Be a concrete Buffer Pool structure below, consist of the following components: the front nodal point pointer of the size of memory cell size, Buffer Pool, the unit number of having used, Buffer Pool pointer, idle chained list, Buffer Pool chained list and posterior nodal point pointer; Be specially
typedef?struct?bufPool{
Size_t cell_size; / * memory cell size */
Size_t bufPool_size; / * Buffer Pool size */
Unsigned short cells_used; The unit number * that/* has used/
Void * bufPool_ptr; The pointer * of/* Buffer Pool/
SLList free_list; The idle chained list * of/*/
Struct bufPool * m_prev; The front nodal point pointer * of/* Buffer Pool chained list/
Struct bufPool * m_next; The posterior nodal point pointer * of/* Buffer Pool chained list/
}bufPool_t;
Memory space in the foremost of each Buffer Pool (size is 32 bytes) is left Buffer Pool structure bufPool_t for, and actual memory cell following closely.
Also can adopt the doubly linked list of a said structure to finish to the management of all Buffer Pools.System automatically generates a head node, when creating a new Buffer Pool, all needs the pointer of Buffer Pool is added in the Buffer Pool chained list.Adopt the forward direction insertion when the Buffer Pool chained list adds new node, the foremost that promptly always new node is joined chained list is after the head node.
As shown in Figure 1, utilize Buffer Pool to non-common, take small quantity of memory space data allocations memory space, may further comprise the steps:
Step 3.1, judge whether to exist the Buffer Pool of memory cell specification coupling, promptly judge immediately, whether be included in the Buffer Pool of having set up more than or equal to the Buffer Pool at the memory cell place of required storage size with required storage size; If there is execution in step 3.2; Otherwise, execution in step 3.3;
Step 3.2, judge whether the idle memory cell in the Buffer Pool is used up, if the idle memory cell in the Buffer Pool is used up execution in step 3.3; Otherwise execution in step 3.4;
A new Buffer Pool that memory cell is suitable is set up, execution in step 3.4 in step 3.3, memory allocated space;
Step 3.4, from the Buffer Pool of memory cell specification coupling, distribute a memory cell, after using up, give back Buffer Pool;
If memory cell whole in step 3.5 Buffer Pool are given back, the memory space that the buffer release pond is shared.
Select the most suitable memory cell, can conserve storage, cut the waste.If the idle memory cell in the chained list has not had, just from system memory space, distribute a bigger memory block once more as new Buffer Pool.New Buffer Pool is identical with the shared storage size of original Buffer Pool, and memory cell is identical with the memory cell size of the Buffer Pool that memory cell is used up.After if the memory cell of the Buffer Pool that memory cell is used up is given back, the memory cell of the identical size of reallocating is distributed from original Buffer Pool.
Memory cell is given back Buffer Pool after using up, and does not discharge, and greatly reduces the chance that fragment produces.Memory cell whole in the Buffer Pool are given back, and the memory space that the buffer release pond is shared just can be set up new Buffer Pool then again in the memory space that discharges.Since each set up and discharge all be with the size of Buffer Pool as unit, so also avoided the generation of fragment.
Below respectively with regard to the foundation of Buffer Pool, the distribution of memory cell, the release of giving back with Buffer Pool is described in detail:
Set up Buffer Pool, concrete steps are:
The required memory space of Buffer Pool is set up in step 3.3.1, distribution, sets the memory cell of the identical coupling of a plurality of sizes in the memory space;
Step 3.3.2, set up the idle memory cell that an idle chained list is managed.
Obtain the address of each memory cell, set up a chained list then and manage these addresses, this is a kind of distribution of memory cell preferably and the mode of giving back, and is simple and efficient.
Idle chained list is to be used for managing memory cell idle in the Buffer Pool, is a single-track link table, and its structure is very simple, and each node is deposited the address of next idle memory cell.After creating Buffer Pool, all to set up the idle chained list of this Buffer Pool, at first set up the head node of idle chained list in the Buffer Pool structure, then all memory unit addresses in the Buffer Pool are added in the idle chained list successively, equally, adopt the forward direction insertion during interpolation, be about to foremost that new node joins chained list and be after the head node, last memory cell should be in the foremost of chained list after finishing.Here the nodal information that it is noted that idle chained list is to leave in these idle memory cell.That is to say, when memory cell is idle, need deposit the nodal information of idle chained list, in case be used, promptly deposit concrete data message, and do not needed this node in the idle chained list this moment, therefore can not cause conflict.
Create Buffer Pool, detailed process is described as follows:
1) be Buffer Pool memory allocated space, the shared storage size of Buffer Pool is system's silent fixed (attention will comprise that part of memory space that the Buffer Pool structure is shared);
2) initialization Buffer Pool structure.The unit number of comprise the memory cell size, cushion out size, having used (being initially 0), Buffer Pool pointer (being the first address of Buffer Pool memory space, also is the first address of Buffer Pool structure);
3) in the Buffer Pool chained list, add this Buffer Pool node;
4) set up idle chained list, all memory unit addresses in the Buffer Pool are added in the idle chained list successively;
5) return the Buffer Pool pointer.
The memory allocated space, input parameter is the size of required memory space, is output as the Storage Unit Pointer that is assigned to and the pointer of place Buffer Pool, detailed process is described as follows:
Step 1 is determined memory cell size (the principle front of judgement is existing to be introduced) according to required storage size;
Step 2, begin inquiry from the next node of Buffer Pool linked list head node, search the big or small identical Buffer Pool of memory cell of idle chained list, up to finding or the end of list (EOL) of Buffer Pool chain for determining in sky and memory cell size and the step 1, if do not find, execution in step 3; If find, execution in step 4;
Step 3 is distributed a new Buffer Pool;
Step 4 is distributed a memory cell from Buffer Pool;
Step 5 is exported to the user with Buffer Pool pointer and Storage Unit Pointer.
Distribute a memory cell from Buffer Pool, detailed process is as follows:
1) judges that whether idle chained list is empty (whether idle chain gauge outfit node points to NULL), if be empty, distributes failure; If be not empty, carry out 2);
2) take out first node of idle chained list, the idle chained list of resetting returns the pointer of the node of taking-up.
Discharge memory space, its parameter is the pointer of Storage Unit Pointer and place Buffer Pool, returns success, failure flags, and detailed process is described as follows:
Step 1 is returned to Buffer Pool with memory cell;
Step 2 judges whether the idle chained list of this Buffer Pool is empty, if be empty, and execution in step 3, if be not empty, execution in step 4;
Step 3 discharges this Buffer Pool;
Step 4, release is finished, and returns success, failure flags.
The memory cell that recovery uses up is returned to Buffer Pool, and detailed process is as follows:
1) whether the content of judgment data unit is idle chained list nodal information (address of certain memory cell in the Buffer Pool just), thereby determines whether to reclaiming for the second time;
2) if not discharging for the second time, add this unit node to idle chained list foremost (depositing next memory unit address in this memory cell),, then no longer reclaim if discharge for the second time.
Discharge (deletion) Buffer Pool, detailed process is described as follows:
1) this Buffer Pool node of deletion from the Buffer Pool chained list;
2) buffer release pool structure discharges this memory space.
By debug function and some statistical function parameters of above memory allocation and release, the operating position of memory space in the monitoring system better.Such as, the size that the size of memory cell and the unit number used just can be understood the memory space that has used in the inquiry Buffer Pool by the size of Buffer Pool, thereby calculates untapped memory space; Calculate the untapped memory space of all Buffer Pools, just can understand the operating position of the memory space of whole set-top box.
It should be noted last that: above embodiment is the unrestricted technical scheme of the present invention in order to explanation only, although the present invention is had been described in detail with reference to the foregoing description, those of ordinary skill in the art is to be understood that: still can make amendment or be equal to replacement the present invention, and not breaking away from any modification or partial replacement of the spirit and scope of the present invention, it all should be encompassed in the middle of the claim scope of the present invention.

Claims (9)

1, a kind of data storage management way of set-top box is characterized in that: comprise the steps:
Step 1, system initialization, often the data allocations memory space that takies a large amount of memory spaces that uses;
The data of step 2, the memory space that uses when request for often use take the data of a large amount of memory spaces the time, directly use the memory space that when system initialization, distributes, finish the distribution of memory space;
When the data of step 3, the memory space that uses when request are data non-common, that take a small amount of memory space, from the Buffer Pool that comprises a plurality of big or small same memory cell, distribute a memory cell, after this memory cell uses up, give back Buffer Pool.
2, the data storage management way of set-top box according to claim 1, it is characterized in that: in the described step 2, during system initialization, for the memory space of the data allocations that takies a large amount of memory spaces often used exists at whole set-top box duration of work always.
3, the data storage management way of set-top box according to claim 1, it is characterized in that: in the described step 3, the specification of Buffer Pool can be more than one, and the shared memory space of the Buffer Pool of different size is identical, and the memory cell of Buffer Pool varies in size.
4, according to the data storage management way of claim 1 or 3 described set-top box, it is characterized in that: described Buffer Pool memory cell size is 32 bytes or 64 bytes or 128 bytes or 2 nByte, n is a natural number, n 〉=8.
5, the data storage management way of set-top box according to claim 1 is characterized in that: in the described step 3, comprise following process:
Step 3.1, judge whether the Buffer Pool that exists memory cell suitable, if there is execution in step 3.2; Otherwise, execution in step 3.3;
Step 3.2, judge whether the idle memory cell in the Buffer Pool is used up, if the idle memory cell in the Buffer Pool is used up execution in step 3.3; Otherwise execution in step 3.4;
A new Buffer Pool that memory cell is suitable is set up, execution in step 3.4 in step 3.3, memory allocated space;
Step 3.4, distribute a memory cell, give back Buffer Pool after using up from the suitable Buffer Pool of memory cell;
If memory cell whole in step 3.5 Buffer Pool are given back, the memory space that the buffer release pond is shared.
6, the data storage management way of set-top box according to claim 5 is characterized in that: in the described step 3, step 3.2 judges whether to exist the Buffer Pool of memory cell coupling, is specially following process:
Judge with required storage size immediately, whether be included in the Buffer Pool of having set up more than or equal to the Buffer Pool at the memory cell place of required storage size.
7, the data storage management way of set-top box according to claim 5 is characterized in that: in the described step 3, the new Buffer Pool that a memory cell is mated is set up in step 3.3 memory allocated space, specifically comprises the steps:
The required memory space of Buffer Pool is set up in step 3.3.1 distribution, sets the memory cell of the identical coupling of a plurality of sizes in the memory space;
Step 3.3.2 sets up the idle memory cell that an idle chained list is managed.
8, the data storage management way of set-top box according to claim 7 is characterized in that: in the described step 3, step 3.4 is given back the memory cell that uses up and is given Buffer Pool from Buffer Pool memory allocated unit, specifically comprises following process:
At first, judge whether the idle chained list of Buffer Pool is empty, if be empty, then distributes failure, returns error message; If be not empty, then take out first node of idle chained list, the idle chained list of resetting returns the pointer of the node of taking-up; After using up, add this unit node to idle chained list foremost, memory cell realizes reclaiming.
9, the data storage management way of set-top box according to claim 7 is characterized in that: in the described step 3, and step 3.5 buffer release pond, this Buffer Pool node of deletion from the Buffer Pool chained list; The buffer release pool structure discharges this memory space.
CNB2003101169555A 2003-12-03 2003-12-03 Data storage managing method of set-top box Expired - Fee Related CN100336392C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2003101169555A CN100336392C (en) 2003-12-03 2003-12-03 Data storage managing method of set-top box

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2003101169555A CN100336392C (en) 2003-12-03 2003-12-03 Data storage managing method of set-top box

Publications (2)

Publication Number Publication Date
CN1625248A CN1625248A (en) 2005-06-08
CN100336392C true CN100336392C (en) 2007-09-05

Family

ID=34760833

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2003101169555A Expired - Fee Related CN100336392C (en) 2003-12-03 2003-12-03 Data storage managing method of set-top box

Country Status (1)

Country Link
CN (1) CN100336392C (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5008936B2 (en) * 2006-09-28 2012-08-22 京セラドキュメントソリューションズ株式会社 Memory management device and memory management method
US7721065B2 (en) 2006-09-28 2010-05-18 Kyocera Mita Corporation Reducing memory fragmentation by learning memory allocation patterns
CN101141737B (en) * 2007-09-25 2010-09-29 中兴通讯股份有限公司 Method of real-time updating spatial information on mobile terminal
CN102023924B (en) * 2009-09-21 2012-11-14 鸿富锦精密工业(深圳)有限公司 Integrated receiving equipment and storage space requisition method thereof
CN101873470B (en) * 2010-04-30 2012-09-12 中山大学 Method and system for supporting user to play television program and record program simultaneously

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5303347A (en) * 1991-12-27 1994-04-12 Digital Equipment Corporation Attribute based multiple data structures in host for network received traffic
CN1201194A (en) * 1997-05-12 1998-12-09 莱克斯马克国际公司 Method and apparatus for managing communication buffer of block communication data of printer
CN1357123A (en) * 1999-05-17 2002-07-03 株式会社科浪 Method for facilitating data sharing between application programs and accesses to peripheral appts. with application programs by using shared addresses
CN1405683A (en) * 2001-09-18 2003-03-26 华为技术有限公司 FLASH storage file management method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5303347A (en) * 1991-12-27 1994-04-12 Digital Equipment Corporation Attribute based multiple data structures in host for network received traffic
CN1201194A (en) * 1997-05-12 1998-12-09 莱克斯马克国际公司 Method and apparatus for managing communication buffer of block communication data of printer
CN1357123A (en) * 1999-05-17 2002-07-03 株式会社科浪 Method for facilitating data sharing between application programs and accesses to peripheral appts. with application programs by using shared addresses
CN1405683A (en) * 2001-09-18 2003-03-26 华为技术有限公司 FLASH storage file management method

Also Published As

Publication number Publication date
CN1625248A (en) 2005-06-08

Similar Documents

Publication Publication Date Title
CN1276361C (en) A memory management method for embedded system
CN1292370C (en) Method and apparatus for data processing
US7165255B2 (en) Method and apparatus for managing surplus memory in multitasking system
CN1205549C (en) Method and device of memory distribution for multi-line range virtual machine
CN1271524C (en) Static internal storage management method
CN1764117A (en) Method for transmitting upgrade software to optical network unit in Ethernet passive optical network
CN1859325A (en) News transfer method based on chained list process
CN101055533A (en) Multithreading processor dynamic EMS memory management system and method
CN1855881A (en) Method for dynamically sharing space of memory
CN1664790A (en) Method and apparatus for increasing data storage capacity
CN1194526C (en) Storing device and facsimile apparatus using the same
CN1794208A (en) Mass storage device and method for dynamically managing a mass storage device
CN1679005A (en) Dynamic memory management
CN1928825A (en) Server implementing method and server system
CN1687904A (en) Method for controlling smart card storage environment
CN100336392C (en) Data storage managing method of set-top box
CN1889737A (en) Resource management method and system
CN1133337C (en) Resource allocation
CN1949203A (en) Architecture of interface target machine for miniature computer system and data transmitting method
CN1881895A (en) Apparatus operation method in network management system
CN101030951A (en) Drop-out compensating method and compensator
CN1427361A (en) Method of driving bottom equipment based on customer/service apparatus structure
CN1360256A (en) Method for dynamic upgrade of set top box software
CN1889038A (en) Method for managing long-distance structural components service cycle with class as unit
CN1508795A (en) Data storage method for hard disk for camera-shooting and recording 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
EE01 Entry into force of recordation of patent licensing contract

Assignee: Zhejiang Boxsam Electronic Co., Ltd.

Assignor: Beijing Zhongshilian Digital System Co., Ltd.

Contract fulfillment period: 2008.3.21 to 2015.12.31 contract change

Contract record no.: 2009330002551

Denomination of invention: Data storage managing method of set-top box

Granted publication date: 20070905

License type: Exclusive license

Record date: 20091020

LIC Patent licence contract for exploitation submitted for record

Free format text: EXCLUSIVE LICENSE; TIME LIMIT OF IMPLEMENTING CONTACT: 2008.3.21 TO 2015.12.31; CHANGE OF CONTRACT

Name of requester: ZHEJIANG BOXSAM ELECTRONICS CO., LTD.

Effective date: 20091020

C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20070905

Termination date: 20101203