Question
Here is the assignment we were given, we are to do this in C language via a linux terminal. Please implement your C code in
Here is the assignment we were given, we are to do this in C language via a linux terminal.
Please implement your C code in the follwing file, also ignore the hist.h include, that is a different part of the assignment, thanks:
#include
typedef struct FileMap { unsigned char* ptr; long fsz; long msz; } FileMap;
FileMap mapFile(char* fName) { // TODO }
void destroyMap(FileMap fm) { // TODO }
int main(int argc,char* argv[]) { if (argc "); return 1; } // TODO
return 0; }
Exercise 1. Reading the file The first step is to read a potentially large file into memory to do the computation. The easiest by far is to map the entire file into your program address space. This will avoid doing file IO in terms of fgetc and gives us a nice array of bytes in memory to work with To make it easier and guide you, we provide the description of a simple ADT for a mapped file. It is (as usual) a C structune typedef struct FileMap f unsigned char* ptr: long fsz Long msz: FileMap FileMap mapFile (char* fName) void destroyMap(FileMap fm): The idea is simple. The function mapFile takes as input a file name and returns a structure describing a shared memory mapping containing the file. Note that the attributes have the following meaning ptr The pointer to the start of the memory map fsz The eract size of the file (in bytes) msz The size of the memory map in bytes. This is 4096. ] to accommodate files whose size is not a multiple of the page sizeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started