From 11add5a5d71c75a8174db668862656f0ef501f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 27 Apr 2006 17:46:19 +0000 Subject: [PATCH] First baby step towards a lockless get_memory_map(): vm_get_current_user_address_space() no longer needs to lock address space hash table - that also makes the lookup much faster, too (and a direct pointer is used instead of a hash lookup). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17246 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/vm/vm_address_space.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/vm/vm_address_space.c b/src/system/kernel/vm/vm_address_space.c index cd37a65e5e..66c5144dd2 100644 --- a/src/system/kernel/vm/vm_address_space.c +++ b/src/system/kernel/vm/vm_address_space.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -200,7 +200,17 @@ vm_kernel_address_space_id(void) vm_address_space * vm_get_current_user_address_space(void) { - return vm_get_address_space_by_id(vm_current_user_address_space_id()); + struct thread *thread = thread_get_current_thread(); + + if (thread != NULL) { + vm_address_space *addressSpace = thread->team->address_space; + if (addressSpace != NULL) { + atomic_add(&addressSpace->ref_count, 1); + return addressSpace; + } + } + + return NULL; }