{"id":50501793,"url":"https://github.com/sinemistoktas/operating_systems-memory_allocation_simulator","last_synced_at":"2026-06-02T12:30:23.043Z","repository":{"id":303254153,"uuid":"1014874950","full_name":"sinemistoktas/operating_systems-memory_allocation_simulator","owner":"sinemistoktas","description":"Memory allocation simulator in C implementing First/Best/Worst Fit algorithms with automatic hole merging, compaction, and interactive/scripted modes","archived":false,"fork":false,"pushed_at":"2025-07-06T15:37:09.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-06T16:35:56.124Z","etag":null,"topics":["best-fit-algorithm","c-programming","contiguous-allocation","data-structures","first-fit-algorithm","fragmentation","hole-merging","linked-list","memory-allocation-simulation","memory-compaction","memory-management","operating-systems","systems-programming","worst-fit-algorithm"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sinemistoktas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-06T15:23:38.000Z","updated_at":"2025-07-06T15:43:50.000Z","dependencies_parsed_at":"2025-07-06T16:47:25.536Z","dependency_job_id":null,"html_url":"https://github.com/sinemistoktas/operating_systems-memory_allocation_simulator","commit_stats":null,"previous_names":["sinemistoktas/operating_systems-memory_allocation_simulator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sinemistoktas/operating_systems-memory_allocation_simulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinemistoktas%2Foperating_systems-memory_allocation_simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinemistoktas%2Foperating_systems-memory_allocation_simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinemistoktas%2Foperating_systems-memory_allocation_simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinemistoktas%2Foperating_systems-memory_allocation_simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinemistoktas","download_url":"https://codeload.github.com/sinemistoktas/operating_systems-memory_allocation_simulator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinemistoktas%2Foperating_systems-memory_allocation_simulator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33822812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["best-fit-algorithm","c-programming","contiguous-allocation","data-structures","first-fit-algorithm","fragmentation","hole-merging","linked-list","memory-allocation-simulation","memory-compaction","memory-management","operating-systems","systems-programming","worst-fit-algorithm"],"created_at":"2026-06-02T12:30:21.988Z","updated_at":"2026-06-02T12:30:23.031Z","avatar_url":"https://github.com/sinemistoktas.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Memory Allocation Simulator\n**Operating Systems - Project 2**  \n**Spring 2025 | Koç University**\n\n## Contributors\n- **Sinemis Toktaş**\n\n## Overview\nThis repository showcases Project 2 from the Operating Systems course completed at Koç University during Spring 2025. The project implements a comprehensive memory management simulator supporting contiguous memory allocation using three fundamental algorithms with both interactive and scripted execution modes.\n\n## Key Features\n\n### **Allocation Algorithms**\n- **First Fit (F):** Allocates memory in the first available hole large enough\n- **Best Fit (B):** Allocates memory in the smallest suitable hole\n- **Worst Fit (W):** Allocates memory in the largest available hole\n- **Case-Insensitive:** Supports both uppercase and lowercase strategy flags\n\n### **Core Operations**\n- **Request (RQ):** Allocate contiguous memory blocks with specified strategy\n- **Release (RL):** Deallocate memory with automatic adjacent hole merging\n- **Compact (C):** Consolidate fragmented holes into single contiguous block\n- **Status (STAT):** Display comprehensive memory layout and allocation map\n- **Exit (X):** Graceful program termination\n\n### **Execution Modes**\n- **Interactive Mode:** Real-time command processing with user prompts\n- **Scripted Mode:** Batch execution from command files with final status output\n- **Error Handling:** Robust validation with detailed error messages\n\n### **Advanced Features**\n- **Dynamic Memory Management:** Doubly-linked list for efficient operations\n- **Automatic Hole Merging:** Combines adjacent free blocks on deallocation\n- **Fragmentation Prevention:** Smart compaction algorithm\n- **Memory Safety:** Comprehensive bounds checking and validation\n\n## Usage\n\n### **Interactive Mode**\n```bash\n# Compile and run\ngcc starter-code.c -o allocator\n./allocator 1048576\n\n# Example session\nallocator\u003e RQ P0 40000 W     # Request 40KB using Worst Fit\nallocator\u003e RQ P1 25000 F     # Request 25KB using First Fit  \nallocator\u003e STAT              # Display memory status\nallocator\u003e RL P0             # Release P0's memory\nallocator\u003e C                 # Compact memory holes\nallocator\u003e X                 # Exit\n```\n\n### **Scripted Mode**\n```bash\n# Execute batch commands\n./allocator 1048576 commands.txt\n\n# Example commands.txt:\n# RQ P1 100000 B\n# RQ P2 50000 F  \n# RL P1\n# C\n```\n\n## Implementation Highlights\n\n### **Data Structures**\n- **Block Structure:** Doubly-linked list nodes with PID, base address, and size\n- **Memory Management:** Dynamic hole tracking with efficient insertion/deletion\n- **Process Validation:** Duplicate PID prevention and existence checking\n\n### **Key Algorithms**\n```c\n// Memory allocation with strategy selection\nvoid allocate(char* PID, int size, char *strategy)\n\n// Deallocation with automatic merging\nvoid deallocate(char* PID)  \n\n// Memory compaction with address recalculation\nvoid compact()\n\n// Comprehensive status reporting\nvoid status()\n```\n\n### **File Structure**\n```\nmemory-allocator/\n├── starter-code.c        # Main implementation\n├── allocator            # Compiled executable  \n├── Makefile            # Build configuration\n└── README.md           # This file\n```\n\n## Sample Output\n\n### **Memory Status Display**\n```\nAddresses [0:315000] Process P1\nAddresses [315001:512500] Process P3  \nAddresses [512501:625575] Unused\nAddresses [625576:725100] Process P6\nAddresses [725101:1048575] Unused\n```\n\n### **Error Handling**\n```\nERROR: Insufficient memory to allocate to the request.\nERROR: Given PID already exists!\nERROR: Given PID does not exist in memory.\n```\n\n## Technical Features\n\n### **Memory Management**\n- **Efficient Allocation:** O(n) time complexity for all allocation strategies\n- **Smart Merging:** Automatic combination of adjacent holes during deallocation\n- **Compaction Strategy:** Moves all processes to top, creates single hole at bottom\n- **Fragmentation Handling:** Minimizes external fragmentation through compaction\n\n### **Robust Design**\n- **Input Validation:** Comprehensive argument checking and error reporting\n- **Memory Safety:** Proper allocation/deallocation with leak prevention\n- **Edge Case Handling:** Boundary conditions and invalid operations\n- **Cross-Platform:** Compatible across different Linux distributions\n\n## Learning Outcomes\nThis project demonstrates proficiency in:\n- **Memory Management:** Practical implementation of allocation algorithms\n- **Data Structures:** Dynamic linked list operations and manipulation\n- **Algorithm Analysis:** Understanding of different allocation strategy trade-offs\n- **System Design:** Modular architecture with clean separation of concerns\n- **C Programming:** Advanced pointer manipulation and memory operations\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinemistoktas%2Foperating_systems-memory_allocation_simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinemistoktas%2Foperating_systems-memory_allocation_simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinemistoktas%2Foperating_systems-memory_allocation_simulator/lists"}