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

TOPIC: Acquired Cardiac Disease while pregnant1. Describe the assigned obstetrical or newborn disorder, the pathophysiology of the disorder, and

TOPIC: Acquired Cardiac Disease while pregnant1. Describe the assigned obstetrical or newborn disorder, the pathophysiology of the disorder, and compare/contrast that to normal findings.2. Discuss the common treatments, progression, and outcomes of the condition/complications.3. Implement health promotion concepts related to the topic.ASSIGNMENT GUIDELINES FOR THE WRITTEN ASSIGNMENT: 1. The student

I need 14 : upgrade Los Angeles slum I attached

I need 14  : upgrade Los Angeles slum I attached the file outline so you can have ideas a bout the topic, please use references in the file outline for my work. I also I attached the file SENIOR RUBRIC ( please follow the rubric) I also attached the APA

You must provide a comprehensive review for each of your

 You must provide a comprehensive review for each of your selected Case Studies – using the FOUR Case Studies options below – PLEASE SELECT 3. Your review requires a min ONE P.P. describing the Classroom Management strategies implemented or those you would suggest should have been used.  Case studies below

Instructions This week (week 6) you will be completing your

Instructions This week (week 6) you will be completing your outline for your research project which is due by the end of Week 7.  This weeks assignment is a one-pa ge outline for your week 7 project.  You will use proper outline formatting and address key points for your project. 

Case Study: Part 2 You will be creating a case

Case Study: Part 2 You will be creating a case study in stages over four course topics. This assignment will add to your previous work in Topic 2. Use an example from your own personal practice, experience, or your own personal/family (however, simulated cases are not acceptable for practice hours

Create a report on teaching strategies to apply in the

Create a report on teaching strategies to apply in the course.  Create three learning outcomes for the course. Conduct research on the course topic as necessary to create these outcomes. Summarize general course content and how these outcomes will relate to overall course content and how they align with learner

Degenerative Diseases Assignment Choose any two Nursing Assignment Help

Degenerative Diseases Assignment Choose any two degenerative diseases (your choice) from the list provided below. Create a 10 slide PowerPoint presentation that identifies the conditions, describes common characteristics, signs/symptoms, if the conditions do or do not interfere with daily life activities, EEG findings if any and treatment options. Use Session

MUST BE APA FORMAT , WITH AT LEAST 5 SCHOLARLY

MUST BE APA FORMAT , WITH AT LEAST 5 SCHOLARLY SOURCES (PLEASE MAKE SURE YOU USE THE CHAPTER ATTACHED AS YOUR MAIN SOURCE) For this Discussion, interact in a free-flowing discussion of the  biblical and constitutional parameters for the particular policy focus  being discussed this module. In other words, you

Constitutional Issues and the Scope and Character of U.S. Government

Week 5 – Final Research Paper Constitutional Issues and the Scope and Character of U.S. Government the Final Research Paper, you will use your critical thinking skills to analyze and evaluate a current events topic that has constitutional and political implications. Select one topic from the following list of three

Descriptive Statistics For this assignment, use the data you created

Descriptive Statistics For this assignment, use the data you created in your W1 Midweek Assignment. Using Microsoft Excel and following the instructions given in your lecture, choose and run the appropriate descriptive statistics (graphic and numerical) to describe the sample’s age, sex, height, and year in college. Copy your output

Question 1: A specialty chemical company is considering expanding its

  Question 1:  A specialty chemical company is considering expanding its operations into Brazil, where five companies dominate the consumption of specialty chemicals. What sort of distribution network should this company use? Question 2:  What types of distribution networks are typically best suited for commodity items?  Why?  What type of network is

Fixed Interest and Derivative Securities

Using the OptAll.xls spreadsheet, test option strategies using the 10 years of monthly exchange rate data downloaded from EIU which is available from the University database Marking scheme (notes are integral to the marking scheme): Presentation and clarity of your report 40% Quality of content 60% 100% Notes (failure to

Recommend one FDA-approved drug, one off-label drug, and one nonpharmacological

Recommend one FDA-approved drug, one off-label drug, and one nonpharmacological intervention for treating your chosen disorder in older adults or pregnant women. Explain the risk assessment you would use to inform your treatment decision  making. What are the risks and benefits of the FDA-approved medicine? What are the risks and

Research one of the three theories (presented in Chapter 18)

Research one of the three theories (presented in Chapter 18) for planned change and how that process could be applied to a real nursing change situation. Be sure to apply concepts from the readings and research. You must cite (with reference) at least one source: your textbook, scholarly resources, or

Can you do this? Management Paper – The assignment should

  Can you do this? Management Paper – The assignment should be prepared as a Word document, 3 pages in length. • The document should be double-spaced, using Arial font #12. • Add any appendices or references at the end of the Word document for each discipline separately. • Your reference

Natural Disaster – Premium Paper Help

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.