Concurrent and Parallel Algorithms

Question 2

There is a public swimming pool with a limit of 4 swimmers in the pool at one time. (It is a very small pool!) The code for each swimmer is given below. It uses a semaphore poolSpace, to represent whether there is space left in the pool for more swimmers. S1, S2 and S3 are labels identifying the line of code. Swimmer code: S1: wait(poolSpace); S2: swim(); S3: signal(poolSpace);

(a) There are six people, A, B, C, D, E and F who want to swim in the pool. Each person is an instance of the Swimmer class. Demonstrate how the semaphore prevents more than four people being in the pool at the same time by giving an example execution trace. Show the value of poolSpace after each wait or signal step. Ensure that you state the initial value of poolSpace. 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 Swimmer process (e.g. A.S1); poolSpace value (e.g. poolSpace=2); whether the wait succeeded or was placed in the queue/ whether the signal changed the semaphore value or a sleeping process woke up. (b) The swimmers have become more competitive. They want to keep track of the fastest time to swim a length of the pool. They decide to use the code below, which uses a shared variable fastest to record the fastest time (i.e. smallest value) so far.

Assume that when the method swim runs, it updates the Swimmer’s local int variable myTime to the time just taken for this current swim. The details of how it does this is irrelevant. Global shared variable: int fastest; Swimmer code: wait(poolSpace); swim(); if (fastest > myTime){ fastest = myTime; } signal(poolSpace); The code given has a problem. The swimmers have found that sometimes the time stored in fastest is not actually the quickest time so far. 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. You can select any arbitrary times for myTime for each swimmer as long as it demonstrates how the problem occurs.

#Concurrent #Parallel #Algorithms

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Use the work you completed for PartsI – Marketing Expenses

Use the work you completed for PartsI – Marketing Expenses versus Rival Firms, Perceptual Map andDiagramming Existing and Proposed Organizational . Write a 500-750-word summary of how the reports for Parts I, II, and III of the CLC assignment were influenced by the analysis prepared in previous assignments your CLC

Possible solutions and recommendations to assist IKEA in resolving the

Possible solutions and recommendations to assist IKEA in resolving the issue with its system. IKEA must own its flaws in order to control and overcome them. This could be quite helpful in assisting IKEA in setting goals and expanding new ideas. IKEA’s issues could include: When it comes to providing

Course: Introduction to Business Management Semester: Fall 2021 Instructor: Tabinda

Course: Introduction to Business Management Semester: Fall 2021 Instructor: Tabinda Chowdhury Assignment 3 (10%) Chapter 11 (Managing Control and Operations) and Chapter 12 (Managing Change) TURNITIN Submission via Schoology Question 1: What is Organizational Control? You must cite 1 external reference to answer this question. (5 marks) Question 2: Define

Review this Mayo Clinic overview ( https://www.mayoclinic.org/diseases-conditions/fibromyalgia/symptoms-causes/syc-20354780) Define fibromyalgia and

  Review this Mayo Clinic overview ( https://www.mayoclinic.org/diseases-conditions/fibromyalgia/symptoms-causes/syc-20354780)  Define fibromyalgia and describe the pathophysiology, clinical manifestations, evaluation, and treatment. Comment on advances in diagnosis and management of this disorder that debunk the idea that the disorder is “in the patient’s head.”  Use at least one scholarly source other than your textbook

your interpretation of this literature, 600 words Mother to Son

your interpretation of this literature, 600 words Mother to Son BY LANGSTON HUGHES Well, son, I’ll tell you:Life for me ain’t been no crystal stair.It’s had tacks in it,And splinters,And boards torn up,And places with no carpet on the floor—Bare.But all the timeI’se been a-climbin’ on,And reachin’ landin’s,And turnin’ corners,And

Choose your sentences for your descriptive paragraph from the following

Premium Paper Help is a professional writing service that provides original papers. Our products include academic papers of varying complexity and other personalized services, along with research materials for assistance purposes only. All the materials from our website should be used with proper references.

CenturyLink (CTL) Iron Mountain (IRM) Ford Motor (F) Kimco Realty

    CenturyLink (CTL) Iron Mountain (IRM) Ford Motor (F) Kimco Realty (KIM) Invesco (IVZ) AT&T (T) Macerich Co (MAC) Seagate Technology (STX) Navient Corp (NAVI) Altria (MO) Deliverable The case study will be presented in one Microsoft Word and one Microsoft Excel document that includes analysis of the company’s financial

Case Study: Motivate your employees with incentives that matter to

Case Study: Motivate your employees with incentives that matter to them. “Kris Snyder — the founder and CEO of Vox Mobile, the mobile technology management company based in Cleveland, Ohio — offers his 130 employees a veritable cafeteria of benefits, compensation, and work assignments. “I think of my employees as

Project Schedule Scavenger Hunt

 Using the Internet, Google images, or the Hunt Library, search for an example of a project schedule. Post the project schedule in the discussion forum, and answer the following questions about the schedule you found: How long does the project take? Which activities do you think are most important? Are

IFRS Discussion Forum [WLOs: 4, 5, 6] [CLOs: 1, 2,

 IFRS Discussion Forum [WLOs: 4, 5, 6] [CLOs: 1, 2, 3, 4] Prior to beginning work on this discussion forum, read Chapters 2 and 3 of the text. Summaries for your weekly required chapter readings can be found in the weekly introductions. Would the worldwide adoption of IFRS result in

Reflection and Discussion Forum Week 4 Reflection and Discussion Forum

  Reflection and Discussion Forum Week 4 Reflection and Discussion Forum Week 4Assigned Readings:Chapter 9. Foundations of Group BehaviorChapter 10. Understanding Work TeamsInitial Postings: Read and reflect on the assigned readings for the week. Then post what you thought was the most important concept(s), method(s), term(s), and/or any other thing

Search engine optimization (SEO) is an important aspect for your

Search engine optimization (SEO) is an important aspect for your website. It is the way your web pages will be listed in the search engines. There are many important factors that will affect how your pages rank in search engines. Proper SEO will increase traffic to your site, which will

Design of a Cost System Why is the design of

  Design of a Cost System Why is the design of a cost system so much more complicated today than it was when cost accounting was in its infancy? Submission Instructions: Any written explanations should use complete sentences, and appropriate grammar, punctuation, spelling and word usage. Your initial post should

Overview – In this activity you are to review the

 Overview – In this activity you are to review the product liability case below and create a brief that summarizes its legal elements and holding. Instructions – Read Estate of Simpson v. GM, LLC. Using the Week 3 Activity Template  [DOCX], accurately summarize the following regarding design, manufacturing, and failure-to-warn causes of action in a brief

esearch the delivery, finance, management, and sustainability methods of the

esearch the delivery, finance, management, and sustainability methods of the U.S. health care system. Evaluate the effectiveness of one or more of these areas on quality patient care and health outcomes. Propose a potential health care reform solution to improve effectiveness in the area you evaluated and predict the expected

A 22-year-old female complains of 3 days of watery diarrhea

  A 22-year-old female complains of 3 days of watery diarrhea with 7 to 8 stools per day. She is drinking approximately “3 sodas a day” because she is “trying not to get dehydrated.” She has had very little other intake because “eating makes me have to go to the

Write a two-paragraph summary of your thoughts of the videos:

Write a two-paragraph summary of your thoughts of the videos: https://www.youtube.com/watch?v=falHoOEUFz0&list=PLDPDyTQerfAaQUdfKH-wDHv2VeCI5bKqR https://www.youtube.com/watch?v=R-sVnmmw6WY&index=1&list=PLKiXyiMuXCLCIR6qt-c7NLYteGDLyxfS Write a one-paragraph summary of each video–6 sentences per paragraph. Make sure you identify what cognition is in your summary. Please make sure your paragraphs are at least six sentences long. You can write more than two paragraphs.