lkml.org 
[lkml]   [2001]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectQuestion about spinlock and timer
Hello, linux guru.

After reading spinlock documentation at the kernelnewbie.org, i've got a
question:
If i clearly understand, each kernel timer is connected with some memory
region, and this region should be freed when timer becomes clear.
And this can occur before spi_lock_bh(). Therefore this memory regin will
be freed second time in the loop.

spin_lock_bh(&list_lock);

while (list) {
struct foo *next = list->next;
del_timer(&list->timer);
kfree(list);
list = next;
}
spin_unlock_bh(&list_lock);


This is correct example:

retry:
spin_lock_bh(&list_lock);

while (list) {
struct foo *next = list->next;
if (!del_timer(&list->timer)) {
/* Give timer a chance to delete this */
spin_unlock_bh(&list_lock);
goto retry;
}
kfree(list);
list = next;
}

spin_unlock_bh(&list_lock);

If i was right in previous assumption, than this code may be owervritten
in such manner:
.....
if (!del_timer(&list->timer)) {
if (!next)
break;
list = next;
continue;
}
.....

Or am I wrong again?
If it is so, please tell me the write answer and explanation.

Thanks in advance for you answers and appologies.

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

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