100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

COS3721 Assignment 2 (DETAILED ANSWERS) 2025 - DISTINCTION GUARANTEED

Rating
-
Sold
-
Pages
19
Grade
A+
Uploaded on
23-06-2025
Written in
2024/2025

COS3721 Assignment 2 (DETAILED ANSWERS) 2025 - DISTINCTION GUARANTEED - DISTINCTION GUARANTEED - DISTINCTION GUARANTEED Answers, guidelines, workings and references ,....

Institution
Course








Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Course

Document information

Uploaded on
June 23, 2025
Number of pages
19
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

COS3721 Assignment 2 2025
Unique Number:
Due date: 23 June 2025
Chapter 6 – Question 01


a. What data have a race condition?


In the given pseudocode for an array-based stack in a concurrent environment, the variable top is subject to a
race condition. This variable is accessed and modified in both the push() and pop() operations. If two
threads execute either of these functions at the same time without proper synchronization, they may read and
update the top value simultaneously, leading to inconsistent or corrupted stack state (e.g. data loss or
overwriting).


b. How could the race condition be fixed?


The pseudocode already attempts to use acquire() and release() to create a critical section, suggesting
some kind of locking mechanism (like a mutex or semaphore). However, to properly fix the race condition:


 Ensure that acquire() is implemented using a thread-safe mutual exclusion mechanism like a mutex.
 Only one thread should be allowed to enter the critical section at a time where top and stack[top]
are accessed or modified.
 Also, make sure release() is always called after acquire() (including in error branches) to avoid

DISCLAIMER & TERMS OF USE
 Educational Aid: These study notes are intended to be used as educational resources and should not be seen as a
replacement for individual research, critical analysis, or professional consultation. Students are encouraged to perform
their own research and seek advice from their instructors or academic advisors for specific assignment guidelines.
 Personal Responsibility: While every effort has been made to ensure the accuracy and reliability of the information in
these study notes, the seller does not guarantee the completeness or correctness of all content. The buyer is
responsible for verifying the accuracy of the information and exercising their own judgment when applying it to their
assignments.
 Academic Integrity: It is essential for students to maintain academic integrity and follow their institution's policies
regarding plagiarism, citation, and referencing. These study notes should be used as learning tools and sources of
inspiration. Any direct reproduction of the content without proper citation and acknowledgment may be considered
academic misconduct.
 Limited Liability: The seller shall not be liable for any direct or indirect damages, losses, or consequences arising from
the use of these notes. This includes, but is not limited to, poor academic performance, penalties, or any other negative
consequences resulting from the application or misuse of the information provided.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Edge
Follow You need to be logged in order to follow users or courses
Sold
9850
Member since
2 year
Number of followers
4253
Documents
2745
Last sold
2 hours ago

4.2

1207 reviews

5
674
4
245
3
187
2
28
1
73

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions