Calculate the size of FAT table - operating-system

Given a disk block has the size of 4096M formatted to FAT. The size of each block is 64K. Calculate the size of the FAT table.
My solution:
Number of blocks = disk size / block size = (4096 * 2^20) / (64 * 2^10) = 2^16 blocks.
Assume using FAT16, since we have 2^16 blocks -> have 2^16 entries, each entry needs to store 16 bits.
=> Size of FAT table = 2^16 * 16 = 2^20 bits = 128KB.
I'm preparing for the final exam and the funny thing is that my teacher told me to self-study virtual memory so I'm not sure that my solution and explanation are correct or not. Please help me point out if I'm doing wrong. Thanks for reading.

I've already had the answer to this question and found out I was correct. Thank you and peace out!

Related

Using Datalogger- and EepromService together

I am trying to store some data on the device that I do not want to be overwritten by when the datalogger is full. And have run into some minor issues. I was looking for the "eeprom_logbook_app" but could not find it in firmware version 1.6.2 of the device-lib.
I have defined how much space I want for my persistent data and in App.cpp I have used the LOGBOOK_MEMORY_AREA(offset, size) macro.
where I have used the size of what I want to store as the offset and set the size to be
(2097152 + 1048576) - (size of data I want to store)
as this was what was returned when I asked the sensor for the eeprom size. (The eeprom is devided between 2 ICs one with 1MB capasity and one with 2MB capacity?)
Then I remembered that there was some talk about ExtflashChunkStorage::StorageHeader being stored as the first 256 bytes in this answer.
So my question is where the data will be offset from and what is the max size I can set as size so that I can subtract the correct amount to fit my data? I presume I at least need to take another 256 bytes off from the size to get my correct storage size.
As stated in my comment I got this working the only thing you need to do is using the LOGBOOK_MEMORY_AREA(offset, size) function.
let's say you want to set aside 256 bits for your own config you could then do this:
#define RESERVED_CONFIG 256
#define TOTAL_MEMMORY_SIZE (2097152 + 1048576)
static const uint32_t offset = RESERVED_CONFIG;
static const uint32_t size = TOTAL_MEMMORY_SIZE -offset;
LOGBOK_MEMORY_AREA(offset, size);
This will set aside 256 bytes on the start of the EEPROM memory and offset the logbook to accommodate this. As a result, the logbook header will also be moved to the start of the logbook's memory area.

Size of entry of page table

I have a homework question during studying for a test:
You have a new device with logic addresses space of 32 bit and physical addresses space of 34 bit. Size of page is 8KB (2^13 B). Calculate size of page table (of single level).
There are 2^32 / 2^13 = 2^19 entries. And what is the size of entry, I have to assume that it's 4B or I have a way to calculate it?
As you have already mentioned no. of enteries will be 2^32/2^13, but the page size can be anything (predefined), also you can have operating systems supporting multiple page sizes, hence to best of my understanding you can't calculate the page size through this as it is predefined and virtual memory can be any big.
There are 2^19 entries now each of these entry will be 32 Bit wide so space occupied = (2^19) * (32) Bits

Create the maximum possible array in matlab

My PC has three RAMs (8GB, 4GB, 4GB). The memory command says that the maximum size for an array is 2045MB the same as before installing the two 4GB RAMs , I want to overcome the 2045 limitation by usage of ram space. my question is how to create the maximum possible array with my system? I use win8.
Thanks
From http://www.mathworks.com/matlabcentral/answers/91711:
To calculate the size of the array that the 'Maximum Possible array' output of MEMORY command corresponds to, simple divide by the number of bytes required by each of the array elements.
So in your case, the size of the array is
A = zeros(1, floor(2045*1024*1024 / 8);
That is a one dimensional array with the number of elements that exactly fills 2045 MB

Perl module to convert between MB/GB/TB without converting to bytes first?

I'm trying to calculate the free space on an LVM physical volume by multiplying the number of free physical extents by the extent size, for example:
3623365 free extents * 4.00 MB each = 13.8 TB
I was using Number::Format to convert the extent size to bytes and convert the results of the multiplication back to a human-readable string, but TB and higher are not supported, so I end up with the longer, less readable 14,153.8 GB.
According to the docs, the reason TB and up are not supported is because of integer overflows on 32-bit systems, which made me wonder if I should even be multiplying arbitrary large numbers without using something like Math::BigInt. I see that Number::Bytes::Human supports numbers up to YB (yottabytes), but it's still in alpha so I hesitate to use it in production code.
My next thought was, why even convert to bytes in the first place when I could calculate the free space in MB and then convert to TB? Unfortunately, it seems like neither Number::Format nor Number::Bytes::Human supports conversions from one "suffix" to another, e.g. MB -> TB. Is there an existing module that does this? I really like how Number::Format and Number::Bytes::Human handle both SI/non-SI units (MB vs. MiB), allow you to set the precision, etc. and so hesitate to roll my own solution if a similarly full-featured module already does it.
Edit: The extent size is not always in MB, nor is the free space always in TB, so I am not asking how to convert from MB to TB (that would be trivial). I am asking if there are any existing modules that can convert from one [arbitrary] suffix to another without converting to bytes first.
To convert from MB to TB w/o going through Bytes:
Number of TB = Number of MB * (Bytes in 1 TB/Bytes in 1 MB)
UPDATE:
To Generalize:
Number of new units = Number of old units * (Bytes in 1 new unit / Bytes in 1 old unit)

Main memory bandwidth measurement

I want to measure the main memory bandwidth and while looking for the methodology, I found that,
many used 'bcopy' function to copy bytes from a source to destination and then measure the time which they report as the bandwidth.
Others ways of doing it is to allocate and array and walk through the array (with some stride) - this basically gives the time to read the entire array.
I tried doing (1) for data size of 1GB and the bandwidth I got is '700MB/sec' (I used rdtsc to count the number of cycles elapsed for the copy). But I suspect that this is not correct because my RAM config is as follows:
Speed: 1333 MHz
Bus width: 32bit
As per wikipedia, the theoretical bandwidth is calculated as follows:
clock speed * bus width * # bits per clock cycle per line (2 for ddr 3
ram) 1333 MHz * 32 * 2 ~= 8GB/sec.
So mine is completely different from the estimated bandwidth. Any idea of what am I doing wrong?
=========
Other question is, bcopy involves both read and write. So does it mean that I should divide the calculated bandwidth by two to get only the read or only the write bandwidth? I would like to confirm whether the bandwidth is just the inverse of latency? Please suggest any other ways of measuring the bandwidth.
I can't comment on the effectiveness of bcopy, but the most straightforward approach is the second method you stated (with a stride of 1). Additionally, you are confusing bits with bytes in your memory bandwidth equation. 32 bits = 4bytes. Modern computers use 64 bit wide memory buses. So your effective transfer rate (assuming DDR3 tech)
1333Mhz * 64bit/(8bits/byte) = 10666MB/s (also classified as PC3-10666)
The 1333Mhz already has the 2 transfer/clock factored in.
Check out the wiki page for more info: http://en.wikipedia.org/wiki/DDR3_SDRAM
Regarding your results, try again with the array access. Malloc 1GB and traverse the entire thing. You can sum each element of the array and print it out so your compiler doesn't think it's dead code.
Something like this:
double time;
int size = 1024*1024*1024;
int sum;
*char *array = (char*)malloc(size);
//start timer here
for(int i=0; i < size; i++)
sum += array[i];
//end timer
printf("time taken: %f \tsum is %d\n", time, sum);