f9-kernel icon indicating copy to clipboard operation
f9-kernel copied to clipboard

Ensure that all explicit memory accesses that appear in program order

Open jserv opened this issue 12 years ago • 0 comments

Function test_and_set_word and test_and_set_bit in file platform/bitops.c implements the basic locking mechanism utilizing ldrex and strexeq instruction. However, other similar routines are not taken into consideration carefully, and we have to ensure that all explicit memory accesses that appear in program order before the DMB instruction are observed before any explicit memory accesses.

Here is the conceptual implementation:

int test_and_set(int *lock)
{
    int old_value;
    /* Ensure that all explicit memory accesses that appear in program order
     * before the DMB instruction are observed before any explicit memory
     * accesses. */
    __asm__ volatile ("dmb");
    old_value = *lock;
    *lock = 1;
    return old_value;
}

jserv avatar Aug 21 '13 23:08 jserv