Skip to content

Add rust synchronization primitives needed for the scheduler#2412

Merged
stevenengler merged 2 commits intoshadow:mainfrom
stevenengler:synchronization-primitives
Sep 16, 2022
Merged

Add rust synchronization primitives needed for the scheduler#2412
stevenengler merged 2 commits intoshadow:mainfrom
stevenengler:synchronization-primitives

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

@stevenengler stevenengler commented Sep 14, 2022

Adds the synchronization primitives (semaphore and count down latch) needed for the rust scheduler.

This count down latch is a little more complex than the C version since it supports multiple waiters. The main difficulties of using multiple waiters in the C version are:

  1. There isn't a nice way to synchronize which waiting thread will reset the latch, since it must always be the last waiting thread that resets the latch.
  2. If the waiters are modified so that the waiting thread that last takes the lock is the one to reset the latch, it leads to a new issue where the waiting threads could be notified, and one thread resumes and loops all the way back to the wait again before the other threads have a chance to resume.

@stevenengler stevenengler added the Component: Main Composing the core Shadow executable label Sep 14, 2022
@stevenengler stevenengler self-assigned this Sep 14, 2022
@stevenengler stevenengler force-pushed the synchronization-primitives branch 2 times, most recently from f510321 to 356af2b Compare September 14, 2022 23:43
@stevenengler stevenengler force-pushed the synchronization-primitives branch from bfc2327 to 32fec41 Compare September 16, 2022 15:06
@stevenengler stevenengler force-pushed the synchronization-primitives branch from 32fec41 to e57f419 Compare September 16, 2022 15:07
@stevenengler stevenengler merged commit 9d6953c into shadow:main Sep 16, 2022
@stevenengler stevenengler deleted the synchronization-primitives branch September 16, 2022 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Main Composing the core Shadow executable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants