0

I want to update the kernel to do some more stuff when switching between tasks and for that i need to find the reason for each switch.

First, i can't find the function where schedule() is called when there is a higher priority task than the current one and they need to be switched, where does it happen?

Second, is there any reason for a task to yield the CPU rather than exiting or going to wait for something? is there a yield function or something?

Thanks!

juliarak
  • 1
  • 1

1 Answers1

0
  1. Check this prio_changed_fair (similar you can refer other scheduling class)
  2. Task will not yield if it is in infinite loop but kernel can schedule another task based on time-slice. Yes linux has yield function.
Sasi V
  • 1,074
  • 9
  • 15
  • Thanks! I found the yield function, i couldn't find the prio_changed_fair function, do you know in wich file it appears? thankss – juliarak Apr 15 '14 at 12:44
  • Which kernel version are you using?. In latest kernel it is in kernel/sched/fair.c – Sasi V Apr 15 '14 at 16:26
  • I'm using a super old one, 2.4.18-14 – juliarak Apr 15 '14 at 18:04
  • That one too old. Check kernel/sched.c (schedule + line number 608) http://lxr.linux.no/#linux-old+v2.4.18/kernel/sched.c#L608 And " goodness" function the same file http://lxr.linux.no/#linux-old+v2.4.18/kernel/sched.c#L144 – Sasi V Apr 15 '14 at 18:50