-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial implementation of spawnable forth tasks #53
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for merry-scone-cc7a60 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
jamesmunns
approved these changes
Jun 4, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I think there are definitely some open questions, but I figure we'll stand a better chance at answering them after playing with the system for a while.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch adds an initial working implementation of a
spawn
builtinword for Forth tasks. The
spawn
word takes the address of a word inthe Forth VM's dictionary, and spawns a new child VM that will begin
executing that word.
The child task is created with a
bbqueue
bi-directional channel forits input and output streams, although these are currently not used yet.
Subsequent changes will probably need to give parent tasks a way to
actually send inputs/outputs to their children, if that's something we
want to do. Currently, though, we can basically only see that the child
task is running by checking the kernel logs for evidence of its
activity, or by having it open serial mux ports and communcate on them.
Potential Future Work
In follow-up branches, we should probably add some new builtins:
maitake
timerwheel!)
spawned child task's
JoinHandle
)(
maitake::future::yield_now()
)Some Notes
In order to make this work, I had to increase the kernel heap size in
Melpomene significantly. One consequence of the async allocator is that
if a task is trying to make an allocation that there's no space in the
heap for, and no other tasks are going to free memory that will make
that allocation possible, the child task just hangs forever and it's not
obvious why. We may want to consider adding debug logging to the
allocator so that we know when a task can't allocate because the heap is
full. Also, we may want to consider making futures run in
Kernel::initialize
(rather thanKernel::spawn
) set some kind of flagthat makes the allocator panic on OOMs instead of waiting for heap
capacity. Since the
initialize
futures run before the OS is actuallyready to run user input, and most tasks started in
initialize
areparts of the OS that will run for as long as the system is up (and
therefore probably won't release most of their allocations), we may want
OOMs to be fatal while starting up, and only make user task
allocations wait for heap capacity. Just a thought.