(VIII-5) [10 points; 5 points each] Consider following example C structure for the RAM drive: typedef unsigned char BYTE

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

(VIII-5) [10 points; 5 points each] Consider following example C structure for the RAM drive: typedef unsigned char BYTE

Post by answerhappygod »

Viii 5 10 Points 5 Points Each Consider Following Example C Structure For The Ram Drive Typedef Unsigned Char Byte 1
Viii 5 10 Points 5 Points Each Consider Following Example C Structure For The Ram Drive Typedef Unsigned Char Byte 1 (144.87 KiB) Viewed 30 times
(VIII-5) [10 points; 5 points each] Consider following example C structure for the RAM drive: typedef unsigned char BYTE; typedef unsigned long DWORD; typedef struct_RAMDrive Manager { BYTE* pbBuffer; DWORD dwTotalSectors; pthread_mutex_t* pMutex; } RAMDrive Manager; RAMDrive Manager gMyRAMDrive; // RAM drive memory area // Total number of sectors in RAM drive // For synchronized I/O Using the above, we wrote an example RAM drive sector read function based on LBA addressing as: // Read iSectors starting from dwLBA, and return it into pcBuffer int readRAMDriveSector (DWORD dwLBA, int iSectors, char* pcBuffer) { int iRealCount = MIN ( gMyRAMDrive.dwTotalSectors - (dwLBA + iSectors), iSectors ); memcpy ( pcBuffer, gMyRAMDrive.pbBuffer + (dwLBA * 512), iRealCount * 512 ); return iRealCount; } where MIN(x, y) is a macro that will return x or y, whichever smaller. (a) Why do we need to calculate iRealCount using MINO? (b) Why are we multiplying 512 when passing arguments to the memcpy(?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply