Strange behavior of for loop in scheduler_tick
Posted
by EpsilonVector
on Stack Overflow
See other posts from Stack Overflow
or by EpsilonVector
Published on 2010-04-28T18:25:21Z
Indexed on
2010/04/28
18:37 UTC
Read the original article
Hit count: 258
I'm working on Linux kernel 2.4 (homework) and I inserted the following code into the scheduler_tick function:
if (unlikely(rt_task(p)) || (p->policy==SCHED_PROD &&
p->time_ran>=p->process_expected_time)) {
/*
* RR tasks need a special form of timeslice management.
* FIFO tasks have no timeslices.
*/
if ((p->policy == SCHED_RR || /*change*/p->policy==SCHED_PROD) && !--p->time_slice) {
/*changes*/
if (p->policy == SCHED_PROD){
for (i=0; i<5000; i++){
printk("I'm leeching off SCHED_RR code! %d\n", i);
}
}
/*end changes*/
The addition was added for debugging purposes. For some reason this causes very weird behavior: when a SCHED_PROD process triggers this code (and consequently the loop that follows) the loop counts to about 4600 normally, but then goes back to 4600 each time it counts to 4800, and gets stuck in an infinite loop.
What's going on??
EDIT: The i variable is my own.
© Stack Overflow or respective owner