GATE CSE · 2023 · CS
Question 38: Operating System
Give it a try, then reveal the answer to check your work.
Question 38
CSMCQ2 marksNeeds review
Consider the two functions inc and dec shown below.
inc(){ dec(){
wait(s); wait(s);
X = X+1; X = X-1;
signal(s); signal(s);
} }
There are 5 threads each invoking inc once, and 3 threads each invoking dec once, on the same shared variable X. The initial value of X is 10.
Suppose there are two implementations of the semaphore s, as follows:
I-1: s is a binary semaphore initialized to 1.
I-2: s is a counting semaphore initialized to 2.
Let V1, V2 be the values of X at the end of execution of all the threads with implementations I-1, I-2, respectively.
Which one of the following choices corresponds to the minimum possible values of V1, V2, respectively?
Your answerChoose one option.
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 answerEXPLORE & PRACTISE
Paper and topic context
See where this question comes from and choose what to practise next.
2023CS
GATE CSE 2023 · Paper 1
Computer Science and Information Technology · Original paper archive
- Section
- Computer Science and Information Technology
- Question type
- Multiple choice (MCQ)
- 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
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.