ISTRIBUTED COMPUTER SYSTEM _ THIS IS MULTIPLE CHOICE - PLease
just help me with answers
1. A thread differs from a process in that, among other
things:
(a) It can be created at a lower cost.
(b) It provides more data isolation than a process.
(c) Switching threads of one process is faster than switching
different processes.
(d) Communication of threads requires IPC mechanisms.
(e) Processes can only be run by a judge.
2. What error/problem occurs in the following code:
from threading import Thread, Lock
l1 = Lock()
l2 = Lock()
def thr1():
with l1:
with l2:
print("Peek-a-boo
1!")
def thr2():
with l2:
with l1:
print("Peek-a-boo
2!")
def main():
t1 = Thread(target=thr1)
t2 = Thread(target=thr2)
t1.start()
t2.start()
if __name__ == "__main__":
main()
(a) Race condition.
(b) Data starvation of *one* of the threads.
(c) Semaphores should be used instead of locks.
(d) Possibility of a deadlock.
(e) No error - the program will definitely work
correctly.
3. What are (among other things) the differences between a binary
semaphore and a lock?
(a) A semaphore has information about which thread acquired
it, while a lock does not.
(b) A lock has information about which thread acquired it,
while a semaphore does not.
(c) A binary semaphore works more efficiently.
(d) A semaphore can be used in algorithms where another
thread
ISTRIBUTED COMPUTER SYSTEM _ THIS IS MULTIPLE CHOICE - PLease just help me with answers 1. A thread differs from a proce
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am