{"id":15003630,"url":"https://github.com/yeong-hwan/kernel-simulator","last_synced_at":"2026-02-28T06:25:11.041Z","repository":{"id":263318313,"uuid":"762967918","full_name":"yeong-hwan/kernel-simulator","owner":"yeong-hwan","description":"OS simulator by C++ that emulates the Linux kernel","archived":false,"fork":false,"pushed_at":"2024-02-28T15:30:33.000Z","size":1059,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T14:34:28.798Z","etag":null,"topics":["cpp","linux-kernel","os-simulator","system-calls"],"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/yeong-hwan.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}},"created_at":"2024-02-25T07:37:37.000Z","updated_at":"2024-11-05T08:34:09.000Z","dependencies_parsed_at":"2024-11-17T20:46:09.517Z","dependency_job_id":"0e4d22a4-8022-4f6d-9dd3-bf962ecae055","html_url":"https://github.com/yeong-hwan/kernel-simulator","commit_stats":null,"previous_names":["yeong-hwan/kernel-simulator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeong-hwan%2Fkernel-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeong-hwan%2Fkernel-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeong-hwan%2Fkernel-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeong-hwan%2Fkernel-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeong-hwan","download_url":"https://codeload.github.com/yeong-hwan/kernel-simulator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243158973,"owners_count":20245669,"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":["cpp","linux-kernel","os-simulator","system-calls"],"created_at":"2024-09-24T18:59:33.087Z","updated_at":"2026-02-28T06:25:05.997Z","avatar_url":"https://github.com/yeong-hwan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kernel-simulator\n\n## Process Overview\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/imgs/process_overview.jpg\" alt=\"drawing\" width=\"600\"/\u003e\n\u003c/p\u003e\n\n\n## Virtual Program Commands\n- System call: **memory_allocate, memory_release, fork_and_exec, wait, exit**\n  - Assume the parent process executes and waits for the execution time of fork_and_exec.\n  - Sleep from the second assignment is not implemented in this assignment.\n- User code commands: **memory_read, memory_write**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/imgs/process_status.png\" alt=\"drawing\" width=\"600\"/\u003e\n\u003c/p\u003e\n\n## Documatation\n\n**System Call**\n- [memory_allocate](docs/memory_allocate.md)\n- [memory_release](docs/memory_release.md)\n- [for_and_exec](docs/fork_and_exec.md)\n- [wait](docs/wait.md)\n- [exit](docs/exit.md)\n\n**User code commands**\n- [memeory_write](docs/memory_write.md)\n- [memory_read](docs/memory_read.md)\n\n## Process details\n\n### Input command \u0026 mode switch\nIn the case of the user mode, the command of the received current process is imported one line. Memory_allocate, memory_release, memory_read, memory_write, fork_and_exec, wait, and exit are separated into strings, and the argument is divided by substr slicing.  \n\nOperations moving on to a system call or fault are reflected in the next cycle by switching kernel mode. The operations following in the kernel mode are assigned cycles, respectively, and the number of cycles is designated to perform a predetermined operation.\n\n```cpp\n// user case\nif (mode == \"user\")\n{\n    // not running\n    if (run_remain_cycle == 0)\n    {\n        list\u003cpair\u003cint, queue\u003cstring\u003e *\u003e\u003e::iterator iter2;\n        queue\u003cstring\u003e *user_command_queue;\n        for (iter2 = pid_command_list.begin();\n              iter2 != pid_command_list.end(); iter2++)\n        {\n            int pid = iter2-\u003efirst;\n            user_command_queue = iter2-\u003esecond;\n\n            if (process_now-\u003eid == pid)\n            {\n                command = (*user_command_queue).front();\n                (*user_command_queue).pop();\n                break;\n            }\n        }\n\n        string command_sliced = command.substr(0, 1);\n\n        string command_memory;\n        // cout \u003c\u003c command;\n\n        if (command_sliced == \"m\") {\n            command_memory = command.substr(7, 3);\n            // answer += command_memory;\n            // break;\n\n            // allocate [systeml_call]\n            if (command_memory == \"all\")\n            {\n                memory_allocate_num = stoi(command.substr(16));\n                allocate_cycle = 2;\n                mode = \"kernel\";\n            }\n            // release [system_call]\n            else if (command_memory == \"rel\")\n            {\n                memory_release_num = stoi(command.substr(15));\n                release_cycle = 2;\n\n                mode = \"kernel\";\n            }\n        }\n    }\n}\n```\n\n## Fixed actions \u0026 Page related command actions\n\n### memory_allocate : flow \nMemory_allocate proceeded in the following order.\nAmong the page replacement algorithms, only fifo was partially implemented.\n1. start_index finding\n2. If issue:\n    - Page fault handler\n    - By page replace algorithm\n3. page_allocation\n4. frame_allocation\n5. page_table update\n    - page_location\n    - page_RorW_info\n\n### memory_write\nOther commands can be implemented according to the specification, but in particular, memory_write is a command that requires consideration of the page replacement algorithm.  \nLike memory_allocate, the frame, page, and page_table information were updated.\n\n### scheduling\nIn the cycle of finishing the kernel mode operation, the current process must be scheduled, which was implemented by changing the state variable of the process from Ready to Running. It was simplified by implementing the schedule() function inside the class\n\n### Kernel : fork_and_exec\nIn the case of a command in which mode switching occurs in user mode, fork_cycle, sleep_cycle, and wait_cycle are assigned. In this way of reducing the command count, it is designed to check the command count every time it rotates the while loop and perform a predetermined operation. In the case of Fork_and_exec, a new forked_process was created and a command list corresponding to the forked_process was read from the user_command list.\n\n## Snapshot\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/imgs/result.png\" alt=\"drawing\" width=\"500\"/\u003e\n\u003c/p\u003e\n\n## Environment\nOS: Mac Ventura  \nLanguage: C++ 17","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeong-hwan%2Fkernel-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeong-hwan%2Fkernel-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeong-hwan%2Fkernel-simulator/lists"}