Background technology
Along with the continuous lifting of physical interface speed, the forwarding of CPU nuclear (core) number also increases thereupon in the route system.In route system, each of CPU transmitted nuclear and transmitted through concurrent working mode parallel processing message, in the hope of improving message forwarding performance.But, when a plurality of forwarding nuclears are visited identical code district (being designated as shared resource) simultaneously,, need a plurality of forwardings of realization to check the exclusive reference of shared resource for avoiding conflict, this exclusive reference can not embody the advantage that multi-core parallel concurrent is carried out.
In order to embody the advantage that multi-core parallel concurrent is carried out, just need avoid the exclusive reference of shared resource.Prior art provides following method to replace the exclusive reference of shared resource: through the visit of resource pointer control shared resource.Can be in the time of should specifically realizing through the visit of resource pointer control shared resource: when reading shared resource,, can directly visit through the resource pointer without mutual exclusion; And when writing shared resource also without mutual exclusion, promptly at first copy a shared resource, on the shared resource of copy, carry out write operation then, new resources pointer more after write operation is accomplished lets it point to the shared resource of new copy.
As for original shared resource, it needs to discharge.Wherein, this release resource is based on the delay memory method for releasing of time, promptly counts from the time point of above-mentioned more new resources pointer, after postponing a period of time, discharges original shared resource.The time of this delay is static appointment, like 1 second or 10 seconds etc.
But; This time-based delay memory method for releasing is a poor efficiency or even insecure; Because the time that postpones is static appointment, if the time of delay of appointment is too short, so when arrive in this time of delay; Also can exist this resource to be discharged to also have the possibility of being visited, this influences resource access; If the time of delay of appointment is long, will certainly in a period of time, reduce the quantity of the available free memory of system so, cause the waste of resource.
Summary of the invention
The invention provides internal memory method for releasing and route system, with the poor efficiency of avoiding time-based delay memory method for releasing to be brought, even not reliable defective.
Technical scheme provided by the invention comprises:
A kind of internal memory method for releasing comprises:
All forwarding nuclears in the route system are organized according to the rule of setting successively;
Each transmits nuclear after the resource of new resources pointed more, and the resource that this resource pointer was pointed to before upgrading is as the resource that needs discharge, and deposits to transmit the resource that nuclear is assigned with to the next one and discharge in the formation;
The resource that each forwarding nuclear inspection self is assigned with discharges the resource whether formation exists needs to discharge; If then take out the resource that each need discharge successively, and judge that whether this resource is because self more resource and resource that definite needs discharge of new resources pointed; If; Then discharge this resource, otherwise, this resource is continued to deposit the resource that is assigned with to next one forwarding nuclear as the resource that needs discharge discharge in the formation.
A kind of route system comprises: OU, dispensing unit and a plurality of forwarding nuclear, wherein,
Said OU is used for all forwarding nuclears of route system are organized according to the rule of setting;
Said dispensing unit is used to each and transmits nuclear distributing independent resource release formation;
Each is transmitted nuclear and comprises: first processing unit and second processing unit, wherein,
Said first processing unit; Be used for after the resource of new resources pointed is more examined in its residing forwarding; The resource that this resource pointer was pointed to before upgrading is as the resource that needs discharge, and deposits to the next one of this forwardings nuclear and transmits in the resource release formation that nuclear is assigned with;
Said second processing unit; Be used to check that the resource that its residing forwarding nuclear is assigned with discharges the resource whether formation exists needs to discharge; If then take out the resource that each need discharge successively, and judge that whether this resource is the resource that definite needs discharge because the resource of new resources pointed is more examined in its residing forwarding; If; Then discharge this resource, otherwise, this resource is continued to deposit the resource that is assigned with to the next one forwarding nuclear of this forwarding nuclear as the resource that needs discharge discharge in the formation.
Can find out by above technical scheme; Among the present invention; Each transmit nuclear at it because the resource of new resources pointed and resource that definite needs discharge just discharges this resource after transmitting nuclear through all is more promptly transmitted at all just in time to discharge this resource when nuclear is not visited this resource, this one side can not influence resource access; Also can in time discharge resource on the other hand; Can not cause the waste of resource, poor efficiency, the even reliable defective of avoiding time-based delay memory method for releasing to be brought, poor efficiency, the even reliable defective of having avoided time-based delay memory method for releasing to be brought fully.
Embodiment
In order to make the object of the invention, technical scheme and advantage clearer, describe the present invention below in conjunction with accompanying drawing and specific embodiment.
Referring to Fig. 1, the basic flow sheet that Fig. 1 provides for the embodiment of the invention.As shown in Figure 1, this flow process can may further comprise the steps:
Step 101 is organized according to the rule of setting all the forwarding nuclears in the route system successively.
Can be during this step 101 concrete realizations all forwarding nuclear is formed a ring successively according to the order of setting.
Wherein, all forwarding nuclears are formed a ring successively according to the order of setting specifically can be: all the forwarding nuclears in the route system are numbered in order, if all in the route system are transmitted nuclear are: core-1; Core-2; ... core-N, then can all transmit nuclear numbering in order to this since a predefined initial value such as 1, such as; Be numbered from 1 to N, afterwards all transmitted nuclear and form a ring successively according to the numbering size.Wherein, all forwarding nuclears are formed a ring successively according to the numbering size and can comprise following arbitrary situation:
Situation 1: clockwise all are transmitted nuclear according to the ascending order of the numbering of transmitting nuclear and form a ring.All forwarding nuclears with in the route system are core-1, core-2 ... core-N, what this each forwarding was examined is numbered 1,2 ... N, based on this, clockwise can be as shown in Figure 2 according to the order that numbering is ascending with ring of all forwarding nuclear compositions.
Situation 2: clockwise all are transmitted nuclear according to the descending order of the numbering of transmitting nuclear and form a ring.All forwarding nuclears with in the route system are core-1, core-2 ... core-N, what this each forwarding was examined is numbered 1,2 ... N, based on this, clockwise can be as shown in Figure 3 according to the order that numbering is descending with ring of all forwarding nuclear compositions.
Step 102, each transmits nuclear after the resource of new resources pointed more, and the resource that this resource pointer was pointed to before upgrading is as the resource that needs discharge, and deposits to transmit the resource that nuclear is assigned with to the next one and discharge in the formation.
Based on above-described all forwarding nuclears in the route system are organized according to the rule of setting; Be all to be transmitted nuclear form a ring successively according to the order of setting; Can obtain, the next one in this step 102 is transmitted nuclear and is current forwarding nuclear perhaps anticlockwise along clockwise direction adjacent forwarding nuclear in ring.
In addition, in this step 102, transmitting resource that nuclear is assigned with, to discharge formation be pre-assigned, and resource discharges formation and is used to deposit the resource that needs discharge, and according to the resource of its needs of depositing release of first in first out (FIFO:First In First Out) tissue.Wherein, it is separate that the resource release formation that is assigned with is examined in each forwarding.
With Fig. 2 is example; If in this step 102; Core-1 is the resource of new resources pointed more, and then this core-1 deposits the resource that this resource pointer pointed to the resource that core-2 was assigned with release formation shown in Figure 2 as the resource of needs release before upgrading.
Step 103, the resource that each forwarding nuclear inspection self is assigned with discharges the resource whether formation exists needs to discharge, if; Then take out the resource that each need discharge successively; And judge that whether this resource is because self more resource and resource that definite needs discharge of new resources pointed, if then discharge this resource; Otherwise, this resource is continued to deposit the resource that is assigned with to next one forwarding nuclear as the resource that needs discharge discharges in the formation.
In this step 103, the resource that each forwarding nuclear inspection self is assigned with discharges the operation whether formation exists the resource of needs release, is after the processing message is perhaps handled message before, to carry out, and the present invention is specifically qualification.
So far, accomplish flow process shown in Figure 1.
Can find out from flow process shown in Figure 1; Among the present invention; Each transmit nuclear at it because the resource of new resources pointed and resource that definite needs discharge just discharges this resource after transmitting nuclear through all more; Promptly when all forwarding nuclears are not visited this resource, just in time do not discharge this resource, this can not influence resource access on the one hand, can in time discharge resource on the other hand yet; Can not cause the waste of resource, poor efficiency, the even not reliable defective of avoiding time-based delay memory method for releasing to be brought.
So far, accomplish method provided by the invention and describe, describe in the face of route system provided by the invention down:
Referring to Fig. 4, the route system structure chart that Fig. 4 provides for the embodiment of the invention.As shown in Figure 4, this route system comprises: OU, dispensing unit and a plurality of forwarding nuclear, wherein,
Said OU is used for all forwarding nuclears of route system are organized according to the rule of setting;
Said dispensing unit is used to each and transmits nuclear distributing independent resource release formation; Particularly, to discharge formation be the resource that the needs according to the mode organize of FIFO discharge for each resource.
Each is transmitted nuclear and comprises: first processing unit and second processing unit, wherein,
Said first processing unit; Be used for after the resource of new resources pointed is more examined in its residing forwarding; The resource that this resource pointer was pointed to before upgrading is as the resource that needs discharge, and deposits to the next one of this forwardings nuclear and transmits in the resource release formation that nuclear is assigned with;
Said second processing unit; Be used to check that the resource that its residing forwarding nuclear is assigned with discharges the resource whether formation exists needs to discharge; If then take out the resource that each need discharge successively, and judge that whether this resource is the resource that definite needs discharge because the resource of new resources pointed is more examined in its residing forwarding; If; Then discharge this resource, otherwise, with this resource continue as the resource that needs discharge deposit to this forwardings nuclear the next one transmit in the resource release formation that nuclear is assigned with.Wherein, said second processing unit is to check before handling message or after handling message that the resource that its residing forwarding nuclear is assigned with discharges the resource whether formation exists needs to discharge.
Particularly, among the present invention, said OU is organized according to the rule of setting all the forwarding nuclears in the route system, is all to be transmitted nuclear form a ring successively according to the order of setting; Correspondingly, the said next nuclear of transmitting is current forwarding nuclear perhaps anticlockwise along clockwise direction adjacent forwarding nuclear in ring.
Preferably, among the present invention, said OU is organized according to the rule of setting all the forwarding nuclears in the route system, is meant:
Clockwise all are transmitted nuclear according to the ascending order of the numbering of transmitting nuclear and form a ring; Perhaps,
Clockwise all are transmitted nuclear according to the descending order of the numbering of transmitting nuclear and form a ring.
So far, accomplish route system structrual description provided by the invention.
Can find out by above technical scheme; Among the present invention; In the ring each transmit nuclear at it because more the resource of new resources pointed and resource that definite needs discharge just discharge this resource after transmitting nuclear through all of whole ring; Promptly when all forwarding nuclears are not visited this resource, just in time do not discharge this resource, this can not influence resource access on the one hand, can in time discharge resource on the other hand yet; Can not cause the waste of resource, poor efficiency, the even not reliable defective of avoiding time-based delay memory method for releasing to be brought.
The above is merely preferred embodiment of the present invention, and is in order to restriction the present invention, not all within spirit of the present invention and principle, any modification of being made, is equal to replacement, improvement etc., all should be included within the scope that the present invention protects.