Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 See also  





2 References  














Cyclic executive






Deutsch
 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


Acyclic executive[1][2] is an alternative to a real-time operating system. It is a form of cooperative multitasking, in which there is only one task. The sole task is typically realized as an infinite loop in main(), e.g. in C.

The basic scheme is to cycle through a repeating sequence of activities, at a set frequency (AKA time-triggered cyclic executive). For example, consider the example of an embedded system designed to monitor a temperature sensor and update an LCD display. The LCD may need to be written twenty times a second (i.e., every 50 ms). If the temperature sensor must be read every 100 ms for other reasons, we might construct a loop of the following appearance:

int main(void)
{
   while (1)
   {
      // This loop is designed to take 100 ms, meaning
      // all steps add up to 100 ms.
      // Since this is demo code and we don't know how long
      // tempRead or lcdWrite take to execute, we assume
      // they take zero time.
      // As a result, the delays are responsible for the task scheduling / timing.

      // Read temp once per cycle (every 100 ms)
      currTemp = tempRead();

      // Write to LCD twice per cycle (every 50 ms)
      lcdWrite(currTemp);
      delay(50);
      lcdWrite(currTemp);
      delay(50);

      // Now 100 ms (delay(50) + delay(50) + tempRead + lcdWrite + lcdWrite)
      // has passed so we repeat the cycle.
   }
}

The outer 100 ms cycle is called the major cycle. In this case, there is also an inner minor cycle of 50 ms. In this first example the outer versus inner cycles aren't obvious. We can use a counting mechanism to clarify the major and minor cycles.

int main(void)
{
   unsigned int i = 0;
   while (1)
   {
      // This loop is designed to take 50 ms.
      // Since this is demo code and we don't know how long
      // tempRead or lcdWrite take to execute, we assume
      // they take zero time.
      // Since we only want tempRead to execute every 100ms, we use
      // an if statement to check whether a counter is odd or even, 
      // and decide whether to execute tempRead.

      // Read temp every other cycle (every 100 ms)
      if ( (i%2) == 0)
      {
         currTemp = tempRead();
      }

      // Write to LCD once per cycle (every 50 ms)
      lcdWrite(currTemp);
      delay(50);

      i++;
      // Now 50 ms has passed so we repeat the cycle.
   }
}

See also[edit]

References[edit]

  1. ^ Bruce Powell Douglass (2003). Real-Time Design Patterns: Robust Scalable Architecture for Real-Time Systems. Addison-Wesley Longman Publishing Co., Inc. pp. 232–237. ISBN 0201699567.
  • ^ Laplante, Phillip A.; Ovaska, Seppo J. (2012). Real-Time System Design and Analysis (4th ed.). Hoboken, NJ: John Wiley & Sons, Inc. pp. 84–85, 100–102. ISBN 978-0-470-76864-8.

  • Retrieved from "https://en.wikipedia.org/w/index.php?title=Cyclic_executive&oldid=1216101298"

    Categories: 
    Operating system technology
    Concurrent computing
    Hidden categories: 
    Articles with short description
    Short description is different from Wikidata
     



    This page was last edited on 29 March 2024, at 01:40 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki