METHOD FOR PREVENTING PROCESS COLLISION OF MICRO CONTROLLER

Information

  • Patent Application
  • 20070288928
  • Publication Number
    20070288928
  • Date Filed
    August 03, 2006
    19 years ago
  • Date Published
    December 13, 2007
    18 years ago
Abstract
A method for preventing process collision of a micro controller is disclosed. The method includes the following steps. At least a first process and a second process are provided, wherein the first process is executed by the micro controller in every first period, the second process is executed by the micro controller in every second period, and the first period is shorter than the second period. When collision of the first process and the second process may happen in the second period, the executing time of the second process is shifted a predetermined time.
Description

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings are included to provide a further understanding of the invention, and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.



FIG. 1 is a flowchart illustrating the method for preventing process collision of a micro controller according to an embodiment of the present invention.



FIG. 2 is a timing diagram of the processes according to the embodiment illustrated in FIG. 1.



FIG. 3 is a flowchart illustrating the method for preventing process collision of a micro controller according to an embodiment of the present invention.



FIG. 4 and FIG. 5 are distribution diagrams of the processes in the embodiment as illustrated in FIG. 3.





DESCRIPTION OF EMBODIMENTS


FIG. 1 is a flowchart illustrating the method for preventing process collision of a micro controller according to an embodiment of the present invention. FIG. 2 is a timing diagram of the processes according to the embodiment illustrated in FIG. 1. Referring to FIG. 1, first, a first process and a second process are provided, wherein the first process is executed by the micro controller in every first period (for example 5 ms), and the second process is executed by the micro controller in every second period (for example 10 ms) (step 101). Whether collision of the first process and the second process will happen in the second period (10 ms) is determined (step 102). When collision of the first process and the second process will happen in the second period (10 ms), the executing time of the second process is shifted a predetermined time (for example 2 ms) (step 103), as shown in FIG. 2.


A possible pattern of the method for preventing process collision of micro controller has been introduced in the foregoing embodiment. Below, another embodiment with 8 processes will be explained so that those skilled in the art can easily implement the present invention.



FIG. 3 is a flowchart illustrating the method for preventing process collision of a micro controller according to an embodiment of the present invention. FIG. 4 and FIG. 5 are distribution diagrams of the processes in the embodiment as illustrated in FIG. 3. First, 8 processes are provided, and the micro controller is used for processing the 8 processes. The 1st process is executed every 5 ms, the 2nd process is executed every 10 ms, the 3rd process is executed every 20 ms, the 4th process is executed every 50 ms, the 5th process is executed every 100 ms, the 6th process is executed every 300 ms, the 7th process is executed every 500 ms, and the 8th process is executed every 1000 ms (step 301). The 8 processes respectively correspond to 8 execution periods, and the 8 execution periods have a greatest common divisor 3000 ms.


Whether process collision will happen at the least common multiple time of the foregoing 8 execution periods is determined (step 302). When process collision will happen at the least common multiple time of the 8 execution periods, the execution of the Ith process is delayed I times of the predetermined time (step 303). For example, the 1st process is delayed 1 ms, the 2nd process is delayed 2 ms etc. Next, whether the delay times of the foregoing 8 processes are equal to multiples of the greatest common divisor is determined (step 304). When it is determined that the delayed of the 6th process (5 ms) is equal to the greatest common divisor of said 8 execution period, the processes 6˜8 are respectively delayed 1 ms (step 305), here the 6th process is delayed 6 ms, the 7th process is delayed 7 ms, and the 8th process is delayed 8 ms so that process collisions can be avoided.


In overview, delays of predetermined time are used in the present invention to separate the rutine programs so that when the processor has to process at least two processes periodically, collision or interruption will not occur, and further, system panic can be prevented.


It will be apparent to those skilled in the art that various modifications and variations can be made to the structure of the present invention without departing from the scope or spirit of the invention. In view of the foregoing, it is intended that the present invention cover modifications and variations of this invention provided they fall within the scope of the following claims and their equivalents.

Claims
  • 1. A method for preventing process collision of a micro controller, comprising: providing at least a first process and a second process, wherein the first process is executed by the micro controller in every first period, the second process is executed by the micro controller in every second period, and the first period is shorter than the second period; andwhen collision of the first process and the second process could happen in the second period, the executing time of the second process is shifted a predetermined time.
  • 2. The process collision preventing method as claimed in claim 1, wherein the micro controller is used for processing N processes respectively corresponding to N execution periods, the N execution periods have a greatest common divisor, and the Kth execution period is shorter than the (K+1)th execution period, N and K are natural numbers, 0<K<=N.
  • 3. The process collision preventing method as claimed in claim 2, wherein when process collision may happen at the least common multiple time of the N execution periods, the execution of the Ith process is delayed I times of the predetermined time, I is a natural number and 0<I<=N.
  • 4. The process collision preventing method as claimed in claim 3, wherein when the J times of the predetermined time delayed to the Jth execution period is equal to the greatest common divisor, the processes after the Jth process are further delayed a predetermined time, J is a natural number and 0<J<=N.
  • 5. The process collision preventing method as claimed in claim 4, wherein the predetermined time is a unit time.
  • 6. The process collision preventing method as claimed in claim 5, wherein the unit time is 1 ms.
Priority Claims (1)
Number Date Country Kind
95120333 Jun 2006 TW national