Real-Time Concurrent Systems Lab #4 SOLUTION

Part A: Understanding the Java synchronized monitors (lab4a.txt) You are given a threaded program that uses logging to trace the execution of two kinds of threads. You will recognize the Sleepy and Yappy threads. Two logs are maintained: log is unsynchronized and slog is synchronized. slog is synchronized because all accesses to it are surrounded by Java's synchronized statements.  Load the programs into your Java IDE, read the program and then run it to observe its behaviour.  Answer some questions about the behaviour (in lab4a.txt) o How many entries SHOULD be in the log? o How many entries are in the unsynchronized log? (If you execute the program more than once, give the minimum and maximum values seen) o How many entries are in the synchronized log? (Again, give minimum and maximum values)  Analyse your observations: Is the synchronized log truly protected? (Answer: NO!) Does your evidence support such a statement? Why or why not? (Not!) Explain in terms of the Java code.(I'm not giving you this answer!) Part B: Java Synchronized (lab4b.java) Write a correct version of Part A's program. Part C: Xenomai Mutex (lab4c.c) Write a Xenomai version of Part A's program.
Powered by