Re: "Aiee: scheduling in interrupt 00111dd2" problem

Riley Williams (rhw@bigfoot.com)
Fri, 18 Dec 1998 22:45:47 +0000 (GMT)


Hi Richard.

>> Am I right to say that the locking structures are mainly used to
>> prevent race conditions. Why does the kernel hang when some of
>> these are broken?

> Observe a typical linked-list operation when the list in increasing
> in size (length) ....

> link = memory_from_somewhere();
> link->next = NULL;

> Now, look while it is decreasing in size...

> while(link != NULL) {
> save_next = link->next;
> memory_from_somewhere_free(link); /* (A) */
> link = save_next; /* (B) */
> }

> If another "thread" were to access ``link'' between A and B, it
> would be accessing invalid memory. If the first procedure was
> executing and didn't finish, before the next procedure was
> executed, all bets are off. This is a typical problem with
> multitasking, not just SMP. Some operations must complete before
> others are allowed.

How about a less dangerous variant thereof...

Q> while (link != NULL) {
Q> save := link;
Q> link := link->next;
Q> memory_from_somewhere_free(save);
Q> }

That should be thread-safe since link never points anywhere invalid...

> This if often called a "race" condition when, in fact it's no race
> at all, it's a "crash" condition, pure and simple.

To be accurate, it's a bug, pure and simple...

Best wishes from Riley.

-
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/