lkml.org 
[lkml]   [1998]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: "Aiee: scheduling in interrupt 00111dd2" problem
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/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.068 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site