Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

1. Synchronization within monitors uses condition variables and two special operation wait and signal. A more general form of synchronization would be to have a single primitive, waituntil, that had an arbitrary boolean predicate as a parameter. Thus, one could say, for example waituntil x < 0 or y+z < nThe signal primitive would no longer be needed. This scheme is clearly more general, but it is not used. Why not? Hint, think about the implementation.

2. Suppose there are 2 threads T1, T2. Please describe if the following solution provides the correct synchronization for critical section that satisfies three conditions:  mutual exclusion, bounded wait and make progress.

T1

T2

Shared: int t1Inside = 0, t2Inside = 0;

while (1) {

  while (t2Inside);

  t1Inside = 1;

  // critical section

  t1Inside = 0;

}

while (1) {

  while (t1Inside);

  t2Inside = 2;

  // critical section

  t2Inside = 0;

}

3. Please write the pseudocode for the following problems:

Consider a pizza store which has 10 seats. A customer come to buy pizza. If there is any unsold pizza left in the kitchen, he can get it immediately. If not, (s)he  need wait for chef to make one. After the customer gets the pizza, (s)he will grab a seat and start eating. If there is no seat, (s)he needs to wait. When (s)he finishes eating, (s)h will left the store. The chef in the kitchen just keeps making pizza. However, (s)he stops if there are 5 unsold pizza left in the kitchen. If a customer come to buy one, (s)he resumes the work to make new pizza. Please write pseudocode for both customer and chef using semaphore to solve this problem, and synchronize chef and customers.

4. Write a multi-threaded program to solve producer and consumer problem.

- There are two types of worker thread: producer and consumer. A producer thread  randomly generate an integer between 0-100 (You can use random()/srandom()  or drand48()/srand48() to generate random number in C), and put it into the buffer. A consumer thread simple take the first integer from the buffer. A circular arrayshould be used for the buffer. You do not need loop for both types of thread. 

-  Assume total number of worker thread is 20, and buffer size is 10. Your program should randomly generate the number of producers and consumers. Their relationship should be : num_producers + num_consumers = num_threads, num_producer - num_consumer <= buffer_size, num_consumer <= num_producer, so that no thread will be blocked forever.  The order between consumer and producer threads should be arbitrary. For example, you shall not generate all producers(consumers) and then all consumers (producers).  (5 points)

-  Synchronize the producer and consumer. 

-  You can choose any type of language (e.g. C/C++/Java) to implement this program. Your output will look like the following: 

Number of producer: 12 Number of consumer: 8
Thread 0 produce 63 in buffer 0, current number of items is 1
Thread 1 consume item 63 in buffer 0, current number of items is 0
Thread 3 produce 45 in buffer 1, current number of items is 1
Thread 5 produce 88 in buffer 2, current number of items is 2
Thread 4 consume item 45 in buffer 1, current number of items is 0

.......

.....

......

There are still 4 items left in the buffer: 96,26,52,81

- Please check blackboard for more reference about pthread library if you choose to use it.

You can choose any of the following questions:

5. Write a program to simulate pizza store problem in problem 3.

Describe how spinlock is implemented in Linux kernel and how/where it is used? Please give some concrete examples, e.g. list the data structure/functions related to spinlock implementation, describe the code of some spinlock functions, describe how to use these functions for synchronization, list the functions that use.

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M9716521
  • Price:- $25

Priced at Now at $25, Verified Solution

Have any Question?


Related Questions in Operating System

Question 1answer the following questions 10 marks a

Question 1 Answer the following questions: 10 marks a. Consider the following page reference string: 3, 1, 4, 1, 2, 3, 5, 3, 2, 1, 2,5, 4, 3, 5, 2, 4,2, 5,3 Using the above page reference string display the contents of t ...

Question topic computerized operating systems os are almost

Question: Topic: Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use our phone or tablet. Find articles that describes the diff ...

Research types of operating systems that are currently

Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Explain why you think the choice you made ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

Question what do you see as the major differences between

Question : What do you see as the major differences between UNIX/Linux and other operating systems, such as Windows and Mac OS X? The response must be typed, single spaced, must be in times new roman font (size 12) and m ...

Assignment -building a multi-threaded web server using c

Assignment - Building a multi-threaded web server using C and p threads, following the model from the lecture. Your program will have one thread acting as a dispatcher thread, listening fornetwork connections with reques ...

Foundation of information technologyresearch types of

Foundation of Information Technology Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Expl ...

Question state the required answer precisely and then

Question : State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. What is the purpose of the command interpreter? Why is it usually separate fr ...

Question you are a security administrator responsible for

Question: You are a security administrator responsible for providing secure configuration requirements for new laptop deployments. After reading Module 2 of Certified Secure Computer User v2exercises, apply the configura ...

Question description of lasa in this assignment you will

Question: Description of LASA: In this assignment, you will select a real-world operating system (can be for a PC, server, tablet, handheld, or embedded device). You will introduce the operating system and its components ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As