{"id":25268255,"url":"https://github.com/julian3sp/multi-threaded-producer-consumer","last_synced_at":"2026-04-30T13:31:29.861Z","repository":{"id":277018169,"uuid":"931066214","full_name":"julian3sp/Multi-Threaded-Producer-Consumer","owner":"julian3sp","description":"Multi-threaded producer-consumer implementation in C using `pthread`, semaphores for synchronization, and a barrier to ensure all consumers complete execution. Configurable buffer size and file-based input.","archived":false,"fork":false,"pushed_at":"2025-02-11T17:05:39.000Z","size":78,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T18:23:25.794Z","etag":null,"topics":["cpp","linux","multithreading"],"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/julian3sp.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":"2025-02-11T17:01:05.000Z","updated_at":"2025-02-11T17:09:54.000Z","dependencies_parsed_at":"2025-02-11T18:34:32.732Z","dependency_job_id":null,"html_url":"https://github.com/julian3sp/Multi-Threaded-Producer-Consumer","commit_stats":null,"previous_names":["julian3sp/multi-threaded-producer-consumer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julian3sp%2FMulti-Threaded-Producer-Consumer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julian3sp%2FMulti-Threaded-Producer-Consumer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julian3sp%2FMulti-Threaded-Producer-Consumer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julian3sp%2FMulti-Threaded-Producer-Consumer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/julian3sp","download_url":"https://codeload.github.com/julian3sp/Multi-Threaded-Producer-Consumer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247431237,"owners_count":20937917,"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","multithreading"],"created_at":"2025-02-12T10:24:26.284Z","updated_at":"2026-04-30T13:31:29.830Z","avatar_url":"https://github.com/julian3sp.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Multi-Threaded Producer-Consumer with Barrier Synchronization  \n\n## Overview  \nThis program implements a multi-threaded producer-consumer model using `pthread` in C++. The producer reads input from a file and adds data to a shared buffer, while multiple consumer threads process the data. Synchronization is handled using semaphores, and a barrier ensures all consumers finish processing together.  \n\n## Features  \n- **Multi-threaded producer-consumer model** using `pthread`.  \n- **Semaphore synchronization** to control access to the shared buffer.  \n- **Barrier synchronization** to ensure all consumers complete execution.  \n- **Configurable buffer size** through command-line arguments.  \n- **Reads input from a file** to simulate production.  \n\n## Usage  \n### Compilation  \nTo compile the program, run:  \n```sh\ngcc -o pcthreads proj3.cpp -pthread\n```  \n\n### Running the Program  \n```sh\n./pcthreads \u003cbuffer_size\u003e \u003c testData.txt\n```  \n- `\u003cbuffer_size\u003e`: Size of the shared buffer (optional, defaults to 1).  \n- `testData.txt`: Input file containing data for the producer.  \n\n#### Example  \n```sh\n./pcthreads 5 \u003c testData.txt\n```  \nRuns the program with a buffer size of **5**, processing input from `testData.txt`.  \n\n## Implementation Details  \n- **Producer** reads input and adds data to the buffer.  \n- **Consumers** retrieve data and process it.  \n- **Semaphores** regulate access to the buffer.  \n- **Barrier synchronization** ensures all consumers finish together.  \n\n## File Structure  \n```\n.\n├── proj3.cpp        # Source code for the producer-consumer implementation\n├── testData.txt     # Sample input file\n├── pcthreads        # Compiled executable\n└── README.md        # Project documentation\n```  \n\n## Possible Improvements  \n- Allow the number of producers/consumers to be specified via command-line arguments.  \n- Implement logging for debugging and performance analysis.  \n- Optimize synchronization to reduce overhead.  \n\n## Author  \n- **Julian Espinal**  \n- **julianrespinal24@gmail.com**  \n- **[https://github.com/julian3sp/]**  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulian3sp%2Fmulti-threaded-producer-consumer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulian3sp%2Fmulti-threaded-producer-consumer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulian3sp%2Fmulti-threaded-producer-consumer/lists"}