Movatterモバイル変換
[0]ホーム
A couple garbage collector questions
Douglas Alannessus at mit.edu
Wed Apr 4 16:18:25 EDT 2001
Andrew Kuchling <akuchlin at mems-exchange.org> writes:> Douglas Alan <nessus at mit.edu> writes:> > Why do you need to lock on increment/decrement? Isn't incrementing or> > decrementing an integer an atomic operation on most CPU's?> Yes, but you don't know if your C compiler is smart enough to> generate such code for obj->refcnt++, so usually bits of assembler> are used. For example, on Linux there are atomic_inc() and> atomic_dec() macros in asm/atomic.h. I doubt there's a way of doing> this portably.Does the C compiler have to be smart for this to happen atomically?Generally wouldn't the normal stupid way be atomic? (I'm assumingthat "obj" is on the thread's private stack, and that no thread isgoing to move the object to a different memory location after you'vedereferenced the pointer.) Or are there CPU's that will accept aninterrupt half-way through writing an integer to a memory location?|>oug
More information about the Python-listmailing list
[8]ページ先頭