Re: Question about linux drivers

Paul Barton-Davis (pbd@Op.Net)
Tue, 17 Nov 1998 02:10:07 -0500


Alessandro Rubini <rubini@pop.systemy.it> writes:

>> [...] Is there any ways to automate this? I.e. I call a function
>> before I enter this loop that sais: "It's OK to switch
>> process/context when appropriate", so I don't have to worry about
>> locking the whole kernel.
>
>Yes. You can change current->state to TASK_INTERRUPTIBLE, and then
>call schedule(). If a process is wating for processor time, it will
>get it. Change back current->stat to TASK_RUNNING when you are done.
>
>The kernel is full of such examples.

I think that your example requires:

while (!done_computing) {
if (loops++ % some_constant == 0) {
current->state = TASK_INTERRUPTIBLE;
schedule();
current->state = TASK_RUNNING; /* redundant, i think */
} else {
compute ();
}

whereas I think the questioner wanted:

tell_scheduler_that_i_do_not_really_matter ();
while (!done_computing) {
compute();
}

I can't think of anyway of doing the second way. I don't know what the
semantics are of marking current->state as TASK_INTERRUPTIBLE but *NOT*
calling schedule().

Perhaps I misunderstood your suggestion Alessandro.

--p

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/