Question 46

CSMSQ2 marksNeeds review
Consider the following pseudocode, where S is a semaphore initialized to 5 in line#2 and counter is a shared variable initialized to 0 in line#1. Assume that the increment operation in line#7 is not atomic.
int counter = 0;
Semaphore S = init(5);
void parop(void)
{

wait(S);

wait(S);

counter++;

signal(S);

signal(S);
} If five threads execute the function parop concurrently, which of the following program behavior(s) is/are possible?
Your answerSelect all correct options. You can choose more than one.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

EXPLORE & PRACTISE

Paper and topic context

See where this question comes from and choose what to practise next.

2021CS

GATE CSE 2021 · Paper 1

Computer Science and Information Technology · Original paper archive

Section
Computer Science and Information Technology
Question type
Multiple select (MSQ)
Marks
2 marks

Practise related topics

Explore more previous year questions using this question’s imported topic tags.

computer science

GATE CSE previous year questions

information technology

GATE CSE previous year questions

computing

GATE CSE previous year questions

operating system

GATE CSE previous year questions

threads

GATE CSE previous year questions

deadlock

GATE CSE previous year questions

Comments

Ask a question, share your approach, or help someone understand.

Log in to view the discussion

You’re not logged in. Log in or create an account to see discussions and add comments.