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
Margarita [4]
3 years ago
13

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

everal processes, subject to the following constraint: the sum of all uniquenumbers associated with all the processes currently accessing the file must be less than n. Write amonitor to coordinate access to the file.Your solution should use condition variables. Assume abroadcast()operation can be invoked on acondition variable c to resume all processes suspended on c. Hint: Your monitor should contain twofunctions: one function is called before a process accesses a file and the other function is called after aprocess accesses a file.
Computers and Technology
1 answer:
Finger [1]3 years ago
5 0

Answer:

int sumid=0;    /* Shared var that contains the sum of the process ids currently accessing the file */

int waiting=0;   /* Number of process waiting on the semaphore OkToAccess */

semaphore mutex=1;   /* Our good old Semaphore variable ;) */

semaphore OKToAccess=0;    /* The synchronization semaphore */

get_access(int id)

{

    sem_wait(mutex);

    while(sumid+id > n) {

        waiting++;

        sem_signal(mutex);

        sem_wait(OKToAccess);

        sem_wait(mutex);

    }

    sumid += id;

    sem_signal(mutex);

}

release_access(int id)

{

    int i;

    sem_wait(mutex);

    sumid -= id;

    for (i=0; i < waiting;++i) {

        sem_signal(OKToAccess);

    }

    waiting = 0;

    sem_signal(mutex);

}

main()

{

    get_access(id);

    do_stuff();

    release_access(id);

}

Some points to note about the solution:

release_access wakes up all waiting processes. It is NOT ok to wake up the first waiting process in this problem --- that process may have too large a value of id. Also, more than one process may be eligible to go in (if those processes have small ids) when one process releases access.

woken up processes try to see if they can get in. If not, they go back to sleep.

waiting is set to 0 in release_access after the for loop. That avoids unnecessary signals from subsequent release_accesses. Those signals would not make the solution wrong, just less efficient as processes will be woken up unnecessarily.

You might be interested in
What kinds of circumstances would lead you to writing a function versus using a loop? please explain in simple terms
GREYUIT [131]

Answer:

1. You want to use parameters

2. You don't want your program to run multiple times

3. You want to call that snippet of code throughout your program

hope this helped :D

5 0
3 years ago
Which term refers to actions that you would typically perform on a computer to revive it if it functions in an unexpected manner
andriy [413]
There are many answers to this question. The first step is normally a reboot, second, I would check witch task or service is taking up all the CPU cycles and check the system and error logs. The list goes on... I'm not sure how detailed you want to get.
5 0
4 years ago
Read 2 more answers
Pick a web browser (a leading one or perhaps a lesser-known one that you use) and examine the Privacy and Security features and
Veseljchak [2.6K]

Solution :

<u>Chrome web browser</u>

The Chrome web browser uses a range of privacy and security settings for its customers. They include several security indicators as well as malware protection. Chrome uses the sandboxing technology, which prevents the harmful viruses and Trojans from reaching the computers.

Chrome provides a safe browsing by giving us an alert whenever we try to browse some harmful web sites.  It also warns you if we use a username and password combination which has been compromised in any data leak.

Chrome also serves to protect the individuals :

It provides a features of Ad blocking.

When we want to browse safely without being recognized or without storing any credentials, Chrome provides an Incognito mode.

Many businesses can be done on the internet using Chrome platform that is safe and authenticate to gather and collect data and information.

3 0
3 years ago
What was the name of the first computer (machine) language?
Angelina_Jolie [31]

In 1957, the first of the major languages appeared in the form of FORTRAN. Its name stands for FORmula TRANslating system. The language was designed at IBM for scientific computing. The components were very simple, and provided the programmer with low-level access to the computers innards.


8 0
3 years ago
Read 2 more answers
An engineer created three VSANs on the Cisco MDS switch. VSAN 100 is allocated to the marketing department, VSAN 110 is allocate
SCORPION-xisa [38]

Answer:

Option B i.e., mdsswitch# show Vsan membership is the correct option.

Explanation:

The following commands is used by the engineer because it displays the membership of the VSAN( virtual storage area network).

switch# command is used to enter the configuration mode. So, the engineer using the following commands to verify that the interfaces for the research department.

7 0
3 years ago
Other questions:
  • This type of connection uses radio waves to connect devices on a network.
    9·2 answers
  • The number of credits awarded for the CLEP exam is determined by__<br> Help pls!
    15·1 answer
  • The HR department of a company wants to send out an email informing its employees about an upcoming social event. Which email ap
    11·2 answers
  • The term ________ refers to the use of a single unifying device that handles media, Internet, entertainment, and telephone needs
    7·1 answer
  • What's is the contribution of technology to the country?
    15·1 answer
  • True or false that computers that are joined together are able to share hardware and software, but not data
    11·1 answer
  • How to automatically ccleaner smartphone?
    10·1 answer
  • Teniendo en cuenta la realidad mundial acerca de la pandemia, ¿cómo crees que impacta
    9·1 answer
  • Computing devices translate digital to analog information in order to process the information
    12·1 answer
  • Ok so I’m using a word document and towards the bottom of the page it stops me from moving my text box any further down even tho
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!