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 will be to have a single primitive, waituntil, which had an arbitrary boolean predicate as the parameter. Therefore, one can say, such as waituntil x < 0 or y+z < n. The signal primitive will no longer be required. This scheme is clearly more general, but it is not used. Why not? Hint, think about the implementation.

2. Assume there are 2 threads T1, T2. Please describe if the following solution provides the correct synchronization for critical section which satisfies three conditions:  mutual exclusion, bounded wait and make progress.
T1                                                                          T2
Shared: int t1Inside = 0, t2Inside = 0;                       while (1) {
while (1) {                                                             while (t1Inside);
  while (t2Inside);                                                     t2Inside = 2;
  t1Inside = 1;                                                         // critical section
   // critical section                                                         t2Inside = 0;
   t1Inside = 0;                                                           }

3. Please prepare the pseudo code for the following problems:

1. Consider a pizza store which has 10 seats. A customer comes to buy pizza. If there is any unsold pizza left in the kitchen, he could get it immediately. If not, (s)he  needs to 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 would left the store. The chef in the kitchen just keeps making pizza. Though, (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 prepare pseudo code for both customer and chef using semaphore to solve this problem, and synchronize chef and customers.

Programming Problem: 

4. prepare 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 could 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 array must be used for the buffer. You don’t need loop for both types of thread. Each thread would exit after only consuming or producing one item (only once).

• Suppose total number of worker thread is 20, and buffer size is 10. Your program must randomly generate the number of producers and consumers. Their relationship must 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 must be arbitrary. Such as, you will not generate all producers(consumers) and then all consumers (producers). 

• Synchronize the producer and consumer.

• You could select any type of language (e.g. C/C++/Java) to execute 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 select to use it.

• Please submit all source code and a simple readme file on how to compile your code and the sample output. Please zip all files into a single zip file and submit through blackboard.

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M91317

Have any Question?


Related Questions in Operating System

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 ...

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 ...

Question students working at individual pcs in a computer

Question : Students working at individual PC's in a computer laboratory send their files to be printed by a server that spools the files on its hard disk. Under what conditions may a deadlock occur if the disk space for ...

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 ...

Catalog course descriptionin this course students carry out

Catalog Course Description In this course students carry out independent research in a significant technical area of information, network, and computer security. The student is to investigate a technical area, research i ...

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 ...

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 ...

Show all stepssuppose that the following processes arrive

Show all steps Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. in answering the questions, use non-preemptive scheduling and base all dec ...

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. Consider a computer embedded in the control of a manned spacecraft. Would it require an ...

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 ...

  • 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