Renamed heap_init_postsem() to _post_sem(), added new heap_init_post_thread().
We now have a working periodic wall checker, enabled by USE_CHECKING_WALL. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9459 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+24
-15
@@ -171,11 +171,10 @@ check_wall_daemon(void *arg, int iteration)
|
|||||||
struct list_link *link = NULL;
|
struct list_link *link = NULL;
|
||||||
uint32 *wall;
|
uint32 *wall;
|
||||||
|
|
||||||
dprintf("checking walls...\n");
|
|
||||||
acquire_sem(sWallCheckLock);
|
acquire_sem(sWallCheckLock);
|
||||||
|
|
||||||
while ((link = list_get_next_item(&sWalls, link)) != NULL) {
|
while ((link = list_get_next_item(&sWalls, link)) != NULL) {
|
||||||
wall = (uint32 *)((addr_t)link + WALL_SIZE + 8);
|
wall = (uint32 *)((addr_t)link + sizeof(struct list_link) + WALL_SIZE + 8);
|
||||||
check_wall(wall);
|
check_wall(wall);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,6 +235,10 @@ heap_init(addr_t heapBase)
|
|||||||
heap_lock.sem = -1;
|
heap_lock.sem = -1;
|
||||||
heap_lock.holder = -1;
|
heap_lock.holder = -1;
|
||||||
|
|
||||||
|
#if USE_CHECKING_WALL
|
||||||
|
list_init(&sWalls);
|
||||||
|
#endif
|
||||||
|
|
||||||
// set up some debug commands
|
// set up some debug commands
|
||||||
add_debugger_command("heap_bindump", &dump_bin_list, "dump stats about bin usage");
|
add_debugger_command("heap_bindump", &dump_bin_list, "dump stats about bin usage");
|
||||||
|
|
||||||
@@ -244,16 +247,22 @@ heap_init(addr_t heapBase)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
heap_init_postsem(kernel_args *ka)
|
heap_init_post_sem(kernel_args *ka)
|
||||||
{
|
{
|
||||||
if (mutex_init(&heap_lock, "heap_mutex") < 0)
|
if (mutex_init(&heap_lock, "heap_mutex") < 0)
|
||||||
panic("error creating heap mutex\n");
|
panic("error creating heap mutex\n");
|
||||||
|
|
||||||
#if USE_CHECKING_WALL
|
#if USE_CHECKING_WALL
|
||||||
sWallCheckLock = create_sem(1, "check wall");
|
sWallCheckLock = create_sem(1, "check wall");
|
||||||
if (sWallCheckLock == 0)
|
#endif
|
||||||
panic("AAAaaaaargl.\n");
|
return B_OK;
|
||||||
list_init(&sWalls);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
heap_init_post_thread(kernel_args *ka)
|
||||||
|
{
|
||||||
|
#if USE_CHECKING_WALL
|
||||||
register_kernel_daemon(check_wall_daemon, NULL, WALL_CHECK_FREQUENCY);
|
register_kernel_daemon(check_wall_daemon, NULL, WALL_CHECK_FREQUENCY);
|
||||||
#endif
|
#endif
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -393,13 +402,13 @@ out:
|
|||||||
#if USE_WALL
|
#if USE_WALL
|
||||||
{
|
{
|
||||||
uint32 *wall = (uint32 *)((addr_t)address + alignment - WALL_SIZE - 8);
|
uint32 *wall = (uint32 *)((addr_t)address + alignment - WALL_SIZE - 8);
|
||||||
#if USE_CECKING_WALL
|
#if USE_CHECKING_WALL
|
||||||
struct list_link *link = (struct list_link)wall - 1;
|
struct list_link *link = (struct list_link *)wall - 1;
|
||||||
|
|
||||||
acquire_sem(sCheckWallLock);
|
acquire_sem(sWallCheckLock);
|
||||||
list_add_link_to_tail(&sWalls, link);
|
list_add_link_to_tail(&sWalls, link);
|
||||||
list_remove_link(link);
|
release_sem(sWallCheckLock);
|
||||||
release_sem(sCheckWallLock);
|
|
||||||
size -= sizeof(struct list_link);
|
size -= sizeof(struct list_link);
|
||||||
#endif
|
#endif
|
||||||
size -= 8 + 2*WALL_SIZE + 2*alignment;
|
size -= 8 + 2*WALL_SIZE + 2*alignment;
|
||||||
@@ -449,12 +458,12 @@ free(void *address)
|
|||||||
uint32 *wall = (uint32 *)((uint8 *)address - WALL_SIZE - 8);
|
uint32 *wall = (uint32 *)((uint8 *)address - WALL_SIZE - 8);
|
||||||
uint32 alignOffset = wall[0];
|
uint32 alignOffset = wall[0];
|
||||||
|
|
||||||
#if USE_CECKING_WALL
|
#if USE_CHECKING_WALL
|
||||||
struct list_link *link = (struct list_link)wall - 1;
|
struct list_link *link = (struct list_link *)wall - 1;
|
||||||
|
|
||||||
acquire_sem(sCheckWallLock);
|
acquire_sem(sWallCheckLock);
|
||||||
list_remove_link(link);
|
list_remove_link(link);
|
||||||
release_sem(sCheckWallLock);
|
release_sem(sWallCheckLock);
|
||||||
#endif
|
#endif
|
||||||
check_wall(address);
|
check_wall(address);
|
||||||
address = (uint8 *)address - alignOffset;
|
address = (uint8 *)address - alignOffset;
|
||||||
|
|||||||
Reference in New Issue
Block a user