{"id":21203745,"url":"https://github.com/bl33h/coffeefactorysimulation","last_synced_at":"2025-03-14T22:44:27.656Z","repository":{"id":69081008,"uuid":"533491276","full_name":"bl33h/coffeeFactorySimulation","owner":"bl33h","description":"A program that simulates a coffee factory with parallel processing using pthreads. It handles coffee production, storage, and thread synchronization.","archived":false,"fork":false,"pushed_at":"2023-06-17T22:33:40.000Z","size":137,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T15:15:28.973Z","etag":null,"topics":["coffee","factory","mutex","mutex-lock","parallel-computing","parallel-programming","posix-threads","pthreads","simulation","synchronization"],"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/bl33h.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":"2022-09-06T20:25:52.000Z","updated_at":"2023-06-17T22:40:57.000Z","dependencies_parsed_at":"2024-11-20T20:39:31.805Z","dependency_job_id":null,"html_url":"https://github.com/bl33h/coffeeFactorySimulation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bl33h%2FcoffeeFactorySimulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bl33h%2FcoffeeFactorySimulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bl33h%2FcoffeeFactorySimulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bl33h%2FcoffeeFactorySimulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bl33h","download_url":"https://codeload.github.com/bl33h/coffeeFactorySimulation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243658177,"owners_count":20326464,"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":["coffee","factory","mutex","mutex-lock","parallel-computing","parallel-programming","posix-threads","pthreads","simulation","synchronization"],"created_at":"2024-11-20T20:26:29.774Z","updated_at":"2025-03-14T22:44:27.046Z","avatar_url":"https://github.com/bl33h.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# coffeeFactorySimulation\nThis code simulates a coffee factory using pthreads for parallel processing. It models the production and storage of coffee. The program utilizes multiple threads for toasters and a baler. The toasters generate toasted coffee pounds, while the baler creates coffee bags and stores them in the storage. The simulation runs until specific conditions are met, such as reaching a certain number of coffee pounds or a specific count for the coffee produced by the toasters. Mutex locks are implemented to ensure thread safety when accessing and modifying the coffee control structure.\n\n\u003cp align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003cimg src=\"https://cdn.dribbble.com/users/922608/screenshots/3283682/coffee_machine.gif\" alt=\"pic\" width=\"500\"\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\u003cp align=\"center\" \u003e\n  \u003ca href=\"#Files\"\u003eFiles\u003c/a\u003e •\n  \u003ca href=\"#Features\"\u003eFeatures\u003c/a\u003e •\n  \u003ca href=\"#how-to-use\"\u003eHow To Use\u003c/a\u003e \n\u003c/p\u003e\n\n## Files\n\n- src: the file that implements de solution.\n- flowchart: flowchart: the model construction.\n\n## Features\nThe main features of the application include:\n- Multithreading: The code uses pthreads to create and manage multiple threads concurrently, allowing for parallel execution of tasks.\n- Mutex Locks: Mutex locks are implemented using the `pthread_mutex_t` structure to provide mutual exclusion and ensure thread safety when accessing shared resources, such as the coffee control structure.\n- Structured Data: The code defines a `coffeeControl` structure to encapsulate and organize data related to coffee production and storage.\n- Condition-based Loops: The code utilizes while loops with specific conditions to control the execution flow and simulate the coffee production process until certain criteria are met.\n- Input/Output: The code utilizes standard input/output operations to display information about the coffee production, toasters, and storage quantities during the simulation.\n- Time Delay: The `sleep` function is used to introduce a delay of one second between certain operations, simulating the passage of time or allowing for synchronization between threads.\n- Error Handling: The code includes error handling mechanisms, such as checking the return values of pthread functions and handling potential errors related to mutex operations.\n- File Inclusion: The code includes several header files, such as `\u003cstdlib.h\u003e`, `\u003cstdio.h\u003e`, and `\u003cpthread.h\u003e`, to provide necessary function declarations and definitions for the program's functionality.\n\n\n## How To Use\nTo clone and run this application, you'll need [Git](https://git-scm.com) and a [C++ compiler](https://www.fdi.ucm.es/profesor/luis/fp/devtools/mingw.html) installed on your computer. From your command line:\n\n```bash\n# Clone this repository\n$ git clone https://github.com/bl33h/coffeeFactorySimulation\n\n# Open the folder\n$ cd src\n\n# Run the app\n$ g++ coffeeFactorySimulation.cpp -o coffeeFactorySimulation\n$ ./coffeeFactorySimulation\n```\n\nAlternatively, you can run the code using Google Colab:\n1. [Open Google Colab](https://colab.research.google.com) in your web browser.\n2. Click on \"File\" in the top menu, then select \"Open notebook\".\n3. In the \"GitHub\" tab, enter the repository URL: https://github.com/bl33h/coffeeFactorySimulation\n4. Choose the desired notebook file and click \"Open\".\n5. Follow the instructions within the Colab notebook to execute the code.\n\nNote: Running the code in Google Colab requires an internet connection and a Google account. It provides a convenient online environment for executing code without the need for local setup or dependencies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbl33h%2Fcoffeefactorysimulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbl33h%2Fcoffeefactorysimulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbl33h%2Fcoffeefactorysimulation/lists"}