{"id":19357839,"url":"https://github.com/dleedev365/bounded-buffer-problem","last_synced_at":"2025-10-08T23:09:52.646Z","repository":{"id":176565169,"uuid":"117417574","full_name":"dleedev365/Bounded-Buffer-Problem","owner":"dleedev365","description":"[CMPT 300: Operating Systems I] A multi-threaded program that demonstrates \"bound-buffer\" problem using POSIX threads semaphores and mutexes","archived":false,"fork":false,"pushed_at":"2019-11-30T19:53:38.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-06T18:25:03.629Z","etag":null,"topics":["multi-threading","mutexes","posix-threads","semaphore"],"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/dleedev365.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}},"created_at":"2018-01-14T09:28:02.000Z","updated_at":"2024-11-24T21:39:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"b93b7b32-7902-4426-ab1f-f3a080207bea","html_url":"https://github.com/dleedev365/Bounded-Buffer-Problem","commit_stats":null,"previous_names":["dlee0528/bounded-buffer-problem","dleedev365/bounded-buffer-problem"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dleedev365%2FBounded-Buffer-Problem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dleedev365%2FBounded-Buffer-Problem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dleedev365%2FBounded-Buffer-Problem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dleedev365%2FBounded-Buffer-Problem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dleedev365","download_url":"https://codeload.github.com/dleedev365/Bounded-Buffer-Problem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240473955,"owners_count":19807245,"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":["multi-threading","mutexes","posix-threads","semaphore"],"created_at":"2024-11-10T07:09:23.977Z","updated_at":"2025-10-08T23:09:47.627Z","avatar_url":"https://github.com/dleedev365.png","language":"C","readme":"# Purpose\nThe purpose of the project is to design a multi-threaded program with use of semaphore and mutex to avoid deadlocks\n\n# Technologies\n  - POSIX Threads\n\n# Process\n### Step 1: The Language of Choice\nThe project involves use of a processor which sits at the core of a computer. To get to the core,  a programming language must be low-level, which means it must provide little or no abstraction of programming concepts and be very close to writing actual machine instructions. My language of choice was C as it is a low-level language and supports multi-threaded programming with POSIX threads library.\n\n### Step 2: The Understanding of Multi-threading\n\u003cimg src=\"https://slideplayer.com/slide/9128173/27/images/3/A+typical+program+Multi-Thread+Start+Task1+Task2+Task1+Task2+Task3.jpg\" width=\"500\"\u003e\nThe very first step I took before delving into coding was understanding the concept of multi-threading. Essentially, it is a programming model that divides the processor to perform different tasks at the same time. In other words, a program or an operating system process manages its use by more than one user at a time and multiple requests by the same user without having to have multiple copies of the programming running in the computer. Multi-threaded programs can help with improving the performance of a device or even allow adding new features without the need to change or upgrade the processor.\n\n### Step 3: The Implementation\nTo create the program, I first needed to create two groups of threads – worker thread and consumer thread. The worker threads pick a tool from one resource, create a new product with a material randomly generated from other resource and pushes a complete product into anther resource. Then, the consumer threads use a product created by a worker thread. As both types of threads share a common resource such as an array, semaphore and mutex which work as a key to control access to the common resource.\n  - [View Source Code](/main.c)\n\n### Step 4: Final Result \u0026 Evaluation\n\u003cimg src=\"https://github.com/danlee0528/producer-consumer-problem/blob/master/pcp.JPG\" width=\"500\"\u003e\nAs a result, threads continued to produce and consume materials from a common resource without a deadlock (different threads are blocked to access the common resource, think it as a traffic jam at a 4-way intersection).  I learned that multi-threaded programming efficiently uses the computer processor to do more than one tasks at a time. However, the design format of outputs could’ve been built better in a way that it only shows changing materials from resources. The current program displays outputs whenever a thread is executed even if there is no change in material from any resource.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdleedev365%2Fbounded-buffer-problem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdleedev365%2Fbounded-buffer-problem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdleedev365%2Fbounded-buffer-problem/lists"}