GATE 2017 (Session 2)
65 questions
MCQ 45 · NAT 201-mark 30 · 2-mark 35
Questions 61–65 of 65
Consider the set of processes with arrival time (in milliseconds). CPU burst time (in milliseconds), and priority (0 is the highest priority) shown below. None of the processes have I/O burst time.
The average waiting time (in milliseconds) of all the processes using preemptive priority scheduling algorithm is __________
The average waiting time (in milliseconds) of all the processes using preemptive priority scheduling algorithm is __________
Answer: 29
Waiting time = completion time arrival time burst time. In preemptive priority scheduling (0 is highest), a newly arrived process with a higher priority takes the CPU at once.
Gantt chart: P1 0-2, P4 2-5, P2 5-33, P4 33-40, P1 40-49, P3 49-51, P5 51-67
Why the CPU changes hands:
- At t = 2, P4 (priority 1) arrives and preempts P1 (priority 2).
- At t = 5, P2 (priority 0, the highest) arrives and preempts P4. Nothing can preempt P2, so it runs to 33. P5 (priority 4) and P3 (priority 3) arrive meanwhile but must wait.
- After 33 the rest run in priority order: P4 (1), P1 (2), P3 (3), P5 (4).
Completion times: P1 49, P2 33, P3 51, P4 40, P5 67.
Waiting times:
P1 = 49 0 11 = 38
P2 = 33 5 28 = 0
P3 = 51 12 2 = 37
P4 = 40 2 10 = 28
P5 = 67 9 16 = 42
Average waiting time = (38 + 0 + 37 + 28 + 42) / 5 = 145 / 5 = 29 ms
Answer: 29 ms
Gantt chart: P1 0-2, P4 2-5, P2 5-33, P4 33-40, P1 40-49, P3 49-51, P5 51-67
Why the CPU changes hands:
- At t = 2, P4 (priority 1) arrives and preempts P1 (priority 2).
- At t = 5, P2 (priority 0, the highest) arrives and preempts P4. Nothing can preempt P2, so it runs to 33. P5 (priority 4) and P3 (priority 3) arrive meanwhile but must wait.
- After 33 the rest run in priority order: P4 (1), P1 (2), P3 (3), P5 (4).
Completion times: P1 49, P2 33, P3 51, P4 40, P5 67.
Waiting times:
P1 = 49 0 11 = 38
P2 = 33 5 28 = 0
P3 = 51 12 2 = 37
P4 = 40 2 10 = 28
P5 = 67 9 16 = 42
Average waiting time = (38 + 0 + 37 + 28 + 42) / 5 = 145 / 5 = 29 ms
Answer: 29 ms
If the characteristics polynomial of 3x3 matrix M over R ( the set of real numbers) is , and one eigenvalue of M is 2, then the largest among the absolute values of the eigenvalues of M is ________.
Answer: 5
We are told that is an eigenvalue. So it must satisfy the characteristic equation.
The characteristic equation is:
The eigenvalues are and
The largest eigenvalue in absolute value
The characteristic equation is:
The eigenvalues are and
The largest eigenvalue in absolute value
Consider a machine with a byte addressable main memory of bytes divided into blocks of size 32 bytes. Assume that a direct mapped cache having 512 cache lines is used with this machine. The size of the tag field in bits is ______.
Answer: 18
The block offset needs 5 bits, because a block is 32 B. The index needs 9 bits, because there are 512 lines. So the tag is 32 5 9 = 18 bits.
Answer: 18
Answer: 18
Consider the following C program.
#include <stdio.h>
int main ( ) {
int m = 10;
int n, n1;
n = ++m;
n1 = m++;
n--;
--n1;
n-=n1;
printf ("%d", n) ;
return 0;
} The output of the program is ______________.Answer: 0
Go through each statement in order:
- n = ++m: m = 11, n = 11
- n1 = m++: n1 = 11, m = 12
- Decrement n: n-- 10. Decrement n1: --n1 10
- Subtract n1 from n: n -= n1 0
Answer: 0
- n = ++m: m = 11, n = 11
- n1 = m++: n1 = 11, m = 12
- Decrement n: n-- 10. Decrement n1: --n1 10
- Subtract n1 from n: n -= n1 0
Answer: 0
Consider the following C Program.
#include <stdio.h>
#include <string.h>
int main ( ) {
char* c = "GATECSIT2017";
char* p = c;
printf("%d", (int) strlen (c+2[p]-6[p]-1));
return 0;
}
The output of the program is _______________.Answer: 2
Here 2[p] is the same as p[2], which is 'T' (84). Also 6[p] is the same as p[6], which is 'I' (73).
So the pointer is c + 84 73 1 = c + 10. It points to the string "17".
strlen("17") = 2
Answer: 2
So the pointer is c + 84 73 1 = c + 10. It points to the string "17".
strlen("17") = 2
Answer: 2