Changeset efed95a3 in mainline for kernel/generic/include


Ignore:
Timestamp:
2024-01-20T17:09:00Z (2 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
3d84734
Parents:
286da52
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-20 16:12:46)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-20 17:09:00)
Message:

Make thread→cpu weakly atomic, to avoid need for thread lock

Location:
kernel/generic/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/atomic.h

    r286da52 refed95a3  
    3939#include <typedefs.h>
    4040#include <stdatomic.h>
     41
     42/*
     43 * Shorthand for relaxed atomic read/write, something that's needed to formally
     44 * avoid undefined behavior in cases where we need to read a variable in
     45 * different threads and we don't particularly care about ordering
     46 * (e.g. statistic printouts). This is most likely translated into the same
     47 * assembly instructions as regular read/writes.
     48 */
     49#define atomic_set_unordered(var, val) atomic_store_explicit((var), (val), memory_order_relaxed)
     50#define atomic_get_unordered(var) atomic_load_explicit((var), memory_order_relaxed)
    4151
    4252#define atomic_predec(val) \
  • kernel/generic/include/proc/thread.h

    r286da52 refed95a3  
    138138
    139139        /** Thread CPU. */
    140         cpu_t *cpu;
     140        _Atomic(cpu_t *) cpu;
    141141        /** Containing task. */
    142142        task_t *task;
Note: See TracChangeset for help on using the changeset viewer.