2008-06-26 13:27:29

by xialiang

[permalink] [raw]
Subject: Can I use yield in this way

Hello,

I'd like to ask a question about the use of a kernel function,
yield(); I am working on Intel Core Duo, running Linux 2.6.21 I want
to let current process be off the cpu when the temperature of cpu is
too high. I add a function called thermal_balance in the timer
interrupt. My program is as following,

scheduler_tick()
{
static int count = 0;
count++;
if(count % 100 == 0)
thermal_balance();
}

static int thermal_balance(void)
{
int cpu = smp_processor_id();
struct task_struct* task;
Get CPU temperature.

if (temperature is too high){
task = cpu_rq(cpu)->curr;
yield();
Move task to other cpu.
}
}

Can yield() be used as above. After I compile the kernel and
run again. Kernel is not working just as it meets deadlock. And if I
comment yield(), it runs ok. Could anyone help me?Thanks!


2008-06-26 13:42:50

by Alan

[permalink] [raw]
Subject: Re: Can I use yield in this way

> Can yield() be used as above. After I compile the kernel and
> run again. Kernel is not working just as it meets deadlock. And if I
> comment yield(), it runs ok. Could anyone help me?Thanks!

You cannot schedule within an interrupt (the interrupt handler cannot
yield) - you can force a reschedule however, and in theory you could
change the processor masks and trigger a reschedule to do what you want

Alan