JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Contents<br />
3.2.1 Semaphore methods . . . . . . . . . . . . . . . . . . . . 56<br />
3.2.2 Using semaphores . . . . . . . . . . . . . . . . . . . . . 58<br />
3.2.3 The semaphores package . . . . . . . . . . . . . . . . . 63<br />
3.3 Objects providing mutual exclusion – Monitors . . . . . . . . . 66<br />
3.3.1 Synchronized . . . . . . . . . . . . . . . . . . . . . . . . 66<br />
3.3.2 Conditions – wait and notify . . . . . . . . . . . . . . . 74<br />
3.3.3 More on monitor programming . . . . . . . . . . . . . . 83<br />
3.4 Message-based communication – Mailboxes . . . . . . . . . . . 85<br />
3.4.1 More on object interaction . . . . . . . . . . . . . . . . 86<br />
3.4.2 Events and buffers . . . . . . . . . . . . . . . . . . . . . 87<br />
3.4.3 Threads and event-based communication . . . . . . . . 95<br />
II Exercises and Labs 97<br />
4 Exercises and Labs 99<br />
4.1 Exercise 1 – Semaphores . . . . . . . . . . . . . . . . . . . . . . 99<br />
4.2 Exercise 2 – Lab 1 preparation . . . . . . . . . . . . . . . . . . 103<br />
4.3 Lab 1 – Alarmclock . . . . . . . . . . . . . . . . . . . . . . . . . 108<br />
4.4 Exercise 3 - Monitor and Wait/Notify . . . . . . . . . . . . . . 112<br />
4.5 Exercise 4 - Deadlock analysis and lab 2 preparation . . . . . . 116<br />
4.6 Lab 2 – Lift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121<br />
4.7 Exercise 5 - Mailbox and lab 3 preparation . . . . . . . . . . . 123<br />
4.8 Exercise 6 - Scheduling analysis . . . . . . . . . . . . . . . . . . 137<br />
4.9 Lab 3 – Washing machine . . . . . . . . . . . . . . . . . . . . . 139<br />
5 Solutions 141<br />
5.1 Solution to exercise 1 . . . . . . . . . . . . . . . . . . . . . . . . 141<br />
5.2 Solution to exercise 3 . . . . . . . . . . . . . . . . . . . . . . . . 144<br />
5.3 Solution to exercise 4 . . . . . . . . . . . . . . . . . . . . . . . . 147<br />
5.4 Solution to exercise 6 . . . . . . . . . . . . . . . . . . . . . . . . 148<br />
8 2012-08-29 16:05