[kernel][thread] Consistent lock acquisition order in thread creation

This resolves a lock ordering violation where the ThreadDispatcher acquires its
lock before calling into the ProcessDispatcher. It is a ordering violation as
the ProcessDispatcher already has a code path, in KillAllThreadsLocked, where it
calls into the ThreadDispatcher.

The change here is to invert the logic of ThreadDispatcher::Start such that the
ProcessDispatcher, and not the ThreadDispatcher, is responsible for driving the
operation and acquiring the first lock. This inversion works as both the
ProcessDispatcher and ThreadDispatcher will 'not fail' after performing their
initial checks. As such although the checks now happen in a different order the
state updates still happen under the same total conditions, and are done with
their respective locks held and so are still atomic from the point of view of
any observers.

Without this change building and running with enable_lock_dep=true results in
a consistent lock order violation during early user startup.

Test: Kerenl unit tests and e2e tests

Change-Id: Ida54022e00bd42fb060a44adad3739de29930f5c
4 files changed
tree: 7aa3d09b53e9582b63f37e7494453e0cf4bdad50
  1. .clang-format
  2. .clang-tidy
  3. .dir-locals.el
  4. .gitattributes
  5. .gitignore
  6. .gn
  8. BUILD.gn
  12. OWNERS
  14. README.md
  15. boards/
  16. build/
  17. buildtools/
  18. bundles/
  19. docs/
  20. examples/
  21. garnet/
  22. infra/
  23. peridot/
  24. products/
  25. rustfmt.toml
  26. scripts/
  27. sdk/
  28. src/
  29. third_party/
  30. tools/
  31. zircon/


Pink + Purple == Fuchsia (a new operating system)

What is Fuchsia?

Fuchsia is a modular, capability-based operating system. Fuchsia runs on modern 64-bit Intel and ARM processors.

Fuchsia is an open source project with a code of conduct that we expect everyone who interacts with the project to respect.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See the documentation.