Concurrency – Implementing Readers and Writers Algorithm in OpenMP

concurrencymultithreading

After reading about OpenMP and not finding functions to support semaphores, I did an internet search for OpenMP and the readers and writers problem, but found no suitable matches.

Is there a general method for replacing counting semaphores in OpenMP with something that it supports? Or is there just a gap in the environment where it does not permit things that are asymmetrical like the third readers and writers problem shown on the following page?

http://en.wikipedia.org/wiki/Readers-writers_problem#The_third_readers-writers_problem

Best Answer

I found your question while looking for an answer myself. That being said, I found the following link: http://bisqwit.iki.fi/story/howto/openmp/

They have a section explaining how to use locks which seems very similar to mutex/semaphore.

Another tool for doing similar things is the critical sections directive even though I don't think it can be used for the reader writer problem because I think it will cause race condition.

Hope this was helpfull :D