Question

Question #7 Generally, both P and V operation must be implemented as a critical section. Are there any cases when any of thes

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question #7

Solution:

  • At the process of synchronization, when the critical section problem arise, the functions P() and V() are being used to resolve the problem.
  • They are also known as sleep (P ()) and wake up functions (V()).
  • When more than one process tries to access the critical section to perform their tasks, this problem or the race condition arises.
  • In order to solve this problem, semaphores are being used.
  • They are the integer variable which is used to solve the critical section problem along with the P () and V () functions.

These functions can also be applied for the non-critical section, but one must not do it.

Since, this leads to the wastage of time and takes longer execution of time.

The pseudo-code to demonstrate the working of the P() and V() functions are provided below:

//Program code

P(s);

//Area of Critical section.

//Provide the function V() for the other processes.

V(s);

//Remain code.

The waiting function P():-

P(s):

{

//The loop executes till infinite till the value of semaphore s become 0.

while(s == 0);

     s = s – 1;

}

The waking up function V(s) is defined below:

V(s):

{

s = s + 1;

}

  • Consider there are two processes P1 and P2 along with a semaphore S which is initialized to 1.
  • If the process P1 enters the area of critical section to perform its task, the value of semaphore s gets updated to 0.
  • And at the same time if the second process P2 wants to enter the area, it will be able to get into because the value of the semaphore is 0. So, the process has to wait.
  • After the completion of the task of the process P1, the function V() will be call and update the value of semaphore s to 1.
  • Then the process P2 enters the critical section and update the value of semaphore and this process continues.
  • Therefore, the process goes on and with the help of the semaphore the critical section problem gets resolved.

Question #8

Solution:

The potential problem of multi-programming is as follows:

  • Usage of the resources of the system such as CPU, disk etc, without the proper accountancy.
  • The copying or the problem related to stealing the file of the user.
  • Writing the space of the other program in the memory which belongs to some other user or Operating system.
  • Mixing of the output by the printer as the data is sending at the same time when some file of the user is printing.
Add a comment
Know the answer?
Add Answer to:
Question #7 Generally, both P and V operation must be implemented as a critical section. Are...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 14 Generally, medical providers must obtain informed consent for any treatment. But some special conditions...

    Question 14 Generally, medical providers must obtain informed consent for any treatment. But some special conditions create an exception, so that informed consent is not needed for treatment. Which of the following conditions, on its own and without other special requirements, is sufficient to make such an exception? The patient has previously agreed to other treatments, and generally has done everything their medical providers have told them they needed to do. The treatment is widely accepted as normal, such as...

  • TRUE-FALSE     Basic synchronization principles and multithreading 1. Java user threads can implement both busy-waiting and no-busy-waiting...

    TRUE-FALSE     Basic synchronization principles and multithreading 1. Java user threads can implement both busy-waiting and no-busy-waiting policy. 2. Priority inversion avoids deadlocks. 3. Spinlock mutex can be used as an adaptive mutex. 4. Java RTE can be blocked for Input/Output operation. 5. Interrupted user thread, which executes a method in a monitor, must be rolled back to undo any changes it performed. 6. The synchronization primitive by disabling interrupts can be used by an application program. 7. Bounded-waiting requirement is...

  • Section III of this assignment asks you to explain how finding the answer to your question...

    Section III of this assignment asks you to explain how finding the answer to your question might impact others around you. For instance, who might be most invested in the answer? Using your Asking Questions Chart, complete a short draft of Section III of your Project 3 submission for instructor feedback. This should be a short paragraph of three to four sentences. You may write your submission directly into the “Write Submission” textbox below. This activity is provided as a...

  • Patterson v. McLean Credit Union 491 U.S. 164 (1989) A black female alleged racial discrimination in...

    Patterson v. McLean Credit Union 491 U.S. 164 (1989) A black female alleged racial discrimination in violation of section 1981 in that she was treated differently from white employees and not promoted, on the basis of race. The Court held that section 1981 was not available to address this problem since the case did not involve the making of a contract, but rather its performance. Kennedy, J. *** Patterson, a black female, worked for the McLean Credit Union (MCU) as...

  • QUESTION 1: You are inserting a gene into an MCS found within the LacZ gene. Using...

    QUESTION 1: You are inserting a gene into an MCS found within the LacZ gene. Using blue/white colony selection, why could you assume that white colonies have modified plasmids? a. A blue colony means the LacZ reading-frame was disrupted b. A blue colony means your gene has mutations c. A white colony means the LacZ reading-frame is intact d. A white colony means the LacZ reading-frame was disrupted    QUESTION 2: You are performing a PCR using primers with a sequence perfectly...

  • THOMAS DRAKE'S 2018 TAX SCENARIO Thomas Drake is a small business owner, operating a manufacturing plant...

    THOMAS DRAKE'S 2018 TAX SCENARIO Thomas Drake is a small business owner, operating a manufacturing plant in Chicago, Illinois (as an S-Corp.) He has heard about a new tax break called Section 199A (deduction for qualified business income) wherein he may be entitled to a deduction of up to 20% of his qualified business income. If he can qualify for this deduction, it would result in significant tax savings for his business. Consequently, he contacts your accounting firm to find...

  • Multiple Choice Multiple Choice Section 3.1 The Bag ADT For the bag class in Chapter 3...

    Multiple Choice Multiple Choice Section 3.1 The Bag ADT For the bag class in Chapter 3 (using a fixed array and a typedef statement) what steps were necessary for changing from a bag of integers to a bag of double values? A. Change the array declaration from int data[CAPACITY] to double data[CAPACITY] and recompile. B. Change the int to double in the typedef statement and recompile. C. Round each double value to an integer before putting it in the bag....

  • operating system engineering , please read the question and solve on the given skeleton code ....

    operating system engineering , please read the question and solve on the given skeleton code . Write a multi-threaded program with Semaphores as counters and pthread_mutex_t mutex to solve the producer-consumer problem: A bounded buffer is simply a global integer array of size N (2) which can be accessed by multiple threads. • Create two types of threads - Producer (2) and Consumer (2). Producers will write to the buffer, and the consumers will read the buffer. In this scenario,...

  • In Problem Set 7 you designed and implemented a Message class. This time, let's design and...

    In Problem Set 7 you designed and implemented a Message class. This time, let's design and implement a Mailbox class in a file named Mailbox java. Do the following with this class • You may use the Message class from PS 7. You will have to add new features to the Message class from PS 7 as you work through this problem. You are welcome to start with my sample solution if you wish • Suppose there are multiple mail...

  • Give an specific example and describe the operation of a perpetual motion machine. Will the machine...

    Give an specific example and describe the operation of a perpetual motion machine. Will the machine work? Why or why not? Reply to the posts of at least two other students as well as comments on your own post. 13 Use the Everyday Phenomenon Box 11.2 on page 230 of the textbook as an example. Do not post this as your example, however. Everyday Phenomenon Box 11.2 Water turbine O n A Productive Pond The Situation. A local farmer consulted...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT