Summary of the invention
The invention provides and forward resource access method and route system, to avoid adopting traditional spin lock to control the problem that multinuclear brings forwarding the resource exclusive reference.
Technical scheme provided by the invention comprises:
A kind of forwarding resource access method, the method are applied to comprise main core and from the multinuclear route system of core, the method comprises:
The exclusive reference lock of configuration pin to whole forwarding resource table, exist each from checking request position and the response bits of answering in described exclusive reference lock;
Each detects described exclusive reference lock the request position of self correspondence from core, and current whether value is the first set point, if not, utilize the forwarding resource in described forwarding resource table to carry out the message repeating processing, if, when the current not value of response bits of self correspondence is the second set point in described exclusive reference lock, the response bits value that self correspondence is set in described exclusive reference lock is the second set point, and returning to the request position of detecting in described exclusive reference lock self correspondence, current whether value is the first set point;
Described main core to described forwarding resource table, write while forwarding resource first remove described exclusive reference lock in each second set point of getting from checking the response bits of answering, arrange afterwards that in described exclusive reference lock, each is the first set point from checking the request position value of answering, and whether the response bits of answering is current is set to the second set point by this each from core from checking to detect in described exclusive reference lock each, if, carry out to described forwarding resource table and write the operation that forwards resource, and after writing and forwarding resource and complete, remove in described exclusive reference lock the first set point that each is got from checking the request position of answering, if not, return and detect in described exclusive reference lock, whether each is set to the second set point by this each from core from checking the response bits of answering.
A kind of route system, this route system comprise main core and a plurality of from core; Its key is, this route system also comprises: exclusive reference lock dispensing unit;
Described exclusive reference lock dispensing unit, for the exclusive reference lock of configuration pin to whole forwarding resource table, exists each from checking request position and the response bits of answering in described exclusive reference lock;
Each comprises from core: the first detecting unit, retransmission unit and the first setting unit;
Wherein, described the first detecting unit, current whether value is the first set point from checking the request position of answering for detection of self place in described exclusive reference lock;
Described retransmission unit, while for the testing result at described the first detecting unit, being no, utilize the forwarding resource in described forwarding resource table to carry out the message repeating processing;
Described the first setting unit, for in the testing result of described the first detecting unit when being, when self place is the second set point from checking the current not value of the response bits of answering in described exclusive reference lock, it is the second set point from checking the response bits value of answering that self place is set in described exclusive reference lock, and triggers described the first detecting unit and continue to carry out and detect;
Described main core comprises: clearing cell, the second setting unit, the second detecting unit and r/w cell;
Wherein, described clearing cell, at its residing main core, writing while forwarding resource and first remove each second set point of getting from checking the response bits of answering of described exclusive reference lock to described forwarding resource table, and send and notice be set to described the second setting unit; And after receiving and removing notice, removes described exclusive reference lock in each first set point of getting from checking the request position of answering;
Described the second setting unit, be used to receive described notice is set after, arrange that in described exclusive reference lock, each is the first set point from checking the request position value of answering, and send and detect notice to described the second detecting unit;
Described the second detecting unit, after receiving described detection notice, whether the response bits of answering is current is set to the second set point by this each from core from checking to detect in described exclusive reference lock each, if testing result is no, continues to carry out to detect;
Described r/w cell,, carry out to described forwarding resource table and write the operation that forwards resource when being for the testing result at described the second detecting unit, and, after writing and forwarding resource and complete, send and remove notice to described clearing cell.
As can be seen from the above technical solutions, in the present invention, by main core to described forwarding resource table, write while forwarding resource first remove described exclusive reference lock in each second set point of getting from checking the response bits of answering, arrange afterwards that in described exclusive reference lock, each is the first set point from checking the request position value of answering, can find out that this master checks the write access that forwards resource and needs mutual exclusion, but, this mutual exclusion does not need to refresh cache zone corresponding to described exclusive reference lock, each is the first set point from checking the request position value of answering and just arrange in described exclusive reference lock, and, for each from core, this each when core only is the first set point according to the current not value in request position of self correspondence described exclusive reference lock, utilize the forwarding resource in described forwarding resource table to carry out the message repeating processing, namely from check forward resource read access without mutual exclusion, these are obviously different from traditional spin lock control forwarding resource exclusive reference, avoided adopting traditional spin lock to control the problem that multinuclear brings forwarding the resource exclusive reference fully.
Embodiment
In order to make the purpose, technical solutions and advantages of the present invention clearer, describe the present invention below in conjunction with the drawings and specific embodiments.
Flow process provided by the invention can comprise step shown in Figure 1:
Referring to Fig. 1, the flow chart that Fig. 1 provides for the embodiment of the present invention.This flow process is applied to comprise main core and from the multinuclear route system of core, and wherein, main core operation system, be used to being in charge of and setting up the forwarding resource, from core operation system not, utilize described forwarding resource to carry out message repeating be used to being responsible for.
As shown in Figure 1, this flow process can comprise the following steps:
Step 101, the exclusive reference lock of configuration pin to whole forwarding resource table, exist each from checking request position and the response bits of answering in described exclusive reference lock.
Here, forward resource table for depositing the forwarding resource, the exclusive reference lock of configuration pin to whole forwarding resource table, be exclusive reference lock of all forwarding resource distributions.If be applied under at least one AMP pattern that forwards the resource person of writing, a plurality of forwarding resource readers, under this AMP pattern, all forwarding resources only have an exclusive reference lock, not for each, forward resource and configure respectively an exclusive reference lock.
Below for ease of describing, can be called for short the exclusive reference lock and be biglock.
Step 102, each detects biglock the request position of self correspondence from core, and current whether value is the first set point, if not, utilize the forwarding resource in described forwarding resource table to carry out the message repeating processing, if, when the current not value of response bits of self correspondence was the second set point in biglock, the response bits value that self correspondence is set in biglock was the second set point, and returning to the request position of detecting in biglock self correspondence, current whether value is the first set point.
In this step 102, each can be carried out from the current operation whether value is the first set point in request position that core detects described exclusive reference lock self correspondence after the forwarding that completes a message, can before the forwarding that starts a message, carry out, the present invention does not specifically limit yet.
Step 103, main core to described forwarding resource table, write while forwarding resource first remove biglock in each second set point of getting from checking the response bits of answering, arrange afterwards that in biglock, each is the first set point from checking the request position value of answering, and whether the response bits of answering is current is set to the second set point by this each from core from checking to detect in biglock each, if, carry out to described forwarding resource table and write the operation that forwards resource, if not, return and detect in biglock, whether each is set to the second set point by this each from core from checking the response bits of answering.
In step 102 and step 103, the first set point, the second set point value have nothing to do, and both can equate, such as being 1, also can not wait, and such as a value is 0, another value is 1, and the present invention does not specifically limit.
In addition, in this step 103, described main core is removed in biglock each and comprised from the second set point of checking the response bits of answering and getting: it is other values from the second set point of checking the response bits of answering and getting that described main core upgrades biglock each.Described main core is removed in described exclusive reference lock each and comprised from the first set point of checking the request position of answering and getting: it is other values from the first set point of checking the request position of answering and getting that described main core upgrades described exclusive reference lock each
Also have, in this step 103, why main core arranges that in described exclusive reference lock, each is the first set point from checking the request position value of answering, purpose is in order to mean the current biglock that just asking of this main core, like this, prevent from also asking biglock from core, realize that main core writes the exclusive reference that forwards resource.And, when main core detects in biglock that each is set to second set point by this each from core from checking the response bits of answering, mean that main core successfully gets biglock, can carry out to described forwarding resource table and write the operation that forwards resource.
So far, complete flow process shown in Figure 1.
From flow process shown in Figure 1, can find out, in the present invention, from check forward resource read access without mutual exclusion, only need the main write access mutual exclusion that forwards resource of checking, and this mutual exclusion does not need cache zone corresponding to biglock frequently refreshed, this has been avoided adopting traditional spin lock to control the problem that multinuclear brings forwarding the resource exclusive reference fully.
Above method provided by the invention is described, below route system provided by the invention is described:
Referring to Fig. 2, the route system structure chart that Fig. 2 provides for the embodiment of the present invention.As shown in Figure 2, this route system comprises main core and a plurality of from core; Its key is, this route system also comprises: exclusive reference lock dispensing unit.
Wherein, described exclusive reference lock dispensing unit is for the exclusive reference lock of configuration pin to whole forwarding resource table, and described exclusive reference exists each from checking request position and the response bits of answering in locking;
And each is from core, as shown in Figure 2, can comprise with lower unit: the first detecting unit, retransmission unit and the first setting unit;
Wherein, described the first detecting unit, current whether value is the first set point from checking the request position of answering for detection of self place in described exclusive reference lock; Wherein, it is to carry out after described retransmission unit completes the forwarding of a message from checking the current operation whether value is the first set point in the request position of answering that described the first detecting unit detects in described exclusive reference lock self place, or at described retransmission unit, start to carry out before the forwarding of a message, the present invention does not limit.
Described retransmission unit, while for the testing result at described the first detecting unit, being no, utilize the forwarding resource in described forwarding resource table to carry out the message repeating processing;
Described the first setting unit, for in the testing result of described the first detecting unit when being, when self place is the second set point from checking the current not value of the response bits of answering in described exclusive reference lock, it is the second set point from checking the response bits value of answering that self place is set in described exclusive reference lock, and triggers described the first detecting unit and continue to carry out and detect;
As for described main core, as shown in Figure 2, this master endorses and comprises with lower unit: clearing cell, the second setting unit, the second detecting unit and r/w cell;
Wherein, described clearing cell, at its residing main core, writing while forwarding resource and first remove each second set point of getting from checking the response bits of answering of described exclusive reference lock to described forwarding resource table, and send and notice be set to described the second setting unit; And after receiving and removing notice, removes described exclusive reference lock in each first set point of getting from checking the request position of answering;
Described the second setting unit, be used to receive described notice is set after, arrange that in described exclusive reference lock, each is the first set point from checking the request position value of answering, and send and detect notice to described the second detecting unit;
Described the second detecting unit, after receiving described detection notice, whether the response bits of answering is current is set to the second set point by this each from core from checking to detect in described exclusive reference lock each, if testing result is no, continues to carry out to detect;
Described r/w cell,, carry out to described forwarding resource table and write the operation that forwards resource when being for the testing result at described the second detecting unit, and, after writing and forwarding resource and complete, send and remove notice to described clearing cell.
It should be noted that, in the present invention, described the first set point is identical with described the second set point, or different.
In addition, in the present invention, described clearing cell is removed in described exclusive reference lock each and can be comprised from the second set point of checking the response bits of answering and getting: it is other values from the second set point of checking the response bits of answering and getting that described clearing cell is upgraded described exclusive reference lock each;
Described clearing cell is removed in described exclusive reference lock each and comprised from the first set point of checking the request position of answering and getting: it is other values from the first set point of checking the request position of answering and getting that described clearing cell is upgraded described exclusive reference lock each.
So far, completing route system provided by the invention describes.
As can be seen from the above technical solutions, in the present invention, by main core to described forwarding resource table, write while forwarding resource first remove described exclusive reference lock in each second set point of getting from checking the response bits of answering, arrange afterwards that in described exclusive reference lock, each is the first set point from checking the request position value of answering, can find out that this master checks the write access that forwards resource and needs mutual exclusion, but, this mutual exclusion does not need to refresh cache zone corresponding to described exclusive reference lock, each is the first set point from checking the request position value of answering and just arrange in described exclusive reference lock, and, for each from core, this each when core only is the first set point according to the current not value in request position of self correspondence described exclusive reference lock, utilize the forwarding resource in described forwarding resource table to carry out the message repeating processing, namely from check forward resource read access without mutual exclusion, these are obviously different from traditional spin lock control forwarding resource exclusive reference, avoided adopting traditional spin lock to control the problem that multinuclear brings forwarding the resource exclusive reference fully.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of making, be equal to replacement, improvement etc., within all should being included in the scope of protection of the invention.