QUESTION 2 (38 MARKS) Given the following code snippet. 16. 17. 18. 19. 20. 21. 22. 23. 24. 125. 26. 27. 28. 29. import

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

QUESTION 2 (38 MARKS) Given the following code snippet. 16. 17. 18. 19. 20. 21. 22. 23. 24. 125. 26. 27. 28. 29. import

Post by answerhappygod »

Question 2 38 Marks Given The Following Code Snippet 16 17 18 19 20 21 22 23 24 125 26 27 28 29 Import 1
Question 2 38 Marks Given The Following Code Snippet 16 17 18 19 20 21 22 23 24 125 26 27 28 29 Import 1 (19.45 KiB) Viewed 7 times
Question 2 38 Marks Given The Following Code Snippet 16 17 18 19 20 21 22 23 24 125 26 27 28 29 Import 2
Question 2 38 Marks Given The Following Code Snippet 16 17 18 19 20 21 22 23 24 125 26 27 28 29 Import 2 (28.11 KiB) Viewed 7 times
Question 2 38 Marks Given The Following Code Snippet 16 17 18 19 20 21 22 23 24 125 26 27 28 29 Import 3
Question 2 38 Marks Given The Following Code Snippet 16 17 18 19 20 21 22 23 24 125 26 27 28 29 Import 3 (28.11 KiB) Viewed 7 times
Question 2 38 Marks Given The Following Code Snippet 16 17 18 19 20 21 22 23 24 125 26 27 28 29 Import 4
Question 2 38 Marks Given The Following Code Snippet 16 17 18 19 20 21 22 23 24 125 26 27 28 29 Import 4 (22.66 KiB) Viewed 7 times
QUESTION 2 (38 MARKS) Given the following code snippet. 16. 17. 18. 19. 20. 21. 22. 23. 24. 125. 26. 27. 28. 29. import threading global variable y y-D def increment (): global y for in zange (1000000): y +1 def main() global if tIncrment threading. Thread (target-increment) tIncrment2 threading.Thread(target-increment) tIncrment.atart() tIncrment2.start() tIncerment.join() Incrment2.join() name main() print (y) main": Determine how many processes and threads are in the given code. Determine the output of the given code and justify your answer. Identify the critical sections of the given code (4 markah/mark) Revise the threads) in the given code using process() (5 markah/marks) (2 markah/mark) Revise the code and apply mutual exclusion on the critical sections in the given code then write the output of the revised code (9 markah/mark) (7 markah/marks) Using the Clojure programming language, construct a new application and use atomic concepts to replace the given code (11 markah/marks)
QUESTION 2 (38 MARKS) Given the following code snippet. 2. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. import threading global variable y y=0 def increment (): global y for in range (1000000) : y +1 def main (): global x tIncrment= threading. Thread (target-increment) tIncrment2 = threading.Thread (target-increment) tIncrment.start() tIncrment2.start() tIncrment.join() tIncrment2.join() if name main () print (y) main ": Determine how many processes and threads are in the given code. Determine the output of the given code and justify your answer. (4 markah/marks) (5 markah/marks)
Identify the critical sections of the given code. (2 markah/marks) Revise the code and apply mutual exclusion on the critical sections in the given code, then write the output of the revised code. (9 markah/marks) Revise the thread(s) in the given code using process(s). (7 markah/marks) Using the Clojure programming language, construct a new application and use atomic concepts to replace the given code. (11 markah/marks)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply