Thread: Portable cooperative scheduling

  1. #1
    Registered User
    Join Date
    Nov 2019
    Posts
    90

    Portable cooperative scheduling

    I want to design a cooperative scheduling for 32 -bit microcontroller. I have read many links and watched many youtube videos but have no idea how to start design

    This is a specification I have create for learning

    task 1 takes 2ms to execute
    task 2 takes 3ms to execute
    task 3 takes 2ms to execute

    task 1 should be run within 5ms deadline
    task 2 should be run within 10ms deadline
    task 3 should be run within 15ms deadline

    Code:
    int main ()
    {
      
       while (1)  
       {
       
      }
    return 0;
    }
    
    void ISR ( ) // timer interrupt set every 1ms 
    {
    
    }
    any thoughts idea

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    How long does it take to switch between tasks?
    Are you going to use/support a yield() command?
    That is the normal commanded by several multitask API when a process is done using current time slice.
    Are you going to use interrupts to trigger task switching?

    Edit: Add more info below
    Note: I have never designed this type of system in C; I think I may have did in Ada once.
    But, if it takes a long time to switch tasks I would likely use a larger default time slice/interval.
    I am guessing from what you posted that the choices are 1ms, 2ms, and 3ms.
    If the requirement is to use 1ms; then the answer to how long to switch really does not matter except if it is too large there will be no possible working solution. In other words, if the time to switch tasks is 1.1 ms; then, there is likely no possible solution using task switch using an 1ms time task interval.

    Tim S.
    Last edited by stahta01; 12-26-2021 at 02:47 AM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Did you learn anything from your previous round of threads?
    How do you design scheduler ?
    Top design- real time operating system
    How to write code for round robin scheduling
    Free rtos code example 1

    > I have read many links and watched many youtube videos but have no idea how to start design
    So what is your current design and programming experience?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Nov 2019
    Posts
    90
    Quote Originally Posted by Salem View Post
    Did you learn anything from your previous round of threads?
    How do you design scheduler ?
    Top design- real time operating system
    How to write code for round robin scheduling
    Free rtos code example 1

    > I have read many links and watched many youtube videos but have no idea how to start design
    So what is your current design and programming experience?
    I have successfully ported freertos on 32 bit micro. I done few experiments for learning.

  5. #5
    Registered User
    Join Date
    Nov 2019
    Posts
    90
    Quote Originally Posted by stahta01 View Post
    How long does it take to switch between tasks?
    Are you going to use/support a yield() command?
    That is the normal commanded by several multitask API when a process is done using current time slice.
    Are you going to use interrupts to trigger task switching?

    Edit: Add more info below
    Note: I have never designed this type of system in C; I think I may have did in Ada once.
    But, if it takes a long time to switch tasks I would likely use a larger default time slice/interval.
    I am guessing from what you posted that the choices are 1ms, 2ms, and 3ms.
    If the requirement is to use 1ms; then the answer to how long to switch really does not matter except if it is too large there will be no possible working solution. In other words, if the time to switch tasks is 1.1 ms; then, there is likely no possible solution using task switch using an 1ms time task interval.

    Tim S.
    When there are multiple task's, scheduler need to decide when and which one task should be run on machine

    Task should be switched at 1ms time interval

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    >I have successfully ported freertos on 32 bit micro.
    I'm confused as to what it is you actually want, if you already have an RTOS running on your platform.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Nov 2019
    Posts
    90
    Quote Originally Posted by Salem View Post
    >I have successfully ported freertos on 32 bit micro.
    I'm confused as to what it is you actually want, if you already have an RTOS running on your platform.

    I want to write my own code for scheduling without freeRTOS just for learning. I am having trouble to making it.

    This is what I want to implement with 1ms system tick
    Attached Images Attached Images Portable cooperative scheduling-timing-resources-jpg 

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Your picture is pre-emptive, not co-operative.

    Which micro-controller are you trying to use?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User
    Join Date
    Nov 2019
    Posts
    90
    Quote Originally Posted by Salem View Post
    Your picture is pre-emptive, not co-operative.
    yes, It's pre-emptive design

    Quote Originally Posted by Salem View Post
    Which micro-controller are you trying to use?
    currently working with PIC18F45K80, MPLAB Xc8, C language, Planning to move on 32 PIC very soon

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scheduling Algorithms
    By jelibon in forum C Programming
    Replies: 3
    Last Post: 02-22-2012, 04:47 PM
  2. process scheduling
    By lordofdarkness in forum C Programming
    Replies: 0
    Last Post: 03-29-2010, 04:53 PM
  3. Scheduling Policy
    By edesign in forum Linux Programming
    Replies: 9
    Last Post: 05-12-2009, 08:47 PM
  4. scheduling in linux
    By anjana in forum Linux Programming
    Replies: 2
    Last Post: 05-24-2007, 03:48 PM
  5. Scheduling
    By Jules in forum Tech Board
    Replies: 4
    Last Post: 01-18-2004, 01:47 PM

Tags for this Thread