{"id":15445347,"url":"https://github.com/bgmp/lru","last_synced_at":"2025-10-29T03:07:20.624Z","repository":{"id":161012210,"uuid":"537975984","full_name":"BGMP/LRU","owner":"BGMP","description":"LRU Page Replacement Algorithm Implementation written in C","archived":false,"fork":false,"pushed_at":"2023-10-16T22:25:52.000Z","size":125,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T13:11:18.388Z","etag":null,"topics":["c","cmake","learn","lru"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BGMP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2022-09-18T02:01:18.000Z","updated_at":"2024-07-20T22:38:55.000Z","dependencies_parsed_at":"2024-12-06T04:25:12.054Z","dependency_job_id":"0d0d0647-fb85-4c1d-83be-e1b8e392144f","html_url":"https://github.com/BGMP/LRU","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.4545454545454546,"last_synced_commit":"4ddd4e991a10a28414a8c2d2ce66ad1f6bf36bf4"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BGMP%2FLRU","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BGMP%2FLRU/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BGMP%2FLRU/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BGMP%2FLRU/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BGMP","download_url":"https://codeload.github.com/BGMP/LRU/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249795202,"owners_count":21326777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["c","cmake","learn","lru"],"created_at":"2024-10-01T19:44:43.930Z","updated_at":"2025-10-29T03:07:20.549Z","avatar_url":"https://github.com/BGMP.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"LRU\n===\nMemory administration emulator built in C.\n\nThis program emulates memory management implementing the LRU (Least Recently Used) page replacement algorithm. The \nimplementation is rather simple, and it aims to be easy to read and understand.\n\nThis is a project I made for an Operative Systems class, which I decided to tidy up and upload to GitHub as an academic\nresource for anybody to peek into.\n\n### General Overview\nAs stated in the brief summary above, this program is meant to be a resource for people who would like to understand\nand experiment with page replacement algorithms. The project scope is rather minimal, and there are limitations to its\nstructure, yet those limitations are meant to be easily tweakable!\n\nEverything relevant to the program is located at `obj_RAM.h`, which represents the memory in question. There are\na few macros you may modify at will:\n\n```c\n#define UNSET_VAL -1      // Represents values pending to be set\n#define REQUESTS 20       // Number of requests the memory will be processing\n#define FRAMES 4          // Number of page frames\n```\n\nAnd there is the main structure which holds the relevant information altogether.\n\n```c\ntypedef struct RAM {\n    FILE *logFile;\n    int requests[REQUESTS];\n    int contents[FRAMES][REQUESTS];\n    int lruMatrix[FRAMES][FRAMES];\n    int faults;\n} RAM;\n```\n\nWhen executing, the program will both log all the steps to console and to a TXT log file you will find located at\n`logs/`. The name of the file will be something like `log_LRU_2022-09-15_16-47-05.txt`.\n\n### Output\nEach step of the page assignment process is written to the log file. Below is the last step, or rather the\nmemory representation after the last process has been computed and assigned to a page.\n\nValue set:\n```c\nint sample[REQUESTS] = {\n        1, 3, 2, 1, 4, 2, 5, 6, 2, 1,\n        2, 3, 7, 6, 3, 2, 1, 2, 3, 6\n};\n```\n\nOutput:\n```\n RQ |  1   3   2   1   4   2   5   6   2   1   2   3   7   6   3   2   1   2   3   6  | LRU Matrix\n----|---------------------------------------------------------------------------------|--------------|-\n  0 |  1   1   1   1   1   1   1   6   6   6   6   6   7   7   7   7   1   1   1   1  |  0  0  0  0  |\n  1 |      3   3   3   3   3   5   5   5   5   5   3   3   3   3   3   3   3   3   3  |  1  0  1  0  |\n  2 |          2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2  |  1  0  0  0  |\n  3 |                  4   4   4   4   4   1   1   1   1   6   6   6   6   6   6   6  |  1  1  1  0  |\n----|---------------------------------------------------------------------------------|--------------|-\n11F |\n```\n\nAt the top, all processes are listed horizontally after RQ (requests). The LRU Matrix is also logged for each step,\nupdated with the latest data. Underneath RQ are the page frame numbers, and under them the number of faults (11F in\nthis case). All processes are in the middle, already assigned to their corresponding page in this final step.\n\n### Building\n\nYou may build the project using CMake.\n\n```sh\nmkdir build \u0026\u0026 cd build\ncmake ..\nmake\n```\n\nThe project requires one directory to be present physically within its root folder, along with a couple of DLLs to\nfunction properly:\n  - logs/\n  - libiconv-2.dll\n  - libunistring-2.dll\n\nYou may also get a pre-packaged version for Windows 64.\n\n### Running\n\nYou may run the `LRU` binary and the program will function normally, just make sure all the required files/directories\nare present within the directory you're executing it at.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgmp%2Flru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbgmp%2Flru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgmp%2Flru/lists"}