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