# Rick van der Zwet # StudentID: 0433373 # $Id: lecture7.txt 380 2007-12-14 19:15:01Z rick $ All quotes are based on the 8th edition of Concepts of programming languages from Robert W. Sebesta *** Chapter 13 Questions *** Problem Set 3, 5, 6, 9 3) Q: Busy waiting is a method whereby a task waits for a given event by continuously checking for that event to occur. What is the main problem with this approach? A: Deadlocks could occurs, where all processes are waiting on each-other 5) Q: From a book on assembly language programming for a computer that uses an Intel Pentium processor determine what instructions are provided to support the construction of semaphores? A: According to http://jsimlo.sk/docs/cpu/index.php/lock.html, Intel processors uses for example F0 (LOCK) to create lock signal or the XCHG which automatically includes/sets the lock signal 6) Q: Suppose two tasks A and B must use the shared variable Buf_Size. Task A adds 2 to Buf_Size and task B subtracts 1 from it. Assume that such arithmetic operations are done by the three-step process of fetching the current value, performing the arithmetic, and putting the new value back. In the absence of competition synchronization, what sequences of events are possible and what values result from these operations? Assume the initial value of Buf_Size is 6? A: We use the symantic of R(ead), O(peration), W(rite) Peforming the operation is no problem and will not lead to problems if execuded before a read or write; * AR - AW - BR - BW = 7 * AR - BR - AW - BW = 5 * AR - BR - BW - AW = 8 * BR - AR - AW - BW = 8 * BR - AR - BW - AW = 5 * BR - BW - AR - AW = 7 9) Q: What happens if a monitor procedure calls another procedure in the same monitor? A: The first procedure (A) will suspend till the second (B) is ready, both A and B do have access to the same dataspace.