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
Cost behavior is considered linear whenever Blank______. Multiple choice question. a straight line approximates the difference b
vitfil [10]

Cost behavior is considered linear whenever a straight line approximates the relationship between cost and activity.

<h3>What is the cost behavior?</h3>

Cost behavior is regarded as the measure of how alterations inside a specific business process can influence costs.

Note that as a result of these changes, Cost behavior is seen as linear whenever a straight line approximates the relationship between cost and activity.

Learn more about Cost behavior from

brainly.com/question/26249967

#SPJ1

4 0
2 years ago
To rearrange the data on your hard disk so your computer can run more efficiently, you use ____.
Ratling [72]
A disk optimization program, but they're probably looking for defragmenting program.
5 0
3 years ago
(Exhibit: Production Possibilities Curves 2) Assume that a nation is operating on production possibilities curve CD. Economic gr
Alex

Answer:

b. shift from curve CD to curve EF.

Required Details of the Question:

The image of the curve required to answer the question has been attached.

Explanation:

A production possibilities curve shows various combinations of the amounts of two goods( in this case capital and consumer goods) which can be produced within the given resources and a graphical representation showing all the possible options of output for the two products that can be produced using all factors of production.

Now the growth of an economy is best illustrated in the image by the shift from curve CD to curve EF, this means that as the nation's production capacity increases, its production possibilities curve shift outward showing an increase in production of both goods.

3 0
4 years ago
Write a program that rolls two dice until the user gets snake eyes. You should use a loop and a half to do this. Each round you
marishachu [46]

import random

num_rolls = 0

while True:

   r1 = random.randint(1, 6)

   r2 = random.randint(1, 6)

   print("Rolled: " + str(r1) + "," + str(r2))

   num_rolls += 1

   if r1 == r2 == 1:

       break

print("It took you "+str(num_rolls)+" rolls")

I added the working code. You don't appear to be adding to num_rolls at all. I wrote my code in python 3.8. I hope this helps.

4 0
4 years ago
How does a phone know where you are?
natali 33 [55]

Answer:

GPS

Explanation:

5 0
4 years ago
Read 2 more answers
Other questions:
  • Why we can not see objects around us in the dark​
    6·1 answer
  • What is TCP/IP?
    13·1 answer
  • 19. Squares. Write a program class named SquareDisplay that asks the user for a positive integer no greater than 15. The program
    11·1 answer
  • Assume that an array named salarySteps whose elements are of type int and that has exactly five elements has already been declar
    11·1 answer
  • Which sentence is an example of constructive statement
    14·1 answer
  • Which WAN technology is designed to work with a variety of commonly used layer-2 protocols and is sometimes called a layer-2.5 t
    15·1 answer
  • We write programs as a sequence of operation. they flow through the computer as?
    11·1 answer
  • . Aisha’s supervisor asks her to create an aspect of a program that will hold data and make it easy to access. What does Aisha n
    5·1 answer
  • To remove a specified number of characters from anywhere within a string, you should use the ____ method.
    15·1 answer
  • While conducting routine maintenance, you discover a network server that needs to
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!