Rubrik | Onsite | System Coding I/O

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2022-03-17Added By Anonymous
Source: Link

A small requesst to you to share your experience and questions as well.


System Coding Question:

Expectation is to write a class which uses below mentioned APIs to implement. I think this has many minor cases to take care of.

1int write(void *dataPtr, size_t len); 2int read(void *dataPtr, size_t len); 3int seek(size_t location); 4// To execute C++, please define "int main()" 5// Goal: Implement byte based IO over a block based interface. 6// Consider a system that supports block based IO. 7 8// Following APIs are provided by underneath block based Interface to you: 9 10 11// int bSeek(size_t blockNum); 12// int bWrite(void *blockPtr); 13// int bRead(void *blockPtr); 14// int bBlockSize();


1// Example input: 2// seek(12) : seeks to x byte 3// write(data1, 15) 4// write(data2, 16) 5// seek(17) 6// read(data3, 2) : read 2 bytes from <seek> into data3


Comments