zdravim, moc toho v assembleru neumim a pokousim se napsat atomicke test&set a compare&swap pro mips procesor (pokud byste to nekdo meli hotove, dejte vedet :)
Momentalne mam ten compare&swap podle ruznych naovdu, ale nevim, zda je dobre
static inline native_t compare_and_swap(atomic_t *var, const native_t old_value, const native_t new_value)
{
native_t temp, result;
asm volatile (
".set push\n"
".set noreorder\n"
" ll %[temp], %[value]\n"
" bne %[temp], %[old_value], 1f\n"
" move %[result], %[new_value]\n"
" sc %[result], %[value]\n"
" b 2f\n"
"1: move %[result], $0\n"
"2: sync\n"
".set pop\n"
: [temp] "=&r" (temp), [result] "=&r" (result), [value] "+m" ((var)->value)
: [old_value] "r" ((old_value)->value), [new_value] "r" ((new_value)->value)
: "memory"
);
return result;
}
predevsim jsem neprisel na to, co znamenaji ty pismenka u vstupnich/vystupnich promennych, takove to =&r, +m, r, Ir a pod. any idea?
Dale jak je to s temi labely, viel jsem vyskyt cisel+f nebo b
znamena to jdi na cislo a to f/b je forward/backward?
Diky za rady :)