Aspire Faculty ID #18921 · Topic: UGC NET Computer Science Nov 2020 (Paper II) · Just now
UGC NET Computer Science Nov 2020 (Paper II)

Suppose you are compiling on a machine with $1$-byte chars, $2$-byte shorts, $4$-byte ints, and $8$-byte doubles, and with alignment rules that require the address of every primitive data element to be an integer multiple of the element's size. Suppose further that the compiler is not permitted to reorder fields; padding is used to ensure alignment. How much space will be consumed by the following array?

struct {
short s;
char c;
short t;
char d;
double r;
int i;
} A[10];

Solution

$short\ s$: starts at offset $0$, size $2$, next offset $2$

$char\ c$: starts at offset $2$, size $1$, next offset $3$

$short\ t$: needs multiple of $2$, so $1$ byte padding, starts at offset $4$, next offset $6$

$char\ d$: starts at offset $6$, size $1$, next offset $7$

$double\ r$: needs multiple of $8$, so $1$ byte padding, starts at offset $8$, next offset $16$

$int\ i$: needs multiple of $4$, starts at offset $16$, next offset $20$

Struct size must be multiple of maximum alignment $8$.

So, $20$ is padded to $24$ bytes.

For $A[10]$:

$10\times24=240$ bytes

Previous 10 Questions — UGC NET Computer Science Nov 2020 (Paper II)

Nearest first
1
In HTML, $<map>$ tag is used for
Topic: UGC NET Computer Science Nov 2020 (Paper II)
2
Consider the following pseudo-code fragment, where $a$ and $b$ are integer variables that have been initialized:Pre-con…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
3
What is the radix of the numbers if the solution to the quadratic equation $x^2-10x+26=0$ is $x=4$ and $x=7$?
Topic: UGC NET Computer Science Nov 2020 (Paper II)
4
A non-pipeline system takes $50\ ns$ to process a task. The same task can be processed in six-segment pipeline with a c…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
5
The following program is stored in memory unit of the basic computer. What is the content of the accumulator after the …
Topic: UGC NET Computer Science Nov 2020 (Paper II)
6
Consider a machine with a byte addressable main memory of $2^{16}$ bytes and block size of $8$ bytes. Assume that a dir…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
7
Consider the following linear programming $(LP)$:Maximize $z=2x_1+3x_2$Such that$2x_1+x_2\le 4$$x_1+2x_2\le 5$$x_1,x_2\…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
8
Which of the following pairs of propositions are not logically equivalent?
Topic: UGC NET Computer Science Nov 2020 (Paper II)
9
How many ways are there to pack six copies of the same book into four identical boxes, where a box contains six books?
Topic: UGC NET Computer Science Nov 2020 (Paper II)
10
The number of positive integers not exceeding $100$ that are either odd or the square of an integer is _____
Topic: UGC NET Computer Science Nov 2020 (Paper II)

Next 10 Questions — UGC NET Computer Science Nov 2020 (Paper II)

Ascending by ID
1
Consider the following recursive Java function $f$ that takes two long arguments and returns a float value:public stati…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
2
The data node and name node in HADOOP are
Topic: UGC NET Computer Science Nov 2020 (Paper II)
3
Consider a relational schema$S=(U,V,W,X,Y,Z)$on which the following functional dependencies hold:$\{U\to V,\ VW\to X,\ …
Topic: UGC NET Computer Science Nov 2020 (Paper II)
4
 Consider a hypothetical machine with $3$ pages of physical memory, $5$ pages of virtual memory, and$\langle A,B,C…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
5
Consider a disk system having $60$ cylinders. Disk requests are received for cylinders $10,22,20,2,40,6,38$ in that ord…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
6
Suppose you have a Linux file system where the block size is $2K$ bytes, a disk address is $32$ bits, and an i-node con…
Topic: UGC NET Computer Science Nov 2020 (Paper II)
7
Consider a single-level page table system, with the page table stored in the memory. If the hit rate to TLB is $80\%$, …
Topic: UGC NET Computer Science Nov 2020 (Paper II)
8
Which of the following UML diagrams has a static view?
Topic: UGC NET Computer Science Nov 2020 (Paper II)
9
Modifying the software by restructuring is called
Topic: UGC NET Computer Science Nov 2020 (Paper II)
10
A company has a choice of two languages $L_1$ and $L_2$ to develop a software for their client. Number of LOC required …
Topic: UGC NET Computer Science Nov 2020 (Paper II)
Ask Your Question or Put Your Review.

loading...