

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


A task may initiate an entry call and there is no available accept clause to rendezvous with it. A task may rendezvous with an accept clause which requires some processing. In this case, the calling task blocks until the accept clause has completed.
A : array [−10 .. 10, −5 .. 5, 1 .. 10] of T;
Assuming that T requires 10 bytes of storage and A is stored at relative location 100, what is the relative location of A [1, 1, 2]? addr (A [1, 1, 2]) = addr (A) + (((1 - (-10)) * 11) + (1 - (-5))) * 10 + 2 - 1)
program MAIN; var U, V : INTEGER; procedure A; var Y : INTEGER; ... (* point 4 ) end; procedure B; var U, V, Y : INTEGER; procedure C; ... begin ... ( point 3 *) A; ... end;
begin (* B ) ... ( point 2 ) C; ... end; begin ( MAIN ) ... ( point 1 *) B; ... end.
Indicate which activation records are stacked at each of points 1, 2, 3 and 4 in the program as well as the exact contents of those activation records. Assuming static scoping and deep binding, show the contents of the display at each of these points. Assuming dynamic scoping, what is the scope of V at point 4? Static scoping and deep binding
int I;
int F (int X, int Y) { I = 2; Y = 1; return X + Y; }
void main (void) { int A [3]; A [0] = 7; A [1] = 11; A [2] = 13; I = 0; cout << F (A [I], I); }
Show the values stored in the locations named A [0], A [1], A [2], I, X and Y at the entry and exit points of function F assuming (a) call by value, (b) call by reference, (c) call by value-result, and (d) call by name? Also, show the result which gets printed in each case. The following table shows the results for each calling method. Call by A[0] i A[0] o A[1] i A[1] o A[2] i A[2] o I i I o X i X o Y i Y o Res value 7 7 11 11 13 13 0 2 7 7 0 1 8 reference 7 7 11 11 13 13 0 1 a1 a1 a2 a2 8 value-result 7 7 11 11 13 13 0 1 7 7 0 1 8 name 7 7 11 11 13 13 0 1 t1 t1 t2 t2 12