Skip to content
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

310551038 lab5–8 #127

Open
wants to merge 51 commits into
base: 310551038
Choose a base branch
from
Open

310551038 lab5–8 #127

wants to merge 51 commits into from

Conversation

abt8601
Copy link

@abt8601 abt8601 commented Jun 29, 2023

Self-Check

  • The base branch belongs to me.
  • There are no large files, useless binaries, or temporary files in the new commits.
  • The PR name contains my student ID and lab assignment number. eg. 0816171 lab0

Description

This PR completes labs 5–8. Namely, the following are completed:

  • Lab 5: Thread and User Process: All
  • Lab 6: Virtual Memory: All
  • Lab 7: Virtual File System: All
  • Lab 8: Non-volatile Storage: All

Everything runs on a real machine.

TODO

Bug Fixes

  • Fix release builds.
  • Fix run queue corruption that causes terminated threads to be scheduled.

Optional Features

  • Properly implement a red-black tree to speed up various operations.

Others

  • Provide a Rust implementation.

abt8601 added 30 commits June 1, 2023 14:30
The consistency checks were meant to guarantee the correct operation of
the kernel by making sure that everything is loaded into the memory in a
sensible way (e.g. the memory region used by the kernel doesn't overlap
with other reserved regions). However, they make the code convoluted.
Given that the probability of something being incorrectly loaded is
exceedingly low in practice, it makes more sense not to include these
checks.

The quicksort implementation remains in the source tree, albeit becoming
unused.
Other changes:

- Properly handle critical sections in memory allocators.

- Fixes a bug in the dynamic memory allocator that causes memory
  corruption.

- Disable page frame allocator debug log.
Other changes:

- Scheduler:

  - Partial rewrite to simplify design.

  - The current thread no longer remains on the run queue after being
    scheduled.

- Serial console:

  - Redesign around non-blocking primitives.

  - Add new non-blocking functions.

  - Add read/write readiness notification facility.

- Dynamic memory allocator:

  - Fix a bug in `free` that causes the incorrect slot to be freed.

- (Old) User program:

  - Retired. Superseded by the current scheduler.

- Testers:

  - Retire `xcpt_test` since it no longer works.

  - Add `syscall_test` that tests some system calls.

  - Add a minimal libc.

TODO:

- Properly implement red-black tree in order to speed up the process of
  finding a process by its PID.
Other changes:

- Scheduler:

  - Disable user stack sharing by default.

  - Fix `get_process_by_id` and `kill_all_processes`.

- System call:

  - Change the return values of `sys_mbox_call` to match the video
    player.

- Main function:

  - Remove scheduler test code.
The default exception handler now starts a kernel panic instead of
returning. This aids in debugging by avoiding cluttering the serial
console due to repeated triggering of the same exception.
Other changes:

- Adjust text width in the default exception handler.

TODO:

- Fix the release build.
- User-space memory is now mapped as normal memory instead of device
  memory.

- Kernel memory now disallows non-privileged access.
`sys_mbox_call` now copies the mailbox buffer into the kernel before
calling `mailbox_call`. This is because it is generally unsafe to pass
the user-space buffer directly, since it may be discontinuous
physically.
Other changes:

- Disable demand paging/CoW debug log.

- Fix a bug in `free` that causes an incorrect slot to be freed.
Fix a bug in `free` that causes an incorrect slot to be freed.

Backported from 8a64b30.
Other changes:

- Add a workaround for a run queue corruption but that causes terminated
  threads to be scheduled.
Other changes:

- Fix a bug in `_vm_drop_page_table` (called by `vm_drop_addr_space`)
  that causes memory leak by not freeing pages.
`deliver_signal` depends on the invariant that, if the `is_waiting`
status bit is set on a thread, then that thread must be in a wait
queue. However, when waking up a thread from a wait queue, the
`is_waiting` status bit was not correctly cleared, causing
`deliver_signal` to corrupt the run queue.
abt8601 added 16 commits July 1, 2023 23:04
`shared_page_decref` used to dereference null pointers when called on a
non-shared page.
Other changes:

- Fix memory leaks in `_tmpfs_create` and `_tmpfs_mkdir`.
Other changes:

- Fix syscall number checking in `xcpt_svc_handler`.
Other changes:

- Move `SEEK_*` constants around.

- Properly handle setup errors in `vfs_mount`.

- Add missing `static`s.
- Stops assuming that the number of sectors per cluster is 1.

- Fix memory leak in `_sd_fat32_read`.

- Slightly clean up `_sd_fat32_read`.

- Remove useless code in `_sd_fat32_lseek64`.

- Adds component name check in `_sd_fat32_lookup`.

- Stops assuming that directories live in 1 cluster.
- Fix file size update in `_sd_fat32_write`.

- `_sd_fat32_write` now persists the file size update in the SD card.

- Fix directory entries used for LFN being overwritten in
  `_sd_fat32_create_impl`.

- Fix directory table persistence using the wrong LBA in
  `_sd_fat32_create_impl`.
Implements block-level caching, which covers FAT caching and file
content caching. Metadata caching (both FS-level and file-level) and the
component name cache have been implemented, accidentally, by the
previous commits.

Also fixes signal handling due to a wrong system call number for the
`sys_sigreturn` system call.
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.

1 participant