How many worker threads do you need

Assignment Help Operating System
Reference no: EM131092565

Operating Systems Assignment-

Question 1 - Using pthreads, add multi-threading to the server in the sample solution for assignment 1 question 2. The server will use a thread pool (as discussed in class) to support the handling of multiple concurrent requests. In other words, you will have a thread (main) that's doing a blocking read on the FIFO and will hand off each message to a worker thread for processing.

Note that to terminate all of the worker threads, the main thread will need to provide the threads with data (such as a -1) to indicate that it is time for the threads to finish. Further, the main thread must ensure that all worker threads are done before it terminates the server.

Be careful with what needs to be protected! All shared resources are subject to access by multiple threads. This includes shared (file scope) variables and any file handles (you never know which threads may access the same file). But, to make things a little simpler, remove support for the HUP signal. That way we can treat the template as read only and free from any protection issues.
The number of worker threads can have a noticeable effect on throughput. Experiment with having thread counts that are less than and greater than the number of clients. How many worker threads do you need? Do you need more than the maximum number of clients? The same number? Will less do? Why? Include your answer (in the form of a paragraph) in your assignment's readme file.

Finally, note that all you need to hand in is server.c. The marker will be using the rest of the assignment 1 sample solution to test your solution.

Question 2 - Using pthreads, implement a bounded buffer. Use condition variables for full and empty and a lock on the entire buffer (and our condition variables). Each producer will take the string "Now is the time for all good people to come to the aid of their country" and write it to the shared buffer, one character at a time. Your consumer will read a character from the buffer and write it to standard output (one at a time). Be careful: the consumer must finish when all of the producers are done. How can the consumer know when a producer is finished?

To test a variety of configurations, vary the buffer size between 2 and 128, incrementing by powers of 2. For each of these sizes, vary the number of producer threads between 2 and 128, incrementing by powers of 2. Note that you'll need to wait for all threads to finish before starting the next round. In your readme, include a paragraph discussing how the output changes as you vary the buffer size and number of producers. Run your program a number of times. How does the output change?

Attachment:- Assignment.zip

Reference no: EM131092565

Questions Cloud

Discuss errors in perception and selection : Write a 2000 words on Untrained interviewers can make mistakes that are very costly to the organization.” Discuss errors in perception and selection that interviewers can make and how to avoid them.
Detail the steps in a secret ballot representation election : 1. Identify and discuss in detail the steps in a secret ballot representation election. Who initiates this process? Explain.
Calculate the maximum resultant stress in the beam : Calculate the maximum resultant stress in the beam and plot the stress distribution diagram for this section
Develop one application using jtabbedpanes and jframes : Develop one application using JTabbedPanes and JFrames and another application that connects to a MySQL database.
How many worker threads do you need : COMP 3430 Operating Systems Assignment. How many worker threads do you need? Do you need more than the maximum number of clients? The same number? Will less do? Why
What conditions is the equilibrium stable or not stable : The contact between cube and sphere is perfectly rough. Under what conditions is the equilibrium stable or not stable?
Leather goods manufacturing unit : The success and final outcome of this Final Report required a lot of guidance and assistance from many people and me extremely fortunate to have got this all along the completion of our project work.
Enter omit in the answer area : The Terms will be designated as "Short Answer" questions. There are twelve of these from which you will select and answer ten. You will enter "OMIT" in the answer area of the two you do not wish me to grade. If you make no designation, I will grad..
How climate change impact on global businesse : Write an article:-Give critics on how climate change impact on global businesses. Introduction(a)Damage to property and infrastructure(b)Reduction in productivity

Reviews

Write a Review

Operating System Questions & Answers

  Explain trade-off between memory use and cpu overhead

Remembering that there's a trade-off between memory use. Then give an example where doing so will cause throughput to suffer.

  How the offices within a wan are connected

The University of Hawaii campus is spanned over 2 miles. It has 7 colleges and each college building is separated from each other by at least 1000 feet. Each building has 4 floors. The University also has it's centers at London and Australia. You ..

  Difference from a firewall to border security

Discuss why is it important for a firm to have firewalls and border security in place? I know that a firewall is to stop intruders from entering your network but when read on it seems border security is very similar.

  Will the idea work if three or more processes use semaphore

In this way, programs that feel it is immoral to block can first inspect the semaphore to see if it is safe to do a down. Will this idea work if three or more processes use the semaphore? If two processes use the semaphore?

  Discuss the different roles ofweb services and web portals.

Which do you think is the more useful in the current Web environment?

  Question about processing packets

A CPU in a router can procedure two million packets/sec. The load offered to it is 1.5 million packets per sec. If the route from source to destination contains ten routers

  How will you specify the location of the files

What options will you give the ln commands? How will you specify the location of the files, since you are not in the same directory?

  What do you have to do to protect the database

One of the application developers was fired. She had access to several of the tables, but did not have DBA-level privileges. That is, she could work with tables but could not create or delete any tables. What do you have to do to protect the datab..

  What is a source code control system

List and briefly describe the three basic approaches to program development order. What are the advantages and disadvantages of each?

  Mobile email and text messaging in the work place

What is a firm's fully qualified domain name and what is the significance of the. Discuss the benefits and drawbacks of mobile email and text messaging in the work place.

  Describe how to prevent race condition from occurring

Function and wife calls deposit (). Explain how a race condition is possible and what might be done to prevent race condition from occurring.

  Processor bound programs

Suppose if run through itself, an I/O bound program spends more time waiting for I/O than using the processor and vice versa for the processor-bound.

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