source: liacs/cvp/assignments/lecture7.txt@ 84

Last change on this file since 84 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

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