For Juliet’s code, I think you meant:
up(romeo)
down(juliet)
This is also my answer for the question, if I recall correctly.
Haha yeah… made the mistake cuz I copy pasted from Romeo’s code :P
Same as me! haha.
Yup, this works. I tried it straight after the paper. =)
My MCQ answers:
1. A
2. A
3. D
4. A
5. D
6. B
7. C
8. C
9. C
10. D
Anyone got same answers?
I got the same ans, except for question 4, I am not sure it’s A or X and I chose X :(
I think question 3 should be X, if they all have to take R before taking any resource, there will never be any deadlock because the one that takes R will always get all the resources he wants
Comments are closed.
Viewing Message: 1 of 1. Warning
Blog.nus accounts will move to SSO login, tentatively before the start of AY24/25 Sem 2. Once implemented, only current NUS staff and students will be able to log in to Blog.nus. Public blogs remain readable to non-logged in users. (More information.)
Q.12 (c) I got a solution without having to change the value of the semaphores. Is this correct?
Romeo:
while(true) {
down(romeo)
down(s)
eat()
up(s)
up(juliet)
}
Juliet:
while(true) {
down(s)
eat()
up(s)
up(juliet)
down(romeo)
}
For Juliet’s code, I think you meant:
up(romeo)
down(juliet)
This is also my answer for the question, if I recall correctly.
Haha yeah… made the mistake cuz I copy pasted from Romeo’s code :P
Same as me! haha.
Yup, this works. I tried it straight after the paper. =)
My MCQ answers:
1. A
2. A
3. D
4. A
5. D
6. B
7. C
8. C
9. C
10. D
Anyone got same answers?
I got the same ans, except for question 4, I am not sure it’s A or X and I chose X :(
I think question 3 should be X, if they all have to take R before taking any resource, there will never be any deadlock because the one that takes R will always get all the resources he wants