Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program, analogous to the Unix/Linux cat command, that uses mmap() and write) system calls (instead of read) or write)) to copy a source

image text in transcribed

Write a program, analogous to the Unix/Linux cat command, that uses mmap() and write) system calls (instead of read) or write)) to copy a source file to the screen. Use fstat() to obtain the size of the input file which can be used to size the required memory mapping. The statement to write the file contents to STDOUT is write (STDOUT_FILENO, addr, sb.st_size): where addr is the start of the mapping, gotten from mmap() and, sb. st_size is the size of the mapping returned by fstat() in the sb_struct. Write a program to create a mmap() that is shared by multiple threads. Use fstat() to obtain the size of the mapped file to size the mapping. Find out the number of logical processors (or cores) available programmatically by calling sysconf(), as shown, and display this number. int numCPU = sysconf(_SC_NPROCESSORS_ONLN): For this exercise, however, you are going to create four (4) threads only. Every thread should see the mapping. Each thread will display separate partial contents (sb.st_size/4 bytes) of the file. Finally, unmap and close the file

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

List six characteristics of annual objectives.

Answered: 1 week ago