Thread: How to write code for round robin scheduling

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

    How to write code for round robin scheduling

    How to write code for round robin scheduling

    I want to write code for round robin scheduling

    How to write code for round robin scheduling-scheduling-jpg

    Code:
    #include<stdio.h>
    
    int main(void)
    {
       
       while (1)
           {
        
          
           }
           
           return 0;
    }
    Any help will appreciate
    Last edited by Player777; 09-07-2021 at 02:21 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,796
    Why are you trying to write your own, when there are many open source ones -> OSRTOS
    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.

  3. #3
    Registered User
    Join Date
    Nov 2019
    Posts
    80
    Quote Originally Posted by Salem View Post
    Why are you trying to write your own, when there are many open source ones -> OSRTOS
    I am not thinking of making real time operating system. I just want to understand the process of how multiple files work together to decide which task should be run on schedule time. Like if you have to set the schedule time then which function will you call? What function do you call if you want to make a priority ? there is a source file for list and queue why is it used and when should it be called from main.

    I know all related documentation is available on internet but I am having trouble to figure out it. you gave me the paper and pencil idea i like it but i don't know how to start.

    I'm trying understand how can I figure out all these problems on paper firstly

  4. #4
    Registered User
    Join Date
    Feb 2019
    Posts
    888
    Google (or Duckduck Go) is your friend: Completly fair scheduler

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,796
    > I am not thinking of making real time operating system.
    Oh yes you are.

    > I want to write code for round robin scheduling

    Without a scheduler, your code runs like this.
    Code:
    P1();
    P2();
    P3();
    You need a scheduler to be able to slice and dice into T1,T2,T3,T1,T2,T3,T1,T2,T3,T2

    > I just want to understand the process of how multiple files work together to decide which task should be run on schedule time
    These are completely independent.
    You can have a single threaded program spread across many files.
    You can have a multi-threaded program in a single file.
    Code organisation into files is something you do to be organised.
    But if your idea is wrong, then no matter how you arrange the code, it will still be wrong.

    > Like if you have to set the schedule time then which function will you call?
    You can fake it somewhat using pthreads.
    But don't expect super-fine time-based switching between the different processes.

    > What function do you call if you want to make a priority ?
    You're probably out of luck, unless you're root on your Linux box or using an RTOS.
    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.

  6. #6
    Registered User
    Join Date
    Nov 2019
    Posts
    80
    Quote Originally Posted by Salem View Post
    > I am not thinking of making real time operating system.
    Oh yes you are..
    I have started reading user manual of FreeRTOS. You said start with paper and pencil. Can you explain little bit how to start?

    Do you mean to draw flowchart, block diagram, state diagram etc.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,076
    The first task is to describe the problem you are trying to solve.
    Then, describe each part/step/sub-task of the problem.

    Of the three you listed (flowchart, block diagram, state diagram); block diagram would be the first of the three I would try.

    Tim S.
    "...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

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    4,076
    What is Context Switching in Operating System?

    Context switch - Wikipedia

    How you are going to do context switching is likely a very important thing to decide.

    Tim S.
    "...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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Community Game) Round Robin for C++ [Round 01]
    By phantomotap in forum General Discussions
    Replies: 5
    Last Post: 04-18-2011, 01:07 PM
  2. (Community Game) Planning for Round Robin for C++ [Round 02]
    By phantomotap in forum General Discussions
    Replies: 2
    Last Post: 04-17-2011, 02:39 PM
  3. Round Robin Scheduling Question?
    By jeffc1 in forum Tech Board
    Replies: 10
    Last Post: 10-08-2010, 05:46 PM
  4. round-robin
    By 3pid in forum C++ Programming
    Replies: 1
    Last Post: 01-29-2009, 11:13 AM
  5. Round Robin Scheduling using c.
    By eclipt in forum C Programming
    Replies: 8
    Last Post: 12-28-2005, 04:58 PM

Tags for this Thread