Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions