ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > ZSTU class(2019-2020-1) > student directories > 2017329621154-郑莉莉 >
homework-4 Version 0
👤 Author: by 1033415679qqcom 2019-09-28 07:14:25
The problem of Readers and Writers:

  1. A data file or record can be shared by multiple processes, some of which require reading, some of which require writing or modification.

  2. It is called Reader process if the data file is just to be read, while it is called Writer process if it is to be modified.

  3. Allow multiple Reader processes to share the same object at the same time, and do not allow one writer process and multiple Reader or writer processes to access the Shared object at the same time.


Solution:

Set two variables as ReaderCount and WriterCount to save the number of processes of reading and writing. If the ReaderCount is not equal to zero, then the Writer process is forbidden. And if another Reader process add, then ReaderCount++. If WriterCount is not equal to zero, then the Reader process is forbidden. And pay attention that there should not be more than one Writer process.

Please login to reply. Login

Reversion History

Loading...
No reversions found.