Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask Programming Language Expert

problem1. describe why interrupts are not appropriate for implementing synchronization primitive in multiprocessor systems and why spinlocks are not appropriate for single-processor systems yet are often used in multiprocessor systems.

problem2.
Mutual exclusion primitives can be implemented with busy waiting or with blocking. Discuss the applicability and relative merits of each approach.

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

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

1703_programing.jpg
problem5. Please prepare the pseudocode for the following problems:

1. Semaphore operation wait() and signal() implemented using block waiting.

2. 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 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 prepare pseudocode for both customer and chef using semaphore to solve this problem, and synchronize chef and customers.

Programming Problem:  

problem6. 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 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 array should be used for the buffer. You do not need loop for both types of thread. Each thread will exit after only consuming or producing one item (only once).

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

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

You can choose any of the following problems:

problem7. prepare a program to simulate pizza store problem in problem 3.2.

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

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M9870
  • Price:- $55

Guranteed 36 Hours Delivery, In Price:- $55

Have any Question? 


Related Questions in Programming Language

You must do this assignment correctly as described

You must do this assignment correctly as described below.  If you do not follow the directions or break the rules you will receive a 0 score. Simulation of checking tic-tac-toe board for wins by counting X and O in rows, ...

Programming assignment- implement a udp client and udp

PROGRAMMING ASSIGNMENT- Implement a UDP client and UDP server that support simple timeout-based retransmission with AIMD congestion control: -The client should send as many packets as are in its CURWIN (current window) a ...

Consider the following three programswhere i k l are low

Consider the following three programs: where i, k, l are low variables and a, b, c, d, h, n are high variables. Assume db is a database with two columns (shown as array, where the index represents the row), lookup and is ...

Assignmentcase problem1 - online trivia found on pages

Assignment: Case Problem1 - Online Trivia found on pages 794-795 of your textbook. Complete the web pages and upload them to your 000WebHost account. After uploading the files make sure to update your index.html page to ...

1 implement dfs by using prolog2 implement bfs by using

1. Implement DFS by using PROLOG. 2. Implement BFS by using PROLOG. 3.  Solve the problem of Question 3 in Assignment 1 by using your PROLOG programs of DFS and BFS, respectively. Question 3 from Assignment 1 to Solve wi ...

Csis program homeworkwrite a program where the user will

CSIS program homework Write a program where the user will enter a number between 1 and 50 representing a state. The program should display the full name of that state. Assume the states are in alphabetical order, that is ...

Operating systems assignment-1 binary record sorting in

Operating Systems Assignment- 1. Binary Record Sorting in Ascending Order| You will write a simple sorting program. This program should be invoked as follows: shell% ./fastsort -i inputfile -o outputfile The above line m ...

Shell programmingyou have created the directory structure

Shell Programming You have created the directory structure and some base files to be used by the Web server and Web site. For the Web site to be created in a production environment, you need to package your commands in a ...

Integrative programmingassignment- managing a user account

Integrative Programming Assignment- Managing a User Account List Objective: To manage a user list that can be modified and saved to a text file. Inputs: • Input text file consisting of pairs of usernames and passwords, s ...

Your problem is as followswrite a program that will ask the

Your problem is as follows: Write a program that will ask the user to enter 4 quiz scores for 3 students.  You will need to fine the lowest quiz grade and drop it out when you calculate the average. You will need to disp ...

  • 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

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate