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.

Here is the assignment we were given, we are to do this

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 #include #include #include #include #include #include #include #include #include #include #include #include #include "hist.h"

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 size

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!