How do I determine if a task is i real-time task in schedule()?

This is a discussion on How do I determine if a task is i real-time task in schedule()? within the Linux Programming forums, part of the Platform Specific Boards category; Hi, I'm currently working with a custom scheduler in linux kernel 2.6.23.9. Or actually I'm porting a scheduler I all ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    47

    How do I determine if a task is i real-time task in schedule()?

    Hi, I'm currently working with a custom scheduler in linux kernel 2.6.23.9. Or actually I'm porting a scheduler I all ready made in Solaris, anyway in sched.c in the schedule() function, I need to determine if a task is a real-time task or not, what is the best way to do this? Do real-time tasks got any flag set that I can check?

    Also a question about jiffies, how many ns is a jiffy?

    This macro, in sched.c says:
    Code:
    #define NS_TO_JIFFIES(TIME) ((TIME) / (1000000000 / HZ))
    But where is HZ set? What is the default value?

    Thanks.

  2. #2
    Registered User
    Join Date
    Oct 2007
    Posts
    47
    d'oh!

    Found it: task_has_rt_policy(); ....

    Still question about jiffies remains.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,691
    HZ - This is the number of hardware clock interrupts per second. This is a "ticks per second" value (T/s).

    jiffies / jiffies_64 - These are basically counters that get incremented ever clock interrupt. So this is a "ticks" value (T).

    There are 1000 milliseconds (ms) in a second - and 1,000,000 nanoseconds (ns) in a millisecond.

    So 1000000000 is the number of nanoseconds in a second - divide by HZ and you now have a value that represents the "nanoseconds per tick" (ns/T). "TIME" in the macro represents a "ns" value, so when you divide "ns (ns/T)" you end up with just a "T" value - which is ticks or jiffies.

    So now that that's out of the way, to your question
    >> But where is HZ set? What is the default value?

    Linux Device Drivers, Third Edition: http://lwn.net/Kernel/LDD3/
    You can jump straight to chapter 7 where those questions are answered.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scheduling Algo
    By BigDaddyDrew in forum C++ Programming
    Replies: 41
    Last Post: 03-08-2003, 11:00 AM
  2. Is this really true or it's just science fiction?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 145
    Last Post: 04-09-2002, 07:17 PM
  3. Programming Puns
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 44
    Last Post: 03-23-2002, 04:38 PM
  4. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 10:12 PM
  5. Real Time?
    By Sebastiani in forum C Programming
    Replies: 1
    Last Post: 09-23-2001, 04:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21