CN101272551B - Initialization method for maximum stack space of embedded system - Google Patents

Initialization method for maximum stack space of embedded system Download PDF

Info

Publication number
CN101272551B
CN101272551B CN200710073673XA CN200710073673A CN101272551B CN 101272551 B CN101272551 B CN 101272551B CN 200710073673X A CN200710073673X A CN 200710073673XA CN 200710073673 A CN200710073673 A CN 200710073673A CN 101272551 B CN101272551 B CN 101272551B
Authority
CN
China
Prior art keywords
space
stack
stack space
task
value
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
CN200710073673XA
Other languages
Chinese (zh)
Other versions
CN101272551A (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.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN200710073673XA priority Critical patent/CN101272551B/en
Publication of CN101272551A publication Critical patent/CN101272551A/en
Application granted granted Critical
Publication of CN101272551B publication Critical patent/CN101272551B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

A setting method for the largest stack space of an embedded system includes the following steps: A. the largest predicted value of the stack space of the commission is predetermined according to the space condition of every commission; B. the practical largest value of the commission for occupying the stack space is obtained after a period of practical operation; C. the largest stack space of thecommission is ultimately determined according to the practical largest value. When the method of the invention is adopted to arrange the largest stack space, abnormality can not be caused by the shortage of the stack space, RAM space can not be wasted owing to the aim of avoiding the overflowing, the reasonable application of the RAM space can be effectively guaranteed, the unnecessary cost expenditure is reduced and the cost is lowered.

Description

The establishing method in a kind of embedded system maximum stack space
Technical field
The present invention relates to the method that CDMA (Code Division Multiple Access) wireless communication terminal product maximum stack space is set, relate in particular to the establishing method in a kind of embedded system maximum stack space.
Background technology
At present, have under a lot of situations, embedded system is relatively more responsive to cost requirement, the ram space that adopts is all more limited, so adopt the mode (as shown in Figure 1) in fixed stack space more, the size in fixed stack space has very large benefit during each task initialization: algorithm is simple relatively during task scheduling, carries out efficiency ratio dynamic assignment stack space and wants high, and speed is faster.
But produce a problem thus: to be made as much be very distinct issues to the size of each task stack space during initialization on earth.If it is excessive that each stack space distributes, to limited ram space is that waste greatly is (in embedded system often because the cost problem, so preferably take less ram space), if distribute too small, can cause stack overflow, can cause program exception to crash, restart, move confusion like this, consequence is very serious.
Summary of the invention
Technical matters to be solved by this invention is: a kind of new method of setting embedded system maximum stack space is provided, and method is simple for this, and have fully effectively foundation, reduces the waste to ram space.
The present invention solves the problems of the technologies described above the technical scheme that is adopted to be:
A kind of embedded system maximum stack space establishing method may further comprise the steps:
A, according to the space situation of each task, the stack space largest anticipated value of predetermined this task;
B, by the actual motion of a period of time, obtain the actual maximal value that this task takies stack space;
C, according to described actual maximal value, finally determine the maximum stack space of this task.
Described method, wherein: described step B adopts following method to obtain the actual maximal value of stack space:
When B1, program initialization, the space of distributing to stack all is initialized to a particular value;
B2, after operation a period of time, begin at the bottom of stack direction from stack space largest anticipated value position and search, first position different with described particular value is current use maximum position in the recording stack space;
B3, utilize current use maximum position to deduct the actual maximal value that initial position at the bottom of the stack obtains stack space.
Described method, wherein: described particular value is 0xAA.
Described method, wherein: the final maximum stack space of determining is peaked two times of a described reality.
Beneficial effect of the present invention is: because the present invention sets the maximum stack space of certain task, be to be reference frame with this task in the long period section shared actual maximal value of stack space, therefore neither can cause causing inadequately unusually of stack space, can not waste ram space for fear of overflowing yet, can effectively guarantee the rational Application of ram space, reduce unnecessary cost, reduce cost.Method of the present invention, thinking is original, novel, and simple.
Description of drawings
The position view in fixed stack space when Fig. 1 is initialization;
Fig. 2 is the position view in certain used space of stack in the inventive method.
Embodiment
With embodiment the present invention is described in further detail with reference to the accompanying drawings below:
Basic skills of the present invention is: at first according to the space situation of each task, be scheduled to the stack space largest anticipated value of this task; By the actual motion of a period of time, obtain the actual maximal value that this task takies stack space then; Finally, finally determine the maximum stack space of this task according to described actual maximal value.Referring to Fig. 2, the concrete enforcement of the technical program comprises following step:
1, largest anticipated value of space situation pre-estimation according to each task, it is bigger that this value can be established, bigger can be set to 8192 bytes earlier such as what task took, task is less is made as 4096 bytes earlier, if code is based on certain solution, general solution can provide a recommended value, the largest anticipated value can be made as about 2 times of recommended value.In a word, should give a bigger stack space value earlier, big inadequately if stack space is given, cause stack overflow, can be which task stack is overflowed by emulator, so just can be amplified to proper size to stack space.
2, on the basis of above setting, by the operation of a period of time, each task during this period of time noted takies the actual maximal value of stack.Certain time of certain task maximum space of the stack that takies in service can be got in the following way:
2.1, during program initialization, can all be initialized to certain specific value to the space of distributing to stack in the ram space, such as 0xAA; Being arranged to certain particular value has suitable benefit, can find that first is not that the place of 0xAA is exactly already used place at an end of usefulness never when an end of usefulness is searched.
2.2, after having moved a period of time (such as two days or three days), position (the stack top location shown in Figure 2 of stack space largest anticipated value by from each task initialization the time, be designated as location_task_top) back search, when finding first no position (Fig. 2 stack pointer indication place), be designated as the maximum position location_task_used of current use, because if the space still is 0xAA, show that this space was not rewritten, show that promptly this space is not used, as long as used space once, so just can not be 0xAA.Because initial position has been fixed up when compiling at the bottom of the stack, be designated as location_task, can draw during this period of time already used maximum stack space like this is location_task_used-location_task, and promptly this task takies the actual maximal value of stack space.
3, take the actual maximal value of stack space according to this task, determine the maximum stack space of this task, because need be on stack in some the condition branch extra opening space of program, so according to a preferred embodiment of the present invention, the twice in the maximum stack space that use draws above is as the size of the stack space of opening up in service.
The method of the invention has bigger versatility, at the GSM that wireless access function is provided, PHS, WCDMA, TD-SCDMA, the single mode/multi-mode wireless product that accesses terminal, all can carry out the setting in maximum stack space with the present invention, therefore make things convenient for the user, applied widely, also simple.
Should be understood that; concerning the those of ordinary skill in field, the technology of the present invention place; can be equal to accordingly according to technical scheme of the present invention and design thereof and change or replace, and all these changes or replacement, all should belong to the protection domain of claims of the present invention.

Claims (2)

1. the establishing method in an embedded system maximum stack space may further comprise the steps:
A, according to the space situation of each task, the stack space largest anticipated value of predetermined this task;
When B, program initialization, the space of distributing to stack all is initialized to a particular value; After operation a period of time, begin at the bottom of stack direction from stack space largest anticipated value position and search, first position different with described particular value is current use maximum position in the recording stack space;
Utilize current use maximum position to deduct the actual maximal value that initial position at the bottom of the stack obtains stack space;
C, according to described actual maximal value, finally determine the maximum stack space of this task.
2. method according to claim 1 is characterized in that: the final maximum stack space of determining is peaked two times of a described reality.
CN200710073673XA 2007-03-23 2007-03-23 Initialization method for maximum stack space of embedded system Expired - Fee Related CN101272551B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200710073673XA CN101272551B (en) 2007-03-23 2007-03-23 Initialization method for maximum stack space of embedded system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200710073673XA CN101272551B (en) 2007-03-23 2007-03-23 Initialization method for maximum stack space of embedded system

Publications (2)

Publication Number Publication Date
CN101272551A CN101272551A (en) 2008-09-24
CN101272551B true CN101272551B (en) 2011-04-20

Family

ID=40006183

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200710073673XA Expired - Fee Related CN101272551B (en) 2007-03-23 2007-03-23 Initialization method for maximum stack space of embedded system

Country Status (1)

Country Link
CN (1) CN101272551B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103870244B (en) * 2014-02-21 2017-01-11 北京神舟航天软件技术有限公司 Task stack overflow detection algorithm for SPARC (scalable processor architecture) platform
CN105094991A (en) * 2015-08-21 2015-11-25 北京经纬恒润科技有限公司 Stack capacity setting method and system
CN105808424B (en) * 2016-02-04 2018-08-07 北京空间飞行器总体设计部 A method of being suitable for multi-tasks Software process stacks and uses depth detection
CN107402759B (en) * 2017-07-20 2020-07-17 北京计算机技术及应用研究所 Software system stack analysis method based on AAD L extension accessory

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5603033A (en) * 1993-04-22 1997-02-11 Bull, S.A. Tool for debugging an operating system
CN1286429A (en) * 1999-11-20 2001-03-07 深圳市中兴通讯股份有限公司 Test and monitor method for embedded in processor memory
CN1818862A (en) * 2006-03-02 2006-08-16 浙江大学 Local variable supporting method based on sram in built-in system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5603033A (en) * 1993-04-22 1997-02-11 Bull, S.A. Tool for debugging an operating system
CN1286429A (en) * 1999-11-20 2001-03-07 深圳市中兴通讯股份有限公司 Test and monitor method for embedded in processor memory
CN1818862A (en) * 2006-03-02 2006-08-16 浙江大学 Local variable supporting method based on sram in built-in system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
万逸珠,戚文芽.嵌入式实时操作系统VxWorks的内存管理方案.《信息工程大学学报》.2004,第5卷(第4期),54-56. *

Also Published As

Publication number Publication date
CN101272551A (en) 2008-09-24

Similar Documents

Publication Publication Date Title
CN101272551B (en) Initialization method for maximum stack space of embedded system
CN101221535B (en) Garbage recovery mobile communication terminal of Java virtual machine and recovery method thereof
CN101957770B (en) The starting method of application program and device on a kind of mobile device
CN101727282B (en) Method for achieving interactive interface cartoon
CN210093773U (en) Intelligent server cabinet
CN101533350A (en) Quick switching method for pages
TW200634517A (en) Utilizing paging to support dynamic code updates
CN102609467A (en) Method and device for database connection management
CN105447105A (en) NoSQL-based single field section index query method for distributed Internet of things data
CN203241985U (en) Flexible server BIOS upgrading device
CN101158892A (en) Floating-point data converting device and method
CN102866889A (en) Cross-platform application based intelligent home system
CN104504996B (en) A kind of changeable type guide board and its assemble method
CN103488577A (en) Method and device of memory allocation and batch recovery for user applications based on use numbering
CN103853434A (en) Terminal and menu displaying method thereof
CN103207843A (en) Data line width dynamically-configurable cache structure design method
CN105045585A (en) Operation menu arrangement method and mobile terminal
CN103559280A (en) Method for flexibly storing and displaying icons
CN101504613B (en) Distributed dynamic binary translation method used for limited system
CN103777945A (en) System and method for updating standby application list according to using frequency
CN103955376A (en) Method for DSP (Digital Signal Processor) self-start secondary demand loading
CN100371909C (en) Method for correcting ROM code in embedded system
CN102306104A (en) Method and device for automatically updating application program
CN106502629B (en) Initramfs firmware Compilation Method and system based on openwrt translation and compiling environment
CN204406906U (en) A kind of changeable type guide board

Legal Events

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

Granted publication date: 20110420

Termination date: 20170323