Skip to content

chore(sync): migrated kernel atomics to the typed atomic wrappers - #177

Merged
FlareCoding merged 5 commits into
masterfrom
pr/almighty-atomic-migration
Aug 26, 2026
Merged

chore(sync): migrated kernel atomics to the typed atomic wrappers#177
FlareCoding merged 5 commits into
masterfrom
pr/almighty-atomic-migration

Conversation

@FlareCoding

@FlareCoding FlareCoding commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Note

Medium Risk
Mechanical but very broad changes in scheduler, signal delivery, and SMP boot synchronization; any mismatched memory order or non-atomic access on a formerly shared field could cause rare races or AP boot hangs.

Overview
Replaces widespread __atomic_* and volatile flag usage with sync::atomic<T> and sync::atomic_ref across the kernel (scheduling, signals, SMP, timers, IRQ/MSI dispatch, networking, PTY, reaper, sync primitives, and tests).

Type-level changes: hot shared fields are now atomics in structs—e.g. sched::task state, cleanup_stage, run_ticks; signal blocked/pending and group shared_pending/exit_signal; smp::cpu_info::state; poll/mutex owner, triggered, error; PTY/console foreground group; MSI handler slots; DHCP RX ready/active.

Access pattern: standalone counters and flags use sync::atomic methods (load_acquire, store_release, fetch_add_relaxed, cmpxchg_strong_acq_rel, etc.). Fields that stay plain scalars for layout/assembly (e.g. task_exec_core::on_cpu, exec.cpu, per-CPU epochs) are updated via sync::atomic_ref<uint32_t> / uint64_t.

Fences: IRQ registration and similar handoffs use sync::atomic_fence_release/acquire; kill/block and signal wake paths use a new sync::atomic_fence_seq_cst. A few failed-CMpxchg paths add an explicit acquire fence when adopting another thread’s winning value (e.g. group exit signal / exit_group status).

Test helpers and kernel tests switch from volatile + builtins to the same typed atomics for handshakes.

Reviewed by Cursor Bugbot for commit 61b9fb8. Bugbot is set up for automated code reviews on this repo. Configure here.

cursor[bot]

This comment was marked as resolved.

@FlareCoding
FlareCoding merged commit 50301a1 into master Aug 26, 2026
27 of 28 checks passed
@FlareCoding
FlareCoding deleted the pr/almighty-atomic-migration branch August 26, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant