Ask Question, Ask an Expert

+61-413 786 465

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

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

  • 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