CN101303658B - Communicating method and device based on front/background mission - Google Patents

Communicating method and device based on front/background mission Download PDF

Info

Publication number
CN101303658B
CN101303658B CN2008101286547A CN200810128654A CN101303658B CN 101303658 B CN101303658 B CN 101303658B CN 2008101286547 A CN2008101286547 A CN 2008101286547A CN 200810128654 A CN200810128654 A CN 200810128654A CN 101303658 B CN101303658 B CN 101303658B
Authority
CN
China
Prior art keywords
module
task
situation
message
under
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.)
Active
Application number
CN2008101286547A
Other languages
Chinese (zh)
Other versions
CN101303658A (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 CN2008101286547A priority Critical patent/CN101303658B/en
Publication of CN101303658A publication Critical patent/CN101303658A/en
Application granted granted Critical
Publication of CN101303658B publication Critical patent/CN101303658B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a communication method based on a foreground/background task and a device; the method includes setting step and setting a counter used for counting the information to be treated in the background task; a first judging step: judging whether an enumerated value of the counter is larger than a first threshold or not; when the judging result is yes, setting a flow control symbol, trying to transmit the information again after delaying the information by a first preset time and implementing the first judging step; when the judging result is no, carrying out a second judging step; the second judging step: judging whether the enumerated value of the counter is larger than a second threshold or not; when the judging result is no, transmitting the information to the background task; when the judging result is yes, carrying out a third judging step; the third judging step: judging whether the flow control symbol is set or not; when the judging result is yes, trying to transmit the information again after delaying the information by a second preset time and implementing the first judging step; when the judging result is no, transmitting the information to the background task. The method and the device optimize the use of a CPU.

Description

Communication means and device based on front/rear task
Technical field
The present invention relates to the communications field, in particular to a kind of communication means and device based on front/rear task.
Background technology
In embedded software; usually can use front/rear task and finish the technology of some function; for example; in the task of the high priority of a processing protocol; need to go up written document toward Flash (flash memories) at a slow speed; perhaps need to issue a large amount of list items,, will cause two serious consequences in the task of this high priority if these work are all finished to content-based storer:
The first, central processing unit (Central Processing Unit abbreviates CPU as) is taken by the task of this high priority always, and priority is lower than all tasks of this task and all can not in time carries out;
The second, the prior message that needs this task in time to handle can not in time be handled.
Therefore, in order to address the above problem, need create a task that priority ratio is lower again, promptly, background task, Fig. 1 is the synoptic diagram according to front/rear task relation of correlation technique, as shown in Figure 1, background task is used for handling the work that relatively expends CPU, so, foreground task (that is, originally task) only need be issued background task to these work by message and gets final product, like this, foreground task just can not take CPU for a long time.
The characteristics that adopt front/rear task treatment technology are foreground task priority height, background task priority is low, background task need be provided with the message that a bigger buffer zone comes the buffer memory foreground to send, and these CPU such as message that are cushioned handle when idle again.
As can be seen, utilize the technology of adding background task can solve two problems above-mentioned, but, under extreme case, still can there be some problems in this technology, for example, background task is provided with the buffer zone of 10K size, the message of the sudden transmission of foreground task has taken whole buffer zone, at this moment, because the back buffer district is full, even foreground task has message to need to handle again, also can't issue the backstage to message, can only abandon message, then, report failure result to give upper layer module, many upper layer module (particularly protocol module) all can attempt carrying out once more the action of previous failure after receiving failure result, this will cause the higher foreground task of this priority ratio to take CPU carrying out this action of failure always always, and background task can not be handled message in the buffer zone always because priority is lower.
Therefore, when the foreground task sent excessive message to background task, if the buffer zone of background task is filled up by message, it was unreasonable then can to cause task to take CPU time.The technical scheme that does not also address the above problem at present.
Summary of the invention
The present invention aims to provide a kind of communication means and device based on front/rear task, in order to solve the irrational problem of CPU holding time in front/rear the task communication process.
According to an aspect of the present invention, provide a kind of communication means based on front/rear task.
The communication means based on front/rear task according to the embodiment of the invention comprises: step is set, counter is set, be used for the pending message of background task is counted; First determining step, before sending message toward the backstage task, whether the count value of judging counter is greater than first threshold; In judged result is under the situation that is, with the Flow Control flag set, message delay is attempted after first schedule time sending once more, carries out first determining step; In judged result is under the situation not, proceeds to second determining step; Second determining step, whether the count value of judging counter is greater than second threshold value, and wherein, first threshold is greater than second threshold value; In judged result is under the situation not, and message is sent to background task; In judged result is under the situation that is, proceeds to the 3rd determining step; The 3rd determining step judges whether the Flow Control sign is set; In judged result is under the situation that is, message delay is attempted after second schedule time sending once more, carries out first determining step; In judged result is under the situation not, and message is sent to background task.
Preferably, first schedule time is greater than second schedule time.
Preferably, said method further comprises: handle in background task under the situation of a message, execution subtracts 1 operation to counter.
Preferably, after institute sent to background task with message, said method further comprised: execution adds 1 operation to counter.
Preferably, said method further comprises: second is provided with step, the Flow Control sign is set, wherein, when the Flow Control sign is set, represent that current quantity is the result after the quantity of message pending in the background task reduces, when the Flow Control sign is not set, represent that current quantity is the result after the quantity of message pending in the background task increases.
Preferably, after message is sent to background task, further comprise: under the situation that the Flow Control sign is set, the Flow Control sign is removed.
According to a further aspect in the invention, provide a kind of communicator based on front/rear task.
The communicator based on front/rear task according to the embodiment of the invention comprises: module is set, is used to be provided with counter, wherein, counter is used for the pending message of background task is counted; First judge module was used for before sending message toward the backstage task, and whether the count value of judging counter is greater than first threshold; Second judge module, whether the count value that is used to judge counter is greater than second threshold value, and wherein, first threshold is greater than second threshold value; Maintenance module is used to be provided with the Flow Control sign, and the Flow Control sign is carried out set, clear operation; The 3rd judge module is used to judge whether the Flow Control sign is set; Sending module is used for message is sent to background task; Calling module is used to call each module and carries out relevant treatment.
Preferably, module being set also is used for counter carried out and subtracts 1 or add 1 operation.
Preferably, be under the situation that is in the judged result of first judge module, calling module calls maintenance module the Flow Control sign is carried out set operation, and is postponing to call first judge module once more after first schedule time; Judged result at first judge module is that calling module calls second judge module under the situation not.
Preferably, be under the situation that is in the judged result of second judge module, calling module calls the 3rd judge module; Judged result at second judge module is that calling module calls sending module under the situation not.
Preferably, be under the situation that is in the judged result of the 3rd judge module, calling module is postponing to call first judge module once more after second schedule time, and wherein, first schedule time is greater than second schedule time; Judged result at the 3rd judge module is that calling module calls sending module under the situation not.
Above embodiment utilizes front/rear communication of flow-control mechanism control, overcome when the foreground task is excessive when sending out message to background task, if the buffer zone of background task is filled up by message, it is unreasonable to cause task to take CPU time, perhaps task is switched frequent problem, make foreground task in time abdicate one diplomatic period, give background task the CPU right of execution by Task Delay.
Description of drawings
Accompanying drawing described herein is used to provide further understanding of the present invention, constitutes the application's a part, and illustrative examples of the present invention and explanation thereof are used to explain the present invention, do not constitute improper qualification of the present invention.In the accompanying drawings:
Fig. 1 is the synoptic diagram according to front/rear task relation of correlation technique;
Fig. 2 is the process flow diagram based on the communication means of front/rear task according to the embodiment of the invention;
Fig. 3 is the detail flowchart based on the communication means of front/rear task according to the embodiment of the invention;
Fig. 4 is the block scheme based on the communicator of front/rear task according to the embodiment of the invention.
Embodiment
The present invention utilizes front/rear communication of flow-control mechanism control, there is the right of execution that allows foreground task abdicate CPU to use to background task in the mode of Task Delay (task delay) tactfully, can be smoothly front/rear task take time of CPU, avoid occurring background task because priority is low and can not rationally use the situation of CPU, can also avoid the CPU excessive useless to switch.Below with reference to the accompanying drawings and in conjunction with the embodiments, describe the present invention in detail.
Method embodiment
According to embodiments of the invention, provide a kind of communication means based on front/rear task.Fig. 2 is the process flow diagram based on the communication means of front/rear task according to the embodiment of the invention, and as shown in Figure 2, this method comprises:
Step S202 is provided with step, and counter is set, and is used for the pending message of background task is counted; Promptly, in the method for the embodiment of the invention, at first, needing increases a counter Counter (promptly, the count value of above-mentioned counter) write down the current message count that is untreated, background task is whenever handled a message Counter and is subtracted 1, need to prove, before background task is sent out message, judge the message count value of background task in foreground task;
Step S204, first determining step, before sending message toward the backstage task, whether the count value of judging counter is greater than first threshold; In judged result is under the situation that is, with the Flow Control flag set, message delay is attempted after first schedule time sending once more, carries out first determining step; In judged result is under the situation not, proceeds to second determining step;
Step S206, second determining step, whether the count value of judging counter is greater than second threshold value, and wherein, first threshold is greater than second threshold value; In judged result is under the situation not, and message is sent to background task, counter is carried out add 1 operation, under the situation that the Flow Control sign is set, the Flow Control sign is removed; In judged result is under the situation that is, proceeds to the 3rd determining step;
Step S208, the 3rd determining step judges whether the Flow Control sign is set; In judged result is under the situation that is, message delay is attempted after second schedule time sending once more, carries out first determining step; In judged result is under the situation not, and message is sent to background task, counter is carried out add 1 operation; Wherein, first schedule time is greater than second schedule time.
And, said method further comprises: second is provided with step, the Flow Control sign is set, wherein, when the Flow Control sign is set, represent that current quantity is the result after the quantity of message pending in the background task reduces, when the Flow Control sign is not set, represent that current quantity is the result after the quantity of message pending in the background task increases.
Method below in conjunction with the example in detail embodiment of the invention.
Fig. 3 is the detail flowchart based on the communication means of front/rear task according to the embodiment of the invention, as shown in Figure 3, determines that by the message count value of judging background task the idiographic flow of communication of front/rear task is as follows:
Step S302, judge whether greater than Counter_On (promptly Counter, above-mentioned first threshold), in judged result be under the situation that is (promptly, Counter surpasses Counter_On), carry out step S304, judged result for situation not under (promptly, Counter is no more than Counter_On), carry out step S306;
Step S304, foreground task postpones (Task Delay) one period long period (for example 2000 milliseconds), and then attempts sending, execution in step S302, and, represent the current Flow Control state that is in the Flow Control flag set;
Step S306 judges that Counter is whether between Counter_On and Counter_Off (that is above-mentioned second threshold value), in judged result is under the situation that is, carries out step S308, judged result for situation not under (promptly, Counter is lower than Counter_Off), carry out step S312;
Step S308 judges whether the Flow Control sign is set, and is under the situation that is in judged result, carries out step S310, is under the situation not (that is, Counter is lower than Counter_Off) in judged result, carries out step S312;
Step S310, one period short period of foreground task Task Delay (for example 500 milliseconds), and then attempt sending execution in step S302;
Step S312 message is issued background task handle, and Counter adds 1, if the Flow Control sign is set, then removes the Flow Control sign.
Device embodiment
According to a further aspect in the invention, provide a kind of communicator based on front/rear task.Fig. 4 is the block scheme based on the communicator of front/rear task according to the embodiment of the invention, and as shown in Figure 4, this device comprises:
Module 402 is set, is used to be provided with counter, wherein, counter is used for the pending message of background task is counted; Also be used for counter carried out and subtract 1 or add 1 operation;
First judge module 404 is connected to module 402 is set, and is used for before sending message toward the backstage task, and whether the count value of judging counter is greater than first threshold;
Second judge module 406 is connected to module 402 is set, and whether the count value that is used to judge counter is greater than second threshold value, and wherein, first threshold is greater than second threshold value;
Maintenance module 408 is used to be provided with the Flow Control sign, and the Flow Control sign is carried out set, clear operation;
The 3rd judge module 410 is connected to maintenance module 408, is used to judge whether the Flow Control sign is set;
Sending module 412 is used for message is being sent to background task;
Calling module 414 is connected to first judge module 404, second judge module 406, maintenance module 408, the 3rd judge module 410, sending module 412, is used to call each module and carries out relevant treatment.
Preferably, said apparatus further comprises: second is provided with the module (not shown), be used to be provided with the Flow Control sign, wherein, when the Flow Control sign is set, the quantity of the pending message of expression background task is for dropping to current quantity, and when the Flow Control sign was not set, the quantity of the pending message of expression background task was for rising to current quantity.
Concrete operations to above judge module are described in detail below.
(1) judged result at first judge module is under the situation that is, calling module calls maintenance module the Flow Control sign is carried out set operation, and is postponing to call first judge module once more after first schedule time; Judged result at first judge module is that calling module calls second judge module under the situation not;
(2) judged result at second judge module is under the situation that is, calling module calls the 3rd judge module; Judged result at second judge module is that calling module calls sending module under the situation not;
(3) judged result at the 3rd judge module is under the situation that is, calling module is postponing to call first judge module once more after second schedule time, and wherein, first schedule time is greater than second schedule time; Judged result at the 3rd judge module is that calling module calls sending module under the situation not.
In above embodiments of the invention, utilize front/rear communication of flow-control mechanism control, there is the right of execution that allows foreground task abdicate CPU to use to background task in the mode of Task Delay tactfully, smoothly the AM/BAM task takies the time of CPU, avoid background task because the low situation that can not rationally use CPU of priority can also avoid the CPU excessive useless to switch.
Obviously, those skilled in the art should be understood that, above-mentioned each module of the present invention or each step can realize with the general calculation device, they can concentrate on the single calculation element, perhaps be distributed on the network that a plurality of calculation element forms, alternatively, they can be realized with the executable program code of calculation element, thereby, they can be stored in the memory storage and carry out by calculation element, perhaps they are made into each integrated circuit modules respectively, perhaps a plurality of modules in them or step are made into the single integrated circuit module and realize.Like this, the present invention is not restricted to any specific hardware and software combination.
The above is the preferred embodiments of the present invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (10)

1. the communication means based on front/rear task is characterized in that, comprising:
Step is set, counter is set, be used for the pending message of background task is counted;
First determining step, before sending message toward the backstage task, whether the count value of judging described counter is greater than first threshold; In judged result is under the situation that is, with the Flow Control flag set, described message delay is attempted after first schedule time sending once more, carries out described first determining step; In judged result is under the situation not, proceeds to second determining step;
Whether described second determining step, the count value of judging described counter be greater than second threshold value, and wherein, described first threshold is greater than described second threshold value; In judged result is under the situation not, and described message is sent to described background task; In judged result is under the situation that is, proceeds to the 3rd determining step;
Described the 3rd determining step judges whether the Flow Control sign is set; In judged result is under the situation that is, described message delay is attempted after second schedule time sending once more, carries out described first determining step; In judged result is under the situation not, and described message is sent to described background task.
2. communication means according to claim 1 is characterized in that:
Described first schedule time is greater than described second schedule time.
3. communication means according to claim 1 is characterized in that, further comprises:
Handle in described background task under the situation of a message, described counter execution is subtracted 1 operation.
4. communication means according to claim 1 is characterized in that, after institute sends to described background task with described message, further comprises:
Described counter execution is added 1 operation.
5. according to each described communication means in the claim 1 to 4, it is characterized in that, after described message is sent to described background task, further comprise:
Under the situation that described Flow Control sign is set, described Flow Control sign is removed.
6. the communicator based on front/rear task is characterized in that, comprising:
Module is set, is used to be provided with counter, wherein, described counter is used for the pending message of background task is counted;
First judge module was used for before sending message toward the backstage task, and whether the count value of judging described counter is greater than first threshold;
Whether second judge module, the count value that is used to judge described counter be greater than second threshold value, and wherein, described first threshold is greater than described second threshold value;
Maintenance module is used to be provided with the Flow Control sign, and described Flow Control sign is carried out set, clear operation;
The 3rd judge module is used to judge whether described Flow Control sign is set;
Sending module is used for described message is sent to described background task;
Calling module is used to call each module and carries out relevant treatment.
7. communicator according to claim 6 is characterized in that, the described module that is provided with also is used for described counter carried out and subtracts 1 or add 1 operation.
8. according to claim 6 or 7 described communicators, it is characterized in that:
Judged result at described first judge module is under the situation that is, described calling module calls described maintenance module described Flow Control sign is carried out set operation, and is postponing to call described first judge module once more after first schedule time; Judged result at described first judge module is that described calling module calls described second judge module under the situation not.
9. according to claim 6 or 7 described communicators, it is characterized in that:
Judged result at described second judge module is under the situation that is, described calling module calls described the 3rd judge module; Judged result at described second judge module is that described calling module calls described sending module under the situation not.
10. according to claim 6 or 7 described communicators, it is characterized in that:
Judged result at described the 3rd judge module is under the situation that is, described calling module is postponing to call described first judge module once more after second schedule time, and wherein, described first schedule time is greater than described second schedule time; Judged result at described the 3rd judge module is that described calling module calls described sending module under the situation not.
CN2008101286547A 2008-06-18 2008-06-18 Communicating method and device based on front/background mission Active CN101303658B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2008101286547A CN101303658B (en) 2008-06-18 2008-06-18 Communicating method and device based on front/background mission

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2008101286547A CN101303658B (en) 2008-06-18 2008-06-18 Communicating method and device based on front/background mission

Publications (2)

Publication Number Publication Date
CN101303658A CN101303658A (en) 2008-11-12
CN101303658B true CN101303658B (en) 2011-09-21

Family

ID=40113575

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2008101286547A Active CN101303658B (en) 2008-06-18 2008-06-18 Communicating method and device based on front/background mission

Country Status (1)

Country Link
CN (1) CN101303658B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103546386A (en) * 2013-10-24 2014-01-29 迈普通信技术股份有限公司 Method and system for flow control over data message sent by router
CN106020980A (en) * 2015-05-21 2016-10-12 中国科学院计算技术研究所 Virtual desktop oriented VCPU (Virtual Central Processing Unit) scheduling method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1245922A (en) * 1998-03-10 2000-03-01 朗迅科技公司 Context controller with time slice task switching capability and its application processor
US6260150B1 (en) * 1998-03-10 2001-07-10 Agere Systems Guardian Corp. Foreground and background context controller setting processor to power saving mode when all contexts are inactive
CN101035349A (en) * 2007-04-04 2007-09-12 中兴通讯股份有限公司 System and method for processing the signaling message report

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1245922A (en) * 1998-03-10 2000-03-01 朗迅科技公司 Context controller with time slice task switching capability and its application processor
US6260150B1 (en) * 1998-03-10 2001-07-10 Agere Systems Guardian Corp. Foreground and background context controller setting processor to power saving mode when all contexts are inactive
CN101035349A (en) * 2007-04-04 2007-09-12 中兴通讯股份有限公司 System and method for processing the signaling message report

Also Published As

Publication number Publication date
CN101303658A (en) 2008-11-12

Similar Documents

Publication Publication Date Title
CN100450081C (en) Method and system for carrying out flow-control
CN101599987A (en) message queue management method and device
CN103080920A (en) A system and methods for multi-tasking in a clientless mobile phone
CN102447610B (en) Method and device for realizing message buffer resource sharing
CN103076977B (en) A kind of method and system of the transmission of trigger message in the standby state
CN101924679A (en) Message rate-limiting method of Ethernet port, device and data communication device
CN101950261A (en) Data storage/authentication parallel processing method and terminal
CN106250250A (en) Data communications method and device
CN101783846A (en) Charging service processing method and charging gateway
CN102263701A (en) Queue regulation method and device
CN101303658B (en) Communicating method and device based on front/background mission
CN102487494B (en) Short message flow control method and system
CN102984077A (en) Network congestion control method and system
EP3588993B1 (en) Broadcast sending method and terminal
CN101188560A (en) Method and device for dynamically detecting forward capability
CN101764712A (en) System and method for transmitting log information
CN102811176B (en) A kind of data flow control method and device
CN101340633B (en) Value increasing service message overload control apparatus and method
CN103607360A (en) Message processing method, line card and switching equipment
CN103442415A (en) Data sending method and mobile terminal
CN102960000A (en) Method, system, managingand controlling device, and terminal equipemtn for sending message
CN104580095A (en) API resource acquisition method and device
CN102340580A (en) Mobile phone and method for preventing repeated sending of mobile phone by using same
CN101951574A (en) Short message processing method and short message center
CN101997777A (en) Interruption processing method, device and network equipment

Legal Events

Date Code Title Description
PB01 Publication
C06 Publication
SE01 Entry into force of request for substantive examination
C10 Entry into substantive examination
GR01 Patent grant
C14 Grant of patent or utility model