1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LUCKY_DIMON [66]
4 years ago
15

A file is to be shared among different processes, each of which has a unique number. The file can be accessed simultaneously by

several processes, subject to the following constraint: the sum of all unique numbers associated with all the processes currently accessing the file must be less than n. Write a monitor to coordinate access to the file. 3. Exercise 6.29 (10 points) Your solution should use condition variables. Assume a broadcast() operation can be invoked on a condition variable c to resume all processes suspended on c. Hint: Your monitor should contain two functions: one function is called before a process accesses a file and the other function is called after a process accesses a file.
Computers and Technology
1 answer:
UkoKoshka [18]4 years ago
8 0

Answer:

monitor fileSharer

{

       enum {THINKING, WAITING, READING} state[N];

       condition self[N];

       int total;

       void open(int i) {

               state[i] = WAITING;

               if (i + total >= N)

               { self[i].wait(); }  // Leaves monitor

               state[i] = READING;

               total += i;

       }

       void close(int i) {

               state[i] = THINKING;

               total -= i;

               // Can signal one waiting proc whose ID won't break bank.

               for (int x = N - total - 1; x >= 0; x--) {

                       if (state[x] == WAITING) {

                               self[x].signal(); break;

                       }

               }

       }

       initialization.code() {

               for (int i = 0; i < N; i++) {

                       state[i] = THINKING;

               }

               total = 0;

       }

}

You might be interested in
Which aspect of business does accounting measure?
VladimirAG [237]

financial aspect

Accounting measurement is the computation of economic or financial activities in terms of money, hours or other units. An accounting measurement is a unit of some measurable element that is used to compare and evaluate accounting data. Accounting is often measured in terms of money.

6 0
3 years ago
Each object that is created from a class is called a(n) ____________ of the class.
gladu [14]
Instance





-------------------------
7 0
3 years ago
Read 2 more answers
Shortly after its introduction, the unix software was rewritten in the popular c programming language.?
nirvana33 [79]
Of course it was rewritten in the popular C++ Programming Language.

a. True
5 0
3 years ago
Describe the system unit​
mestny [16]

Answer:

A system unit is the part of a computer that houses the primary devices that perform operations and produce results for complex calculations

6 0
3 years ago
Read 2 more answers
Quickly Please!!!
Alex
:)holding the control and pressing home
7 0
3 years ago
Read 2 more answers
Other questions:
  • C. why do manufacturers offer hard drive diagnostic software? what are the potential benefits of doing so to the manufacturer an
    13·2 answers
  • one business rule is that each project has one manager. Identify two (and no more than two) problems with the data structure or
    9·1 answer
  • Web and mobile applications are created for users to only read information. True False
    15·2 answers
  • For this exercise, you are given a phrase. Return the number of time the word “dog” appears in the phrase.
    7·1 answer
  • Give an example of a situation in which shears would be the best choice and one in which scissors would suffice.
    14·1 answer
  • 1) Prompt the user to enter two words and a number, storing each into separate variables. Then, output those three values on a s
    11·1 answer
  • /* Write a method called fractionSum that accepts an integer parameter n and
    5·1 answer
  • Of the following potential benefits, which is LEAST likely to be provided by the upgraded system?
    12·1 answer
  • Write a script that inputs a line of encrypted text and a distance value and outputs plaintext using a Caesar cipher. The script
    11·1 answer
  • Areas on which the development of the computer as a communication technology is based
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!