-
Notifications
You must be signed in to change notification settings - Fork 0
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
Shutdown/Reboot #116
Merged
Shutdown/Reboot #116
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
We can now shutdown and throw everything in the garbage since we don't save anything or handle any hardware power-off But this is a good first step. More to come later Signed-off-by: Amjad Alsharafi <[email protected]>
- Also added some comments for the trait Signed-off-by: Amjad Alsharafi <[email protected]>
- Now, the shutdown process can be started from anywhere with `power::start_shutdown`. - Then, the scheduler will not allow any new process, and will exit current processes when they get back to the scheduler. - The scheduler then will wait until all processes have shutdown. - Then, the cleanup starts. - For now only the filesystem is cleaned up (after closing all opened files, now we have opened files in the processes (which should all have dropped) and the log file, which is closed here). - Then, we issue ACPI command to shutdown the machine. Signed-off-by: Amjad Alsharafi <[email protected]>
This is needed because I tried implementing shutdown access from userspace through the `/devices` filesystem, and issuing shutdown command by writing to a specific file. It works well except when calling `scheduler::stop_scheduler`, because the `sys_write` syscall reads the files from the `Process` struct stored inside the `SCHEDULER`, and when calling `stop_scheduler` we will still be inside the `Mutex` of `SCHEDULER` and this causes double lock. The fix is to have the `SHUTDOWN` flag be global atomic, easy to modify, the scheduler will check if it needs to shutdown and does that and continue the shutdown procedure as is. Signed-off-by: Amjad Alsharafi <[email protected]>
…o them This will make it possible to implement something like: `echo shutdown > /devices/power` When opening a file that already exist with `>`, it will make it `truncate` to `0`, before this commit, truncating devices was invalid. Signed-off-by: Amjad Alsharafi <[email protected]>
Now we can do `echo shutdown > /devices/power` and it will shutdown the machine. We can implement other types as well of power commands. Signed-off-by: Amjad Alsharafi <[email protected]>
This just writes `shutdown` into `/devices/power`, but this is better implemented as part of `emerald_runtime` to be uniform Signed-off-by: Amjad Alsharafi <[email protected]>
There are several methods to perform reboot/reset, check: https://wiki.osdev.org/Reboot ACPI reset_register wasn't defined for me on my qemu setup, so the next best thing is using the keyboard PS2 device. Signed-off-by: Amjad Alsharafi <[email protected]>
Now we can shutdown and reboot with `power shutdown` and `power reboot`. It would be nice to have one command for each, but it would be more executable. A better approach is to support aliases. Signed-off-by: Amjad Alsharafi <[email protected]>
Signed-off-by: Amjad Alsharafi <[email protected]>
Signed-off-by: Amjad Alsharafi <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implemented shutdown functionality
Related issue
Partial fix for #38, only shutdown for now
Changes
\_Sx
fromAML
to be prepared for shutdown/sleep.\_Sx
data to issue a shutdown/sleep withACPI
.power::start_shutdown
is called.scheduler
stops scheduling and starts exiting processes when they arrive for rescheduling, keeps waiting until all have exited.ACPI
to finally shutdown the machine.reset_register
, but its not available for my testing setup now.shutdown
andreboot
through/devices/power
virtual deviceecho shutdown > /devices/power
orecho reboot > ...
power
commands that does the above, chooseshutdown
orreboot
Checklist