+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Full Member level 5
    Points: 2,501, Level: 11

    Join Date
    Nov 2011
    Location
    india
    Posts
    285
    Helped
    2 / 2
    Points
    2,501
    Level
    11

    basic scheduler program

    Hello everyone

    There are two type of interrupt, hardware ans software interrupt. When we have to do any task at any specific time, we use timer interrupts like if we have to do task after 1 second then we will set timer interrupt. interrupt will occur at every 1 second. Hardware interrupt like if any event happen interrupt will generate such as if any switch press turn on the motor. interrupt will happen at every switch press.

    Scheduling decide which task should execute at this time. My understanding say that we set the timer interrupt for every tasks.

    set interrupt for 10 ms (task 1)
    set interrupt for 12 ms (task 2)
    set interrupt for 15 ms (task 1)

    We set priority for every task's

    first priority (task 3)
    second priority (Task 2)
    third priority (Task 1)

    I have the knowledge of timer interrupt and priority. if I want to make basic scheduler program then what's the programming knowledge required to implement simple scheduler

    •   Alt25th February 2018, 19:04

      advertising

        
       

  2. #2
    Super Moderator
    Points: 71,480, Level: 65
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    11,697
    Helped
    3869 / 3869
    Points
    71,480
    Level
    65

    Re: basic scheduler program

    Software interrupts are only available on a limited number of processors. I think what you probably need to do is use a hardware timer interrupt to keep a software clock running so you can hook your tasks to it and start them as needed. Find the longest period common to all your timing requirements then count the periods in an ISR.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   Alt25th February 2018, 21:31

      advertising

        
       

  3. #3
    Full Member level 5
    Points: 2,501, Level: 11

    Join Date
    Nov 2011
    Location
    india
    Posts
    285
    Helped
    2 / 2
    Points
    2,501
    Level
    11

    Re: basic scheduler program

    Quote Originally Posted by betwixt View Post
    Software interrupts are only available on a limited number of processors. I think what you probably need to do is use a hardware timer interrupt to keep a software clock running so you can hook your tasks to it and start them as needed. Find the longest period common to all your timing requirements then count the periods in an ISR.

    Brian.
    Okay but my Question was what what's the programming skill required to implement simple scheduler. I know the interrupt and structure. Is it sufficient to make simple scheduler. What's the skill need to make simple scheduler



    •   Alt26th February 2018, 02:36

      advertising

        
       

  4. #4
    Advanced Member level 3
    Points: 6,381, Level: 19

    Join Date
    Jan 2015
    Posts
    927
    Helped
    294 / 294
    Points
    6,381
    Level
    19

    Re: basic scheduler program

    Depending on the processor you are using, you may well have to set aside enough storage for each task to save the complete register set - at least of the CPU. Some devices I know of allow registers to be set but not read (e.g. some of the PIC registers associated with repeated instructions for the DSP operations). Therefore it can be quite hard to save the state of the device completely for a general case - if you know that you will never write code or use a library that uses the 'special' registers then you can leave them out of the context switch.
    As for the scheduling, so you want this purely based of the timer (preemptive) or can the tasks relinquish the processor when it knows it has nothing to do (cooperative)?
    Either way, you need to maintain the state of each task and then regularly check to see if it is the highest priority task at that time that can run. A common way of doing this is to have a list of tasks in the order they can be run - be that timer base, priority based or both.
    Each 'heartbeat' you need to scan the list and see if the top-most task that can run is the current task or not - if not then a context switch is required and the task list re-ordered.
    In the example you provided, your heartbeat would need to be every 1msec if that is the time slice resolution you want to achieve.
    Personally I would investigate an existing piece of software such as RTOS (there are a number of alternatives) which are free and have the development (and general support) available without having to reinvent the wheel.
    Susan



--[[ ]]--