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

Process Overhaul, Memory Tweaks, and Bug Squashing #117

Merged
merged 18 commits into from
Dec 5, 2024

Conversation

Galfurian
Copy link
Member

@Galfurian Galfurian commented Dec 5, 2024

Process Overhaul, Memory Tweaks, and Bug Squashing

1. Process Management Enhancements

  • PID Management:
    • Added pid_manager.c for bitmap-based PID handling with initialization, allocation, and deallocation. It's like givin' every process its own shiny teef!
    • Integrated pid_manager_get_free_pid in process.c and replaced old scheduler_getpid logic-no more fighting over IDs.
    • Refactored process_create_init to use dynamic PIDs and improved task initialization, makin' things run smoother than a well-oiled choppa.
    • Integrated pid_manager_mark_free to release PIDs when processes meet their glorious end.

2. Memory Management Improvements

  • Buddy System Enhancements (buddy_system.c, zone_allocator.c):
    • Reintroduced the buddy system code-because statically compiled libraries were more stubborn than a grot hoarding squigs.
    • Renamed buddysystem.h to buddy_system.h for consistency.
    • Added stricter validation and diagnostics for memory zone operations-ain't leavin' anything to chance!
  • Virtual Memory Enhancements (paging.c):
    • Beefed up error checks for virtual memory operations (create_vm_area, clone_vm_area, etc.). Now even da sneakiest bugs won't get through.
    • Tweaked constants for virtual memory mapping.
  • PMMNGR Refactor:
    • Overhauled pmmngr_init, adding a ton of error checks-turns out even memory likes a bit of discipline.
    • Split zone setup into pmmngr_initialize_pages and pmmngr_initialize_page_data. This way the code is re-usable and easier to understand.

3. Synchronization and Waiting

  • Wait Queue Refactor (wait.c):
    • Just change the naming for wait queue functions, before it was a mess (e.g., entry instead of wq), more guessin' wot wq means.
    • Introduced stop_wake_function for managing task STOP/CONT states, keepin' things in line.
  • Signal Updates (signal.c):
    • Integrated stop_wake_function into stopped_queue handling.
    • Polished up task restoration logic, like givin' a nob a fresh coat of paint.

4. Filesystem and String Handling

  • Safer Path Manipulation:
    • Replaced strcpy/strcat with safer strncpy/strncat in rm.c and t_mkdir.c-less risk of buffer overruns!
    • Added __build_path helper for reusable path concatenation in directory operations (t_mkdir.c).
  • Filesystem Enhancements:
    • Refactored ext2_write_inode_block for better reliability. EXT2 it's still a slog, but it won't krump itself apart anymore.
    • I don't know if it was in this PR or a previous one, but the way I was using kmem_cache_alloc in EXT2 was completely annihilating the kernel. I found that bug after speed-running a paper for a midnight deadline. Y'know what, what better thing to do after a paper deadline if not a tasty session of midnight-coding-wtf-is-that-thing!-did-I-introduced-that-bug?!?-no-more-beer-for-you-sir.

5. Debugging and Logging

  • Improved Logging:
    • Added a log_level parameter to __blkmngr_dump-more control over da noise we make.
  • Standardized Debug Messages:
    • Unified debug message formatting across debug.c and paging.c.

6. Error Handling Enhancements

  • Stricter Validations:
    • Introduced is_valid_virtual_address helper for safer address checks-no more orky guesswork.
    • Enhanced error handling and logging in memory and process management.
  • Standardized Return Paths:
    • Simplified error returns and removed redundant comments, 'cause nobody likes long-winded grot-speak.

7. Bug Fixes

  • Memory Safety:
    • Replaced unsafe string operations with bounded alternatives, keepin' da memory in check.
    • Fixed pointer arithmetic and alignment issues in boot.c.
  • Formatting Fixes:
    • Corrected format specifiers in t_msgget.c, t_semget.c, and related tests-accuracy matters, even to Orks.

8. Miscellaneous

  • Test Enhancements:
    • Updated test programs to check IPC and memory management changes. If da tests ain't happy, neither are we.
    • Polished up test output-lookin' good for da next battle.
  • Deprecations and Cleanups:
    • Removed unused macros and legacy variables all over the tests. Dead weight ain't for fightin'!
    • Commented out work-in-progress waitpid code for future tinkerin'.
  • Renaming for Consistency:
    • Renamed buddysystem.h to buddy_system.h and fixed include paths-da naming squigs have been tamed.

… no allocated blocks and updated debug messages to use magenta for better visibility. Da debug logs now shine like da loot, and da code won’t trip over empty chests.
… the maximum pid, then, it starts to hand out unallocated PID.
- Improved validation for virtual and physical address handling.
- Replaced verbose logging with string-based summaries.
- Introduced memory_info_t for better zone encapsulation.
- Fixed alignment and pointer arithmetic issues.
- Deprecated redundant macros and constants.
@Galfurian Galfurian changed the title Develop Process Overhaul, Memory Tweaks, and Bug Squashing Dec 5, 2024
@Galfurian Galfurian merged commit ddd88d1 into mentos-team:develop Dec 5, 2024
18 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.

1 participant