Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public class Accumulator { private double total: private int N: } public class T

ID: 3882966 • Letter: P

Question

public class Accumulator { private double total: private int N: } public class Transaction { private final String who: private final Date when: private final double amount: } public class FixedCapacityStackOfstrings { private String[] a = new String[C]: // stack entries private int N: // size } class INode implements Comparable { protected byte [] name: protected long modificationTime: protected long accessTime: } class INodeFile extends INode { private long header: private Block [] blocks: } class INodeDirectory extends INode { private INodeFile [] children: } public class Block implements Comparable { private long blockId: private long numBytes: private long generationStamp: } Please answer what size (e) and (f) are with at least 50 words explaining how you made the calculations and assumptions: Assuming a 64-bit CPU architecture and Java 7, given the class definitions described in Listing 1 compute the amount of memory needed by each of the following objects considering their respective assumptions: (e) INodeFile, assuming that an inode name consist of 8 chars, and that there are 3 Blocks per INodeFile. Remember to include the amount of memory required to store the Blocks in your calculation. (f) INodeDirectory, consider the same assumptions from INodeFile, and also assume that there are 10 INodeFiles per INodeDirectory. Remember to include the amount of memory required to store the INodeFiles in your calculation. Note that in all of your calculations you should assume a 64-bit CPU architecture and Java 7. Don't forget to consider the padding in your calculation.

Explanation / Answer

e) INodeFile consists of instance variables(header and blocks). INodeFile gets the properties from Inode where it consists of name, modificationtime and accesstime.

Name consists of 8 chars so its size is 8 bytes, size of modification time and accesstime are 8 bytes.

Size of header is 8 bytes, No of blocks are 3. Block consists of instance variables are blockId(8 bytes), numBytes(8 bytes) and generationStamp(8 bytes).

Note: when calculating the amount of memory required to store the object we have to consider overhead(object header) associated with the object. Every object has overhead of 16 bytes on 32-bit systems and 24 bytes on 64-bit systems.

The total amount of memory required to store the blocks=3*(8+8+8)=3*(24)+3*(24)(overhead)=72+72=144 bytes

The total amount of memory needed to store INodeFile= 8(header)+144+8(name)+8(modificationtime)+8(accesstime)+24(overhead for INode)+24(overhead for INodeFile)= 224bytes. Moreover, the memory usage is padded to multiple of 8 bytes(on 64-bit)

f) INodeDirectory gets the properties from INode where it consists of name, modificationtime and accesstime.

Name consists of 8 chars so its size is 8 bytes, size of modification time and accesstime are 8 bytes.

The amount of memory required to store INode= 8+8+8+24(overhead)=48 bytes

The total amount of memory needed to store INodeFile= 10*(8(header)+144+8(name)+8(modificationtime)+8(accesstime)+24(overhead for INode)+24(overhead for INodeFile))= 2240bytes. Moreover, the memory usage is padded to multiple of 8 bytes(on 64-bit)

So the total amount of memory required to store INodeDirectory= 48+2240+24(overhead for INodeDirectory)=2312 bytes