Skip to content

Instantly share code, notes, and snippets.

@DhruvParanjape
Created November 8, 2017 05:35
Show Gist options
  • Save DhruvParanjape/c8efb39f400f9016aa88cea7c1f56f03 to your computer and use it in GitHub Desktop.
Save DhruvParanjape/c8efb39f400f9016aa88cea7c1f56f03 to your computer and use it in GitHub Desktop.
Problem statement
Q> a reader exists and a writer exists. the reader can read from 5 buckets. the writer can write to said 5 buckets. How would you solve
this problem in a manner that would allow the reader and writer to access buckets with minimum blocking time and no busy waiting.
Terms:
concurrency : allowing two processes or threads to access shared data simultaneously, issues to handle deadlock and data inconsistency.
deadlock: when a dependancy causes the processes that want to access data to wait for infinite time.
data inconsistency : when two processes access and change data the order of access causes one or both processes to get old data.
Hint :
read about threads, mutexes, and conditional_variables in c++.
Hint 2 : think of buckets as an entity (object) with its own behaviour and state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment