Skip to content

example: add multithreading example - #624

Merged
Indanz merged 1 commit into
seL4:mainfrom
Sadiqua-Parween:multithreading-example
Nov 19, 2026
Merged

Indanz merged 1 commit into
seL4:mainfrom
Sadiqua-Parween:multithreading-example

Conversation

@Sadiqua-Parween

Copy link
Copy Markdown
Contributor

This PR adds an example demonstrating multithreading and shared-memory synchronization in Microkit, as discussed in #602.

Summary

  • Sets up two Protection Domains (pd_a and pd_b) sharing a 4KB memory region.
  • Uses standard C11 atomics (<stdatomic.h>) to implement an atomic_flag spinlock for mutual exclusion.
  • Both PDs concurrently increment a shared counter in a loop and verify the final expected total on completion.
  • Includes build support across architectures and documentation in README.md.

Fixes #602

@dreamliner787-9 dreamliner787-9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, thank you for your contribution! A few comments from my side:

Comment thread example/multithreading/pd.c Resolved
Comment thread example/multithreading/shared.h Resolved
@dreamliner787-9

Copy link
Copy Markdown
Collaborator

Could you please squash your changes into one commit and fix the gitlint, I don't think we can do anything about the link check though...

Add an example demonstrating concurrency and shared-memory
synchronization in Microkit using two Protection Domains.

Both PDs map a shared memory region and increment a shared counter
under a C11 stdatomic spinlock, verifying the final counter value
on completion.

Fixes seL4#602

Signed-off-by: Sadiqua Parween <falaksadiqua786@gmail.com>
@Sadiqua-Parween

Copy link
Copy Markdown
Contributor Author

Hi @dreamliner787-9 , just checking in on this. Looks like all CI checks are green and approval is in. Let me know if there's anything else needed from my side before it can be merged.

@Indanz
Indanz merged commit eb16d47 into seL4:main Nov 19, 2026
12 checks passed
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.

Multithreading example

3 participants