How to understand the first and second readers-writers problems? Posted: 31 Oct 2020 09:06 AM PDT Computer Systems: a Programmer's Perspective says The readers-writers problem has several variations, each based on the priori- ties of readers and writers. The first readers-writers problem, which favors readers, requires that no reader be kept waiting unless a writer has already been granted permission to use the object. In other words, no reader should wait simply because a writer is waiting. The second readers-writers problem, which favors writers, requires that once a writer is ready to write, it performs its write as soon as possible. Unlike the first problem, a reader that arrives after a writer must wait, even if the writer is also waiting. https://en.wikipedia.org/wiki/Readers%E2%80%93writers_problem says the first problem: no reader shall be kept waiting if the share is currently opened for reading. It prefers readers over writers, may starve writers in the queue the second problem: no writer, once waiting i.e. added to the queue, shall be kept waiting longer than necessary. It prefers writers over readers, may starve readers. Is it correct that: Regardless of which type of reader-writer problem, if there is reader(s) in critical region, a waiting reader can always enter the critical region, and a waiting writer can't, regardless of which one arrives earlier? Regardless of which type of reader-writer problem, if a writer is in critical region, no waiting reader or writer can enter the critical region? Is the first problem defined as: If no reader (regardless of whether a writer) is in critical region, a waiting reader shall have priority over a waiting writer, independently of which arrived earlier? Is the second problem defined as: If no reader (regardless of whether a writer) is in critical region, a waiting rwritr shall have priority over a waiting reader, independently of which arrived earlier? Thanks! submitted by /u/timlee126 [link] [comments] |
Which CS concepts that you learned as part of your degree have (not) turned out to be useful for programming? Posted: 31 Oct 2020 11:12 AM PDT |
No comments:
Post a Comment