Implement a solution via semaphores and threads

Assignment Help C/C++ Programming
Reference no: EM131405222

Implement a solution via semaphores and threads to the n reader 1 writer problem. Fairness always matters. You will accept the number of readers from the command line. In no case will more than 12 readers be used and always at least 1 reader will be used. Each reader must access a shared counter value 250000000 times in the C.S. For convenience code is below that will do this. A reader reads just one time and a writer writes just one time. Each reader needs to print its name when done. The writer will update the value 25000 times and print done. The writer will also set a shared flag, in-cs, when it enters the critical section and reset it just before it leaves the critical section. The reader must, upon entering the critical section, check this flag and write an error message if the flag is set.

You can help us out for testing by using a version of the following code to give the writer a chance to run before all threads (if you want).

k = (int) (numofReaders/2);

for(i = 0; i < k; i++){

pthread_createacreaders[i], icattr[01, reader_thread, (void*) i);

}

/* Create the writer thread */

pthread_create (&writer [0] , tattr [0] , writer_thread , NULL) ; for(i = k ; i < num0f Readers ; i++) {

pthread_create (&readers , &a= [0] , reader_thread, (void*) i) ;

}

void relaxandspendtime()

{

int i;

for(i = 0; i < 250000000; i++) i=i;

}

Reference no: EM131405222

Questions Cloud

Construct and interpret the given confidence intervals : Given the following observations in a simple random sample from a population that is approximately normally distributed, construct and interpret the 95% and 99% confidence intervals for the mean:
Select an information technology or services company : you will select an Information Technology or Services company. Alternately, you may select any other type of company, however, your strategic plan should be limited to the Information Technology or Services department within the company. You may f..
Example of a possible concealment : You are applying for auto insurance with a new company and a new agent. Give an example of a possible concealment, or being silent when you are obligated to speak. Be specific on the question and the answer. Then, give an example of a possible mis..
Evaluate the warehousing facility project : You work for an investment banking firm and have been asked by management of Vestor Corporation. Determine what discount rate (WACC) Vestor should use to evaluate the warehousing facility project.
Implement a solution via semaphores and threads : Implement a solution via semaphores and threads to the n reader 1 writer problem. Fairness always matters. You will accept the number of readers from the command line
Negative aspects of doing a job analysis : Give two positive aspects of doing a job analysis and give two negative aspects of doing a job analysis. Defend your answers.
Requirements for logistics support : Discuss how the requirements for logistics support are significantly influenced by reliability factors.
Construct confidence interval for average number of defects : Given that the population standard deviation is not known, which of these two confidence intervals should be used as the interval estimate for μ?
Advantages to offshoring and outsourcing : What are the advantages to offshoring and outsourcing for the company and consumer? Disadvantages? What are the popular alternatives?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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