diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-07-26 22:13:52 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-26 22:13:52 +0200 |
| commit | 705c98d47937d603e3ad569cc2ade12fa1df3677 (patch) | |
| tree | 6cd980e01943a87126ec51a248ffc4f03a195e5f /kernel/kapi/devices | |
| parent | 4b28e4626e744ac9b779a680f8e9647014956dda (diff) | |
| download | kernel-705c98d47937d603e3ad569cc2ade12fa1df3677.tar.xz kernel-705c98d47937d603e3ad569cc2ade12fa1df3677.zip | |
build: add tsan build
Diffstat (limited to 'kernel/kapi/devices')
| -rw-r--r-- | kernel/kapi/devices/bus.cpp | 12 | ||||
| -rw-r--r-- | kernel/kapi/devices/bus.stress.cpp | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/kernel/kapi/devices/bus.cpp b/kernel/kapi/devices/bus.cpp index 71dd01e6..2b94e486 100644 --- a/kernel/kapi/devices/bus.cpp +++ b/kernel/kapi/devices/bus.cpp @@ -11,7 +11,6 @@ #include <kstd/vector.hpp> #include <algorithm> -#include <span> #include <utility> namespace kapi::devices @@ -36,7 +35,10 @@ namespace kapi::devices auto bus::add_child(kstd::shared_ptr<device> child) -> void { - child->set_parent(kstd::static_pointer_cast<bus>(shared_from_this())); + { + auto guard = kstd::lock_guard{m_lock}; + child->set_parent(kstd::static_pointer_cast<bus>(shared_from_this())); + } if (!kapi::devices::device_registry::get().add(child)) { @@ -74,9 +76,11 @@ namespace kapi::devices return true; } - [[nodiscard]] auto bus::children() const -> std::span<kstd::shared_ptr<device> const> + [[nodiscard]] auto bus::children() const -> kstd::vector<kstd::shared_ptr<device>> { - return {m_devices.data(), m_devices.size()}; + auto guard = kstd::lock_guard{m_lock}; + + return m_devices; } auto bus::query_facet(kapi::capabilities::facet_id facet) -> void * diff --git a/kernel/kapi/devices/bus.stress.cpp b/kernel/kapi/devices/bus.stress.cpp index 226b0296..3fefc892 100644 --- a/kernel/kapi/devices/bus.stress.cpp +++ b/kernel/kapi/devices/bus.stress.cpp @@ -21,7 +21,7 @@ namespace } // namespace -constexpr auto thread_count = 32; +constexpr auto thread_count = 8; constexpr auto devices_per_thread = 200; SCENARIO("Concurrent attach/detach/lookup on a bus is race-free") |
