Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Three Approaches to Solving the Readers-Writers Problem: A Comparative Study, Study Guides, Projects, Research of Computer Science

A research project proposing to simulate and analyze the efficiency of three different approaches to the readers-writers problem (rwp) in concurrent systems. The rwp is a classic problem in computer science where processes attempt to access shared memory for reading or writing. The concurrent read, exclusive write (crew) model and compares it to the reader's preference, writer's preference, and no preference models. The project aims to determine under which scenarios certain solutions cause processes to starve and to develop a new approach to prevent starvation.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 08/17/2009

koofers-user-5nl
koofers-user-5nl 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Three Approaches to Read-Write Concurrency Problems
Kyle Robinson
Summary
In concurrent systems, the rules for organizing access of separate processes to shared
memory can be complicated because there are many different scenarios. In an earlier project,
fellow classmates and I simulated a solution to the Dining Philosophers problem which is
made up of processes in a circle which access two separate items, each of which is shared with
only their neighbor, one to their left, and one to their right. The solution was drastically simple
compared to real-world concurrency issues because of the predefined low number of shared
resources and neighbors. Because of this, our solution does not translate well to other types of
concurrency problems.
For my next project, I propose to simulate a larger concurrency problem, the Readers-
Writers Problem (RWP). In a RWP, processes attempt to access shared pieces of memory for
one of two reasons, to read or to write. It would be easy enough to implement a simple queue
on each piece of memory and allow access to only one process at a time using a mutex or
semaphore. However, for example, if two processes both wish to access memory for reading
purposes, then there is no reason to wait for one to finish before the other can begin because
reading processes do not interfere with each other. I will implement and test a Concurrent
Read, Exclusive Write (CREW) model in which a processes being read can be read by multiple
processes at the same time1 (See figure 1). This is different from the Exclusive Read, Exclusive
Write (EREW) model in which at most one process can be accessing a piece of memory at any
given time2.
Figure 1: CREW model for memory access. Reading processes can be concurrent with other reading
processes, but writing processes must be exclusive.
1 NIST. Concurrent Read, Exclusive Write. Retrieved from
http://www.itl.nist.gov/div897/sqg/dads/HTML/concurrentReadExcluWrt.html
2 NIST. Exclusive Read, Exclusive Write. Retrieved from
http://www.itl.nist.gov/div897/sqg/dads/HTML/exclusiveReadExcluWrt.html
pf2

Partial preview of the text

Download Three Approaches to Solving the Readers-Writers Problem: A Comparative Study and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

Three Approaches to Read-Write Concurrency Problems

Kyle Robinson

Summary

In concurrent systems, the rules for organizing access of separate processes to shared memory can be complicated because there are many different scenarios. In an earlier project, fellow classmates and I simulated a solution to the Dining Philosopher’s problem which is made up of processes in a circle which access two separate items, each of which is shared with only their neighbor, one to their left, and one to their right. The solution was drastically simple compared to real-world concurrency issues because of the predefined low number of shared resources and neighbors. Because of this, our solution does not translate well to other types of concurrency problems.

For my next project, I propose to simulate a larger concurrency problem, the Readers- Writers Problem (RWP). In a RWP, processes attempt to access shared pieces of memory for one of two reasons, to read or to write. It would be easy enough to implement a simple queue on each piece of memory and allow access to only one process at a time using a mutex or semaphore. However, for example, if two processes both wish to access memory for reading purposes, then there is no reason to wait for one to finish before the other can begin because reading processes do not interfere with each other. I will implement and test a Concurrent Read, Exclusive Write (CREW) model in which a processes being read can be read by multiple processes at the same time^1 (See figure 1). This is different from the Exclusive Read, Exclusive Write (EREW) model in which at most one process can be accessing a piece of memory at any given time^2.

Figure 1: CREW model for memory access. Reading processes can be concurrent with other reading processes, but writing processes must be exclusive.

(^1) NIST. Concurrent Read, Exclusive Write. Retrieved from http://www.itl.nist.gov/div897/sqg/dads/HTML/concurrentReadExcluWrt.html (^2) NIST. Exclusive Read, Exclusive Write. Retrieved from

http://www.itl.nist.gov/div897/sqg/dads/HTML/exclusiveReadExcluWrt.html

Using MPI to simulate and finely control CREW-modeled memory and processes that request to access them, I will analyze efficiency for three separate RWP solution approaches. I am most interested in determining under which scenarios that certain solutions cause processes to starve and how this situation can be avoided. It is my goal that this analysis will lead to a fourth approach to RWP which can allow memory to adapt to requests and change its access rules to be the most efficient and prevent starvation.

Details

According to Wikipedia, there are three different forms of RWP^3 , by which it means that there are three different solution approaches.

  1. Reader’s Preference (also known as First RWP)
  2. Writer’s Preference (also known as Second RWP)
  3. No Preference (also known as Third RWP) In a reader’s preference model, a piece of memory currently being accessed by a process for reading will allow any other readers to access the memory so as to maximize concurrency. A writing process will gain access only when there are no reading processes in queue. In this model, it is possible for a writing process to starve if reading processes enter the queue faster than they complete their operation. In a writer’s preference model, a writer will never starve because writers are given priority when they enter the queue. This has the exact opposite problem of the reader’s preference model. A reader might starve if writers show up in queue faster than they complete their operation.

A no-preference model is a balance between the two above models. By enqueuing all processes despite access type, it is guaranteed that no process starves. This model still allows for multiple reads if reading processes are given access at the same time or if a reading process requests access when there are no writing processes in the queue. While guaranteeing that no process starves, this model might not be the most efficient of the three models. My project will attempt to determine if this is so.

These models will be simulated using an MPI model in which separate processes will be used to simulate reading and writing processes as well as the queue management for the shared memory. There will also be a user interface process that will be used to interact with the user running the test, advance units of time in the other processes using clock tick messages, and compile/print reports sent from the other processes. The reports will contain information on the length of time processes waited to gain access to shared memory, the length of time that memory was accessed for reading and writing, and measurements for efficiency of the solution. This information will lead to a better understanding of how different solutions handle in different scenarios which will hopefully lead to a new approach/solution to RWP.

(^3) Wikipedia. Readers-writers problem. Retrieved from

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