Bloomberg LP Interview Question
Financial Software DevelopersThere's no link between 32b/62b and max file size.
max file size is based on the type of inode and block structure.
Quoting an example from my lecture slides:
Example: 4.3 BSD file system
– Inode contains 12 direct block addresses
– Inode contains 1 indirect block address
– Inode contains 1 double-indirect block address
If block addrs are 4-bytes and blocks are 1024-bytes,
what is maximum file size?
– Number of block addrs per block = 1024/4 = 256
– Number of blocks mapped by direct blocks 12
– Number of blocks mapped by indirect block 256
– Number of blocks mapped by double-indirect block 256
2
= 65536
– Max file size: (12 + 256 + 65536) * 1024 = 66MB (67,383,296 bytes)
I agree to the solution above. The file size has nothing to do with how many 'bit' system it is. It only depends on the inode structure or any allocation strategy used by the file system at hand.
So what is needed to be known is the file system in use.
I guess it depends on the page table and its size...and also when he said 32bit system what he mean...it can also be its data bus size not jst addressing capacity...and virtual mem makes it look u have more physical mem than it is present...i need to brush up my concepts to ans exactly, but these are my initial thoughts...
Virtual memory allows you to have the address space of the program more than the actual physical storage, also allows you to execute many programs simultaneously.
I found these 2 articles abt virtual memory:
ualberta ca/CNS/RESEARCH/LinuxClusters/mem.html#intro
princeton edu/~unix/Solaris/troubleshoot/vm.html
These article excellently explains the virtual memory and mapping of variables from c to memory(segments).
My question here is, how to include "file" access in the virtual memory? ("file" and the "program" are 2 separate things)
IMO there's no relationship between 32/64b OS and the file size you can access. Even on 32b system you can use 64b integers (or whatever else) and access file of any size. But typically OS API use 64b numbers to address the file position.
Max file size is limited only by file system and nothing else.
The important fragment is "all at the same time". If using a read() system call, then user buffer Orr has to be provided. Likewise for an mmap() based access. To read a 5gb file at the same time, one has to provide a. 5th destination user buffer. This is not possible on a 32 bit VM system without special hacks.
The important fragment is "all at the same time". If using a read() system call, then user buffer Orr has to be provided. Likewise for an mmap() based access. To read a 5gb file at the same time, one has to provide a. 5th destination user buffer. This is not possible on a 32 bit VM system without special hacks.
Maximum file size depends on 2 things:
1. The data type of the file size variable in the inode e.g. if it is 'int file_size', then MAX_INT bytes can be the size of the file
2. The data block addressing structure inside the inode
- there are usually 9 directly addressed blocks
- 1 indirectly addressed block
- 1 double indirectly addressed block
- 1 triple indirectly addressed block
File size can be the addition of all these block sizes
The actual file size will be the minimum of 1. and 2.
5 GB can't be accessed at the same time since the max address generated by a 32-bit system will be < 5 GB. There will have to be some hacks to the VM e.g. introducing a hierarchy to expose the file as chunks.
you will find this article helpfull..
- Myth March 17, 2011codinghorror.com/blog/2007/03/dude-wheres-my-4-gigabytes-of-ram.html