{"id":21288647,"url":"https://github.com/abdo-essam/synchronization-in-operating-systems","last_synced_at":"2025-03-15T15:42:31.440Z","repository":{"id":260545694,"uuid":"652271607","full_name":"abdo-essam/Synchronization-In-Operating-Systems","owner":"abdo-essam","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-11T16:22:25.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T05:41:22.445Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/abdo-essam.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":"2023-06-11T16:18:23.000Z","updated_at":"2023-06-11T16:22:28.000Z","dependencies_parsed_at":"2024-10-31T23:52:28.367Z","dependency_job_id":null,"html_url":"https://github.com/abdo-essam/Synchronization-In-Operating-Systems","commit_stats":null,"previous_names":["abdo-essam/synchronization-in-operating-systems"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdo-essam%2FSynchronization-In-Operating-Systems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdo-essam%2FSynchronization-In-Operating-Systems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdo-essam%2FSynchronization-In-Operating-Systems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdo-essam%2FSynchronization-In-Operating-Systems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abdo-essam","download_url":"https://codeload.github.com/abdo-essam/Synchronization-In-Operating-Systems/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243753995,"owners_count":20342537,"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":[],"created_at":"2024-11-21T12:23:49.761Z","updated_at":"2025-03-15T15:42:31.403Z","avatar_url":"https://github.com/abdo-essam.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Problem description\r\n\r\nIt is required to simulate a limited number of devices connected to a router’s Wi-Fi using Java threading and semaphore. Routers can be designed to limit the number of open connections. For example, a Router may wish to have only N connections at any point in time. As soon as N connections are made, the Router will not accept other incoming connection until an existing connection is released. Explain how semaphores can be used by a Router to limit the number of concurrent connections.\r\n\r\n## Consider the following rules\r\n\r\n- The Wi-Fi number of connected devices is initially empty.\r\n- If a client is logged in (print a message that a client has logged in) and if it can be served (means that it can reach the internet), then the client should perform the following activities:\r\n  - Connect\r\n  - Perform online activity\r\n  - Log out\r\n\r\n**`Note:` these actions will be represented by printed messages, such that there is a random waiting time between the printed messages when a client connects, do some online activities and logged out.**\r\n▪ If a client arrives and all connections are occupied, it must wait until one of the currently available clients finishes his service and leave.\r\n▪ After a client finishes his service, he leave and one of the waiting clients (if exist) will connect to the internet.\r\n\r\n## Problem Design\r\n\r\nYou program must contain the following classes:\r\n\r\n1. Router Class: that contains a list of connection and methods to occupy a connection and release a connection.\r\n2. Semaphore Class: as given the synchronization lab.\r\n3. Device Class: represent different devices (threads) that can be connected to the router; each device has its own name (i.e. C1) and type (i.e. mobile, pc, tablet...) and it may perform three activities: connect, perform online activity and disconnect/logout.\r\n4. Network Class: this class contains the main method in which the user is asked for two inputs:\r\n▪ N: max number of connections a router can accept\r\n▪ TC: total number of devices that wishes to connect).\r\n▪ TC lines that contain: name of each device, and its type.\r\n\r\n## Program Output:\r\n\r\nYou will print the output logs in a file, which simulates the execution order of the devices threads and the printed messages of each device.\r\n\r\n## Example:\r\n\r\n### `Sample Input:`\r\n\r\n```\r\nWhat is number of WI-FI Connections? 2\r\nWhat is number of devices Clients want to connect? 4\r\nC1 mobile\r\nC2 tablet\r\nC3 pc\r\nC4 pc\r\n```\r\n\r\n### `Sample output:` (Note: output depends on the order of the executions of the threads)\r\n\r\n```\r\n- (C1)(mobile)arrived\r\n- (C2)(tablet)arrived\r\n- Connection 1: C1 Occupied\r\n- Connection 2: C2 Occupied\r\n- C4(pc) arrived and waiting\r\n- C3(pc)arrived and waiting\r\n- Connection 1: C1 performs online activity\r\n- Connection 2: C2 performs online activity\r\n- Connection 1: C1 Logged out\r\n- Connection 1 : C4 Occupied\r\n- Connection 1 : C4 performs online activity\r\n- Connection 2: C2 Logged out\r\n- Connection 2: C3 Occupied\r\n```\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdo-essam%2Fsynchronization-in-operating-systems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabdo-essam%2Fsynchronization-in-operating-systems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdo-essam%2Fsynchronization-in-operating-systems/lists"}