RE: Atomic operations

Gregory Giguashvili (Gregoryg@ParadigmGeo.com)
Mon, 3 Jun 2002 21:09:22 +0200


Peter,

Thanks a lot for your help.

> atomic_t test_then_add (int i, atomic_t* v)
> {
> atomic_t old = *v;
> v->counter += i;
> return old;
> }
> There is no way to do this (without waiting and trying again type
> code) that I know of on i386. However, you can test for zeroness of
> the result, or for <= 0, or a few other options.

Could you, please, clarify what you meant saying that there was no way of
doing so. I admit, I'm no expert in i386 assembly, but this operation seems
so simple to me...

Could you, please, suggest some other implementation (with waiting and
trying again - whatever this means)?

test_and_set and test_then_add functions are coming from code written for
IRIX. Solaris has similar functionality. Windows NT also provides these
primitives in Win32 API (possibly implemented not in the most effective way,
according to what you say). The only OS where they are missing is Linux.

Unfortunately, these primitives became an integral part of our code, which
makes it very painful to change their behavior.

Thanks in advance.
Giga
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/