/* * Copyright (c) 1994 by Xerox Corporation. All rights reserved. * Copyright (c) 1996 by Silicon Graphics. All rights reserved. * Copyright (c) 1998 by Fergus Henderson. All rights reserved. * Copyright (c) 2000-2009 by Hewlett-Packard Development Company. * All rights reserved. * * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. * * Permission is hereby granted to use or copy this program * for any purpose, provided the above notices are retained on all copies. * Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice.
*/
#ifdefined(GC_DARWIN_THREADS) # include "private/darwin_stop_world.h" #else # include "private/pthread_stop_world.h" #endif
#ifdef THREAD_LOCAL_ALLOC # include "thread_local_alloc.h" #endif
#ifdef THREAD_SANITIZER # include "dbg_mlc.h"/* for oh type */ #endif
EXTERN_C_BEGIN
/* We use the allocation lock to protect thread-related data structures. */
/* The set of all known threads. We intercept thread creation and */ /* joins. */ /* Protected by allocation/GC lock. */ /* Some of this should be declared volatile, but that's inconsistent */ /* with some library routine declarations. */ typedefstruct GC_Thread_Rep { # ifdef THREAD_SANITIZER char dummy[sizeof(oh)]; /* A dummy field to avoid TSan false */ /* positive about the race between */ /* GC_has_other_debug_info and */ /* GC_suspend_handler_inner (which */ /* sets store_stop.stack_ptr). */ # endif
struct GC_Thread_Rep * next; /* More recently allocated threads */ /* with a given pthread id come */ /* first. (All but the first are */ /* guaranteed to be dead, but we may */ /* not yet have registered the join.) */
pthread_t id; # ifdef USE_TKILL_ON_ANDROID
pid_t kernel_id; # endif /* Extra bookkeeping information the stopping code uses */ struct thread_stop_info stop_info;
unsignedchar flags; /* Protected by GC lock. */ # define FINISHED 1 /* Thread has exited. */ # define DETACHED 2 /* Thread is treated as detached. */ /* Thread may really be detached, or */ /* it may have been explicitly */ /* registered, in which case we can */ /* deallocate its GC_Thread_Rep once */ /* it unregisters itself, since it */ /* may not return a GC pointer. */ # define MAIN_THREAD 4 /* True for the original thread only. */ # define DISABLED_GC 0x10 /* Collections are disabled while the */ /* thread is exiting. */
unsignedchar thread_blocked; /* Protected by GC lock. */ /* Treated as a boolean value. If set, */ /* thread will acquire GC lock before */ /* doing any pointer manipulations, and */ /* has set its SP value. Thus it does */ /* not need to be sent a signal to stop */ /* it. */
# ifndef GC_NO_FINALIZATION unsignedshort finalizer_skipped; unsignedchar finalizer_nested; /* Used by GC_check_finalizer_nested() */ /* to minimize the level of recursion */ /* when a client finalizer allocates */ /* memory (initially both are 0). */ # endif
ptr_t stack_end; /* Cold end of the stack (except for */ /* main thread). */
ptr_t altstack; /* The start of the alt-stack if there */ /* is one, NULL otherwise. */
word altstack_size; /* The size of the alt-stack if exists. */
ptr_t stack; /* The start and size of the normal */ /* stack (set by GC_register_altstack). */
word stack_size; # ifdefined(GC_DARWIN_THREADS) && !defined(DARWIN_DONT_PARSE_STACK)
ptr_t topOfStack; /* Result of GC_FindTopOfStack(0); */ /* valid only if the thread is blocked; */ /* non-NULL value means already set. */ # endif # ifdefined(E2K) || defined(IA64)
ptr_t backing_store_end; /* Note: may reference data in GC heap */
ptr_t backing_store_ptr; # endif
struct GC_traced_stack_sect_s *traced_stack_sect; /* Points to the "frame" data held in stack by */ /* the innermost GC_call_with_gc_active() of */ /* this thread. May be NULL. */
void * status; /* The value returned from the thread. */ /* Used only to avoid premature */ /* reclamation of any data it might */ /* reference. */ /* This is unfortunately also the */ /* reason we need to intercept join */ /* and detach. */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.