static int dump_handlers(int argc, char** argv) { kprintf("current state: %c%c%c%c\n", (sLowResources & B_KERNEL_RESOURCE_PAGES) != 0 ? 'p' : '-', (sLowResources & B_KERNEL_RESOURCE_MEMORY) != 0 ? 'm' : '-', (sLowResources & B_KERNEL_RESOURCE_SEMAPHORES) != 0 ? 's' : '-', (sLowResources & B_KERNEL_RESOURCE_ADDRESS_SPACE) != 0 ? 'a' : '-'); kprintf(" pages: %s\n", state_to_string(sLowPagesState)); kprintf(" memory: %s\n", state_to_string(sLowMemoryState)); kprintf(" sems: %s\n", state_to_string(sLowSemaphoresState)); kprintf(" aspace: %s\n\n", state_to_string(sLowSpaceState)); HandlerList::Iterator iterator = sLowResourceHandlers.GetIterator(); kprintf("function data resources prio function-name\n"); while (iterator.HasNext()) { low_resource_handler *handler = iterator.Next(); const char* symbol = NULL; elf_debug_lookup_symbol_address((addr_t)handler->function, NULL, &symbol, NULL, NULL); char resources[16]; snprintf(resources, sizeof(resources), "%c %c %c", handler->resources & B_KERNEL_RESOURCE_PAGES ? 'p' : ' ', handler->resources & B_KERNEL_RESOURCE_MEMORY ? 'm' : ' ', handler->resources & B_KERNEL_RESOURCE_SEMAPHORES ? 's' : ' '); kprintf("%p %p %s %4ld %s\n", handler->function, handler->data, resources, handler->priority, symbol); } return 0; }
status_t unregister_low_resource_handler(low_resource_func function, void* data) { TRACE(("unregister_low_resource_handler(function = %p, data = %p)\n", function, data)); RecursiveLocker locker(&sLowResourceLock); HandlerList::Iterator iterator = sLowResourceHandlers.GetIterator(); while (iterator.HasNext()) { low_resource_handler* handler = iterator.Next(); if (handler->function == function && handler->data == data) { sLowResourceHandlers.Remove(handler); free(handler); return B_OK; } } return B_ENTRY_NOT_FOUND; }