Git Product home page Git Product logo

swisswatch's Introduction

Swiss Watch:

  • A priority based task scheduler for C.

Setting Up Tasks

At the start of the program each task must be initialized with a period, a priority and a callback function pointer.

- Task Periods
    - The period of a task is the ideal number of milliseconds between calls to the tasks callback function

- Task Priorities
    - Each task must be assigned a priority when it is initialized
    - The tasks priority is only taken into consideration in the case where multiple tasks are due at the same time
    - Tasks with higher priority (lower numeric value) will be executed first
    - Priority values can range from 0 (highest priority) to 255 (lowest priority)

- Task Callback Functions
    - When a task is due the callback function is called.
    - The callback function must return the results of the task

- Task Results
    - When a task is called it should not block execution any longer than necessary
    - Tasks should return FINISHED if they do not require further work until their next normal call
    - If a task occasionally needs more time to finish it's work it can return a result of INCOMPLETE
    - If a task returns INCOMPLETE it will be marked as "needs more time"
    - If the task scheduler determines that no tasks are due at a given time, it will call the highest priority task that "needs more time"
    - If a task determines that it needs to be disabled it can do so by returning KILL_TASK. This task will not be called again unless it is re-enabled.

Monitoring Idle Time

By default, nothing happens when all tasks are idle. The task scheduler supports an Idle Callback which will be called during this time. This can be used to monitor the amount of time that the processor is idle. To do so use the TS_SetIdleFunc method. This function takes a function pointer to the function that you want to be called during idle time. The idle function cannot take any arguments.

IMPORTANT: If this is running on a system with an OS where there are other processes running you need to implement a sleep function in idle function. Otherwise you will peg the processor at 100% for your process.  <-- Baaaaad

swisswatch's People

Contributors

jschaenzle avatar

Stargazers

 avatar Anand Singh avatar Sam Seltzer-Johnston avatar  avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.