1 synchronization within monitors uses condition variables

Assignment Help Operating System
Reference no: EM13346904

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.

Reference no: EM13346904

Questions Cloud

Write an essay on the youngest billionairedevelop an : write an essay on the youngest billionaire.develop an appropriate thesis to argue in essay. no formal research is
Part-11 how is job costing in service organizations : part-11. how is job costing in service organizations different from job costing in manufacturing environments?2. if
Question 1a in a competitive market place pure competition : question 1a in a competitive market place pure competition is it possible to continually sell your product at a price
Question 1a in a competitive market place pure competition : question 1a in a competitive market place pure competition is it possible to continually sell your product at a price
1 synchronization within monitors uses condition variables : 1. synchronization within monitors uses condition variables and two special operation wait and signal. a more general
Exercise 1 implementation of classes chart and barchart : exercise 1 implementation of classes chart and barchart. class barchart chould display a simple textual representation
1 calculate the dc voltage applied to the 10 load resistor : 1. calculate the dc voltage applied to the 10 ? load resistor in the circuit shown below assume the diode threshold
1 describe why interrupts are not appropriate for : 1. describe why interrupts are not appropriate for implementing synchronization primitive in multiprocessor systems and
Write a paper on interest groups and how they seek to : write a paper on interest groups and how they seek to influence the making of public policy. in your paper address the

Reviews

Write a Review

Operating System Questions & Answers

  Direct mapped cache- word, block, tag

Think about a byte addressable computer with twenty-four bit addresses, a cache capable of storing a total of 64KB of data, and blocks of 32 bytes.

  Question about Ethernet capture effect

The teacher went over the following trouble in class. However, I do not understand how he describes the work. He skips too many steps and jumps around.

  Supporting multiple incoming requests via threads

The email database server is created to accept multiple incoming requests via a socket in order to locate a specific message and return it to the customer email browser

  Identity top level objects of the microwave

Construct a table with the following four column headings, Top Level Objects, Communicates With, Incoming Messages, and Outgoing Messages and Identity top level objects of the microwave.

  Describe the processes involved in the management

Identify and describe the processes involved in the management of the services, disk quotas and security of both Windows and UNIX operating systems.

  Find the common characteristics of the dss system

Assume you are a chief information officer who is hired through a company that generates electricity with three coal burning electric power plants located in various parts of the nation.

  Explanation of osi model

Determine what if someone designs a communication methodology that does not comply with OSI but is compatible with the application layer and the physical layer.

  Relational database architecture from a network

Determine what would make a corporation or organization migrate to a relational database architecture from a network or hierarchical architecture?

  Comparison of 3 mobile operating systems in user interface

comparison of three mobile operating systems in terms of user interface, functionality, application support and platform presence.

  Explanation of it networks

While there are difficult security concerns in any isolated computing environment, addition of a network in geographically distributed facilities.

  Creating an appropriate user interface

Assume you have just started a new semester and you have become friends with one of your classmates, Tomislav. Tomislav tells you he has just moved to the US from Europe

  Question about internet use policies

Internet use policies are often utilized in corporations. Conduct independent research on these and construct an Internet use policy for your company or an organization of your choice.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd