Thread: more kernel hacking, the check_preempt_curr_rt() func

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

    more kernel hacking, the check_preempt_curr_rt() func

    The following function in the linux kernel is a little confusing for me:


    Code:
    /*
     * Preempt the current task with a newly woken task if needed:
     */
    static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p)
    {
    	if (p->prio < rq->curr->prio) {
                resched_task(rq->curr);
            }
    }

    So this means that the current thread, rq->curr will be preempted when resched_task(rq->curr) is called, but this happens when p have a LOWER prio then rq->curr? shouldn't it be the other way around? I mean 99 is highets prioirty and 0 is the lowest. Or have I missunderstood this?



    Also why is prio used and not rt_prioirty?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    If I understand it correct, p is the current task, so if p's priority is LOWER than the newly enabled-to-run priority, then reschedule.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    47
    Hmm, but confusing with the naming rq->curr, sounds like thats the current task?


    And why isn't rt_priority used instead of prio?


    So p is the current task that is being preempted? But isn't rq->curr the one being rescheduled??
    Last edited by micke_b; 02-18-2008 at 11:06 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Kernel Hacking Issue
    By NuNn in forum Linux Programming
    Replies: 1
    Last Post: 03-31-2009, 12:54 PM
  2. kernel hacking, plz help
    By micke_b in forum Linux Programming
    Replies: 8
    Last Post: 02-18-2008, 04:49 PM
  3. CreateThread ?!
    By Devil Panther in forum Windows Programming
    Replies: 13
    Last Post: 11-15-2005, 10:55 AM
  4. typedef a func
    By trekker in forum C Programming
    Replies: 4
    Last Post: 07-02-2002, 05:15 AM
  5. Kernel hacking
    By Spark in forum C Programming
    Replies: 7
    Last Post: 06-20-2002, 08:40 PM