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

  Inventory management systemsyour sister owns a small

inventory management systemsyour sister owns a small clothing store. during a conversation at a family dinner she

  You have poisson arrivals into your system

You have Poisson arrivals into your system with ?= 5 packets/second. The slot length is 1 second. Your current estimate for n^ is 20 (for the k-th time slot iteration).

  What are mobile oss you have personally used

What are mobile OSs you have personally used? Describe the advantages and disadvantages of their effects. Share a resource you have found regarding mobile OSs

  How many 512 byte blocks are required to store a 1.6mb file

Suppose that the keyboard device stored keystrokes in a buffer until it was full then sent the entire buffer for processing. What would be some adverse consequences?

  Build an os catalogue

Build an OS catalogue where you will list the categories of OS by each criterion, and will list at least two examples of actual OSs in each category. Provide the reference for same.

  Implement a basic shell that restricts the runtime of

implement a basic shell that restricts the runtime of processes executed from within it. your shell will read input

  How many page faults are generated array-initialization loop

Illustrate how many page faults are generated by following array-initialization loops, using LRU replacement, and assuming page frame 1 has process in it, and the other two are initially empty?

  Question about operating system interfaces

The Internet can be used for several reasons, including research and education, and information can be  achieved  from many types of Web sites.

  A system uses a page size

A system uses a page size of the 4 Kbytes and a program size of 46 kbytes is allocated memory. what is the fragmentation?

  Schedule for shortest-job-first and roundrobin algorithms

Process 2 has total of 20 units of work to perform. This process arrives just behind P1. Illustrate the resulting schedule for shortest-job-first (preemptive) and roundrobin algorithms.

  Television clips in a powerpoint presentation

Computers and television would work is when you tape television demonstrate that can be used to give flavor to PowerPoint Presentations.

  Explain how a race condition is possible

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

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