DATA STRUCTURES, ANALYSIS OF ALGORITHMS AND COMPUTATIONAL COMPLEXITY
COMPUTER ARCHITECTURE AND OPERATING SYSTEMS
| Process | Arrival time | Expected CPU time
| P1 | 0 | 14
| P2 | 2 | 12
| P3 | 4 | 8
| P4 | 5 | 4
| P5 | 17 | 7
| |
a) Assuming Shortest-Job-First scheduling, draw a Gantt chart to show when each process executes on the CPU. Also compute the average waiting time.
b) Repeat for Round-Robin scheduling, assuming a time quantum of size = 6.
PROGRAMMING LANGUAGES AND COMPILER DESIGN
a) Define "Abstraction" in this context.
b) Give 3 examples of features in modern programming languages
which provide support for abstraction. Explain briefly
how these features support abstraction.
a) i = a[i++];
b) int f(int); /* A function with global side effects */
. . .
if ( f(x) > 0 || f(x) < 3 ) { /* do something */ }
c) int f(int); /* A function with global side effects */
. . .
x = 3*f(x) + 7*f(x);
d) void g(inout int, inout int); /* A function with value-result parameter passing */
. . .
g(x, x);
program P
var x,y,z: integer; /* Static (global) variables */
var ip: pointer to integer;
const c = 2, d= 3; /* Static (global) constants */
procedure Proc(
in i: integer; /* Value or input parameter */
out j: integer; /* Result or output parameter */
inout k: integer) /* In/Out or value-result parameter */
var x,y: integer; /* Local variables */
x := i + 1; /* Use of input parameter and local variable */
j := x + 1; /* Use of output parameter */
k := k + 1; /* Use of value-result parameter */
z := i + j + k + x; /* Use of non-local variable */
y := 2 * z;
ip := new integer; /* Use of non-local pointer variable */
ip^ := z + 1; /* Represents a dereferenced pointer, similar to *ip in C */
/* <<<<< HERE >>>>> */
end Proc;
procedure main()
x := 1; /* Use of global variables */
z := 1;
Proc(x,y,z); /* Subprogram invocation */
print(x,y,z,ip^);
end main;
end P;
a) Show (1) how memory is allocated and (2) the contents of memory at the point labeled <<<< HERE >>>>>.
b) What is the output of the program?