Assignment - Data Structure and Algorithms Question

Assignment Help Data Structure & Algorithms
Reference no: EM132466990

Assignment - Data Structure & Algorithms Question

Some researchers are working in a lab. Due to safety regulations, only five people are allowed in the lab at the same time. The code for each researcher is given below. It uses a semaphore lab, to represent whether there is space left in the lab for more people. S1, S2 and S3 are labels identifying the line code.

Researcher code:

S1: wait(lab);

S2: work();

S3: signal(lab);

Part a - There are eight researchers, A, B, C, D, E, F, G and H, working in the lab. Each researcher operates according to the above code. Your task is to give an execution trace that contains both of the following:

- The trace should show what happens when there are less than five researches in the lab and one or more of them leave.

- The trace should show what happens when there are five researchers in the lab and another researcher or several researchers want to enter.

The trace must start with an empty lab and show all the steps of each of the researchers as they enter/leave.

You must show the value of lab after each wait or signal step. Ensure that you state the initial value of lab.

If a wait operation executes, indicate whether the process succeeds or is placed in the queue. If a signal operation executes, indicate whether the value is changed or a sleeping process is woken up.

Each line of your trace should have the following format:

Statement executed including which Researcher process (e.g., M.S1 means that the researcher named M executed statement S1); the value of the lab semaphore (e.g., lab=2); whether the wait succeeded or was placed in the queue/ whether the signal changed the semaphore value or a sleeping process woke up.

For example: M.S1; lab=2; wait succeeded.

Part b - The code has now been modified. Each time a researcher enters the lab, an integer totalEntered is incremented. The variable is initially 0. The new code is given below:

Researcher code:

S1: wait(lab);

S2: totalEntered = totalEntered + 1;

S3: work();

S4: signal(lab);

The code given has a problem. The researchers have found that sometimes the totalEntered value does not reflect the actual number of researchers who have entered the lab.

Explain, in words, how this situation could occur.

Show a trace that demonstrates the problem occurring. Note that you are not being asked to solve the problem.

Reference no: EM132466990

Questions Cloud

Determining the fund the expansion plans : The current market price of the company's stock is $23.60 a share. How many shares of stock must be sold to fund the expansion plans?
What is the value of one right : The new rights offering grants one right for each share of stock outstanding. The new shares being offered are priced at $10 plus two rights.
Determine the income-sharing agreements would rory : Determine the income-sharing agreements would Rory would Rory prefer if the foresight?Aikman (beginning capital, $60,000) and Rory (beginning capital $90,000)
What is the value of one right-river bend company : The current market price of the stock is $28.15 and there are 1,600,000 shares currently outstanding. What is the value of one right?
Assignment - Data Structure and Algorithms Question : Assignment - Data Structure & Algorithms Question. Explain, in words, how this situation could occur. Show a trace that demonstrates the problem occurring
What is the amount of the annual interest tax shield : What is the amount of the annual interest tax shield if the tax rate is 28 percent?
What is the total market value of the company : The other shareholders have agreed to have the company borrow the $262,000 needed to repurchase her shares of stock.
How much income was allocated to martha assuming net income : How much income was allocated to Martha assuming net income was 36,000?Determine Jones' ending capital balance assuming net income was 50,000?
What is the value of company-shoes company : The company also has $12,000 of debt that carries a coupon rate of 7 percent. The debt is selling at par value.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  What are the characteristics of a good algorithm

What is an algorithm? What are the characteristics of a good algorithm and what do you mean by complexity of an algorithm? Explain the meaning of worst case analysis and best case analysis with an example.

  Find the optimum value of k and compare the result

The last subarray may be longer to preserve the total number of items n but do not go in such details in your analysis.

  Give an algorithm similar to that in the text for threading

Give an algorithm similar to that in the text for threading a binary tree, but to facilitate preorder traversal.

  Create an online student class registration system.

All information on classes, students, department, and instructors can be added, deleted, and updated.

  Implement the missing methods for class mygraph

Implement the missing methods for class MyGraph which implements the interface Graph where the Integer is a vertex index (0..n-1) and the Double is the edge weight (distance). A skeleton has been provided.

  Create algorithm to accept current salary

Create the algorithm which will prompt for and accept current salary for each of faculty members, then compute and show their individual pay increases.

  Develop class templates for various trees

Develop a class template for general search trees that uses a binary tree to represent the tree as described in the text.

  Hierarchy chart and design the logic

Draw the hierarchy chart and design the logic for a program that calculates the projected cost of an automobile trip. Assume that the user's car travels 20 miles per gallon of gas. Design a program that prompts the user for a number of miles drive..

  Show how the box can be used to factor n

That is, given a quadratic residue y, the box outputs an x with x2 = y (equation is modulo n). Show how the box can be used to factor n.

  Write a function to traverse a tree level by level

Write a function 1eve1ByLeve10 to traverse a tree level by level; that is, first visit the root, then all nodes on level 1.

  Draw the hierarchy chart and then plan logic for a program

Draw the hierarchy chart and then plan the logic for a program for the sales manager of The Couch Potato Furniture Company. The manager needs a program to determine the profit on any item sold

  Research paper - cognitive modeling and human interaction

The paper can be a review that covers current solutions on Cognitive modeling and human interaction, or a research paper that proposes your own opinions/solutions.

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