SlideShare a Scribd company logo
1 of 2
Download to read offline
This project explores usage of the IPC in the form of shared memory. Your task is to create a
client/server pair to process CSV files by loading the text file into shared memory, allowing a
second program to parse that file for lines of text containing a matching string. You must create a
client which uses the POSIX IPC method you choose to send a command-line pro- vided file name
to the server. The server will load the contents of that file into shared memory. The client will use
threads to search the shared memory for a command-line provided search string. The client will
print each line found containing the substring to the standard output stream. If you would like to
challenge yourself with this project, make the following changes: Use a structure in the server
which allows it to signal the client as soon as it begins loading lines into memory (rather than after
it finishes). A circular queue would be an ideal structure. The goal is to allow the server to write
lines to the queues write while the threads read from the queues read pointer until one pointer
catches the other. In the client, begin writing lines to the standard output stream as soon as the
first one is found by a thread. This may be modeled as a producer/consumer where the search
threads are producers and the STDOUT writer is the consumer. The producers will likely be much
faster than the consumer, so use multiple slots each representing a line of text containing the
search string (a circular queue of strings from the producer/consumer lecture would work).
Because there is only one STDOUT, multiple consumers will not provide a speedup. CSCE 311
Project 3: IPC Page 2 of 5 Server The server is started without argument, i.e., ./csv-server If the
server does not execute as indicated, the server and correctness portions will receive 0 points.
The server is used to accept the file and search string information from the csv-client, open the
file, and write the lines of the file to the shared memory. You may hard-code the name of the
shared memory provided by the client. The server must perform as follows AND YOU MUST
DOCUMENT IN YOUR CODE WHERE EACH STEPS 24 TAKE PLACE: 1. At start, writes
"SERVER STARTED" to its STDLOG (use std::clog and std::endl from iostream if using C++). 2.
Upon receiving a file name and path (relative to the project directory) from the client, (a) It writes
CLIENT REQUEST RECEIVED to its STDLOG (use std::clog and std::endl from iostream if using
C++). 3. Opens the shared memory. After it writes "tMEMORY OPEN" to its STDLOG 4. Using the
path, Writes "tOPENING: " followed by the provided path name to the terminals STDLOG, e.g.
"tOPENING: dat/dante.txt" Opens and reads the file Writes the contents of the file to the shared
memory opened above Closes the file and writes "tFILE CLOSED" to the servers STDLOG. If
open fails, indicate to the client using the IPC method of your choosing Closes the shared memory
and writes "tMEMORY CLOSED" to the servers STDLOG stream. 5. The server need not exit
Cont. CSCE 311 Project 3: IPC Page 3 of 5 Client The client should start with the command-line
arguments./csv-client, followed by: 1. The name and path of the text file, relative to the root of the
project directory which should be searched and 2. A boolean search string for which the each line
of the file will be parsed: ./csv-client dat/bankloan1.csv prod + ind + paid If the client does not
execute as described above, the client and behavior portions will receive 0 points. The client is
used to pass the file name and path to the csv-server, search the lines of text transferred via
shared memory, and count the number of lines of text found, while printing each line and its count
to its standard output stream. You may hard-code the name of the shared memory provided by the
client. The client must behave as follows AND YOU MUST DOCUMENT IN YOUR CODE WHERE
EACH STEP TAKES PLACE: 1. Creates a shared memory location and initializes with any
necessary structures. I recommend using one or more character arrays of fixed size as a structure
to hold the lines of text. Use the shared memory as a means of transmission, not storage. 2.
Sends the text file name and path to the server. I recommend using the shared memory you
created. 3. Copies the contents of the file, via shared memory, to local storage. I recommend
writing into an std::vector<std::string> using std::string(const char *, std::size t) and
std::vector::push back 4. Creates four threads, each of which; Process 14 of the lines of the
shared memory to Find any lines containing the search expression 5. The client uses the results of
the threads search to write all lines of text found to its STDOUT as follows: The client must begin
each line found with a count starting from 1 and must use a tab character (t) after the count, e.g., 1
t 7, 193100, 73200, 2.64, 38, professional, house, ftb, repay 2 t 9, 83000, 62500, 1.33, 30,
professional, house, ftb, repay 3 t 18, 162700, 77400, 2.10, 37, professional, house, ftb, repay
Note that the t should be an actual tab character. If the server was unable to open the file, writes
INVALID FILE to its STDERR (use std::cerr and std::endl from iostream if using C++). 6. Destroys
the shared memory location. 7. Terminates by returning 0 to indicate a nominative exit status
Cont. CSCE 311 Project 3: IPC Page 4 of 5 Notes Client Your client should create and destroy
your shared memory. See shm open and shm unlink below. If your client does not destroy the
shared memory, subsequent runs will fail and you will lose a substantial amount of points.
Consider the barrier problem for signalling the server from the client. A named POSIX semaphore
allows processes access to multi-process synchronization. You might hard-code the named
semaphore into your client or have your server pass its name with IPC. Your client likely will not
create or destroy named semaphores. It will connect to semaphores created by your server.
Server Your server should create and destroy any named semaphores used to synchronize the
server and client. Given that your server will be killed with CTRL + t, you will only be able to
destroy a named semaphore by setting up a signal handler using void (*signal(int sig, void
(*func)(int))(int) to destroy the semaphore. Your second option is to simply attempt to destroy any
semaphore before you create it.
NotethatyourexpectationisanerrorEINVAL(semisnotavalidsemaphore)ifthesemaphore does not
currently exist. THAT IS A GOOD THING, in this case. Continue past this error and initialize the
semaphore with the named used to destroy it. The start process for your server will like proceed
as follows: 1. Create any necessary semaphoresone of which should be the barrier 2. Do the
following forever: (a) Lock the barrier semaphore (b) Attempt to acquire the locked barrier
semaphoreeffectively blocking until the client unlocks it (c) Connect to the shared memory
initialized by the client (d) Use shared memory or any other IPC to get file name/path from client
(e) Transfer file via shared memory structure Shared memory structure You may store anything in
shared memory. For example you might store a structure as follows: Shared Memory Struct1 path
length : const static std::size t path : const char[path length] line length : const static std::size t line
: const char[line length] Assuming the client places the file path in the correct member before
raising the barrier blocking the server, the server may simply read the file path from the shared
memory. You should calculate the size of the path and line such that your struct is some number
of pages in memory. No matter what you request, you will get at least one page. PROVIDE CODE
IN C++ WITH HEADER/SOURCE FILES AND A FUNCTIOING MAKEFILE.

More Related Content

Similar to This project explores usage of the IPC in the form of shared.pdf

MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmenMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
VannaSchrader3
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docxMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
alfredacavx97
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorial
hughpearse
 
15network Programming Clients
15network Programming Clients15network Programming Clients
15network Programming Clients
Adil Jafri
 
Network Programming Clients
Network Programming ClientsNetwork Programming Clients
Network Programming Clients
Adil Jafri
 
BACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docxBACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docx
wilcockiris
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project Report
Kavita Sharma
 
CSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docxCSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docx
mydrynan
 
Please do ECE572 requirementECECS 472572 Final Exam Project (W.docx
Please do ECE572 requirementECECS 472572 Final Exam Project (W.docxPlease do ECE572 requirementECECS 472572 Final Exam Project (W.docx
Please do ECE572 requirementECECS 472572 Final Exam Project (W.docx
ARIV4
 
1-Information sharing 2-Computation speedup3-Modularity4-.docx
1-Information sharing 2-Computation speedup3-Modularity4-.docx1-Information sharing 2-Computation speedup3-Modularity4-.docx
1-Information sharing 2-Computation speedup3-Modularity4-.docx
SONU61709
 
Process Synchronization Producer-Consumer ProblemThe purpos.docx
Process Synchronization Producer-Consumer ProblemThe purpos.docxProcess Synchronization Producer-Consumer ProblemThe purpos.docx
Process Synchronization Producer-Consumer ProblemThe purpos.docx
stilliegeorgiana
 

Similar to This project explores usage of the IPC in the form of shared.pdf (20)

Dot net interview questions and asnwers
Dot net interview questions and asnwersDot net interview questions and asnwers
Dot net interview questions and asnwers
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streaming
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmenMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docxMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
 
Chat server
Chat server Chat server
Chat server
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorial
 
Chapter 6-Remoting
Chapter 6-RemotingChapter 6-Remoting
Chapter 6-Remoting
 
ARM Embeded_Firmware.pdf
ARM Embeded_Firmware.pdfARM Embeded_Firmware.pdf
ARM Embeded_Firmware.pdf
 
NP-lab-manual.docx
NP-lab-manual.docxNP-lab-manual.docx
NP-lab-manual.docx
 
NP-lab-manual (1).pdf
NP-lab-manual (1).pdfNP-lab-manual (1).pdf
NP-lab-manual (1).pdf
 
NP-lab-manual.pdf
NP-lab-manual.pdfNP-lab-manual.pdf
NP-lab-manual.pdf
 
15network Programming Clients
15network Programming Clients15network Programming Clients
15network Programming Clients
 
Network Programming Clients
Network Programming ClientsNetwork Programming Clients
Network Programming Clients
 
Advanced Java Topics
Advanced Java TopicsAdvanced Java Topics
Advanced Java Topics
 
BACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docxBACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docx
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project Report
 
CSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docxCSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docx
 
Please do ECE572 requirementECECS 472572 Final Exam Project (W.docx
Please do ECE572 requirementECECS 472572 Final Exam Project (W.docxPlease do ECE572 requirementECECS 472572 Final Exam Project (W.docx
Please do ECE572 requirementECECS 472572 Final Exam Project (W.docx
 
1-Information sharing 2-Computation speedup3-Modularity4-.docx
1-Information sharing 2-Computation speedup3-Modularity4-.docx1-Information sharing 2-Computation speedup3-Modularity4-.docx
1-Information sharing 2-Computation speedup3-Modularity4-.docx
 
Process Synchronization Producer-Consumer ProblemThe purpos.docx
Process Synchronization Producer-Consumer ProblemThe purpos.docxProcess Synchronization Producer-Consumer ProblemThe purpos.docx
Process Synchronization Producer-Consumer ProblemThe purpos.docx
 

More from adinathfashion1

This is my visual studio C code how do I make it so that w.pdf
This is my visual studio C code how do I make it so that w.pdfThis is my visual studio C code how do I make it so that w.pdf
This is my visual studio C code how do I make it so that w.pdf
adinathfashion1
 
This problem is referred to as Exon chaining in bioinformati.pdf
This problem is referred to as Exon chaining in bioinformati.pdfThis problem is referred to as Exon chaining in bioinformati.pdf
This problem is referred to as Exon chaining in bioinformati.pdf
adinathfashion1
 
This project is broken up into Windows and Mac versions lis.pdf
This project is broken up into Windows and Mac versions lis.pdfThis project is broken up into Windows and Mac versions lis.pdf
This project is broken up into Windows and Mac versions lis.pdf
adinathfashion1
 
THis is from an Applied Mixed Models class Answer just part.pdf
THis is from an Applied Mixed Models class Answer just part.pdfTHis is from an Applied Mixed Models class Answer just part.pdf
THis is from an Applied Mixed Models class Answer just part.pdf
adinathfashion1
 
Title Media culture Objectives 1 To apply aseptic techniq.pdf
Title Media culture Objectives 1 To apply aseptic techniq.pdfTitle Media culture Objectives 1 To apply aseptic techniq.pdf
Title Media culture Objectives 1 To apply aseptic techniq.pdf
adinathfashion1
 
TitleInvestigating the effect of counterfeit permits on the.pdf
TitleInvestigating the effect of counterfeit permits on the.pdfTitleInvestigating the effect of counterfeit permits on the.pdf
TitleInvestigating the effect of counterfeit permits on the.pdf
adinathfashion1
 

More from adinathfashion1 (20)

This is based on lab activity in week 34 You will explore t.pdf
This is based on lab activity in week 34 You will explore t.pdfThis is based on lab activity in week 34 You will explore t.pdf
This is based on lab activity in week 34 You will explore t.pdf
 
This is my visual studio C code how do I make it so that w.pdf
This is my visual studio C code how do I make it so that w.pdfThis is my visual studio C code how do I make it so that w.pdf
This is my visual studio C code how do I make it so that w.pdf
 
This problem is referred to as Exon chaining in bioinformati.pdf
This problem is referred to as Exon chaining in bioinformati.pdfThis problem is referred to as Exon chaining in bioinformati.pdf
This problem is referred to as Exon chaining in bioinformati.pdf
 
This project is broken up into Windows and Mac versions lis.pdf
This project is broken up into Windows and Mac versions lis.pdfThis project is broken up into Windows and Mac versions lis.pdf
This project is broken up into Windows and Mac versions lis.pdf
 
Tim and Stephanie are devastated when they find out their ne.pdf
Tim and Stephanie are devastated when they find out their ne.pdfTim and Stephanie are devastated when they find out their ne.pdf
Tim and Stephanie are devastated when they find out their ne.pdf
 
THis is from an Applied Mixed Models class Answer just part.pdf
THis is from an Applied Mixed Models class Answer just part.pdfTHis is from an Applied Mixed Models class Answer just part.pdf
THis is from an Applied Mixed Models class Answer just part.pdf
 
This is not working for me at allAnd I cannot edit anythi.pdf
This is not working for me at allAnd I cannot edit anythi.pdfThis is not working for me at allAnd I cannot edit anythi.pdf
This is not working for me at allAnd I cannot edit anythi.pdf
 
This is false please explain Assuming that the reserve req.pdf
This is false please explain Assuming that the reserve req.pdfThis is false please explain Assuming that the reserve req.pdf
This is false please explain Assuming that the reserve req.pdf
 
This is NOT TRUE concerning courtship sounds Question 2 opt.pdf
This is NOT TRUE concerning courtship sounds Question 2 opt.pdfThis is NOT TRUE concerning courtship sounds Question 2 opt.pdf
This is NOT TRUE concerning courtship sounds Question 2 opt.pdf
 
This is what I got for 54 but Im unsure if its right Prepa.pdf
This is what I got for 54 but Im unsure if its right Prepa.pdfThis is what I got for 54 but Im unsure if its right Prepa.pdf
This is what I got for 54 but Im unsure if its right Prepa.pdf
 
This PNF technique starts with the same process as the the h.pdf
This PNF technique starts with the same process as the the h.pdfThis PNF technique starts with the same process as the the h.pdf
This PNF technique starts with the same process as the the h.pdf
 
This is where you set up the project infrastructure to help .pdf
This is where you set up the project infrastructure to help .pdfThis is where you set up the project infrastructure to help .pdf
This is where you set up the project infrastructure to help .pdf
 
This is a true case study A woman kept coming to the doctor.pdf
This is a true case study A woman kept coming to the doctor.pdfThis is a true case study A woman kept coming to the doctor.pdf
This is a true case study A woman kept coming to the doctor.pdf
 
To answer Questions 14 and 15 read the article Britain.pdf
To answer Questions 14 and 15 read the article Britain.pdfTo answer Questions 14 and 15 read the article Britain.pdf
To answer Questions 14 and 15 read the article Britain.pdf
 
To adhere to Endangered Species Act ESA guidelines the Fi.pdf
To adhere to Endangered Species Act ESA guidelines the Fi.pdfTo adhere to Endangered Species Act ESA guidelines the Fi.pdf
To adhere to Endangered Species Act ESA guidelines the Fi.pdf
 
Title Media culture Objectives 1 To apply aseptic techniq.pdf
Title Media culture Objectives 1 To apply aseptic techniq.pdfTitle Media culture Objectives 1 To apply aseptic techniq.pdf
Title Media culture Objectives 1 To apply aseptic techniq.pdf
 
TitleInvestigating the effect of counterfeit permits on the.pdf
TitleInvestigating the effect of counterfeit permits on the.pdfTitleInvestigating the effect of counterfeit permits on the.pdf
TitleInvestigating the effect of counterfeit permits on the.pdf
 
Tketici talebindeki kk deiiklikler aadaki nedenlerle ve.pdf
Tketici talebindeki kk deiiklikler aadaki nedenlerle ve.pdfTketici talebindeki kk deiiklikler aadaki nedenlerle ve.pdf
Tketici talebindeki kk deiiklikler aadaki nedenlerle ve.pdf
 
Titanic Project Management Blunders Links to an external s.pdf
Titanic  Project Management Blunders Links to an external s.pdfTitanic  Project Management Blunders Links to an external s.pdf
Titanic Project Management Blunders Links to an external s.pdf
 
This is my table met Mry anlea Nole isch studein las diru ev.pdf
This is my table met Mry anlea Nole isch studein las diru ev.pdfThis is my table met Mry anlea Nole isch studein las diru ev.pdf
This is my table met Mry anlea Nole isch studein las diru ev.pdf
 

Recently uploaded

Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 

Recently uploaded (20)

Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 

This project explores usage of the IPC in the form of shared.pdf

  • 1. This project explores usage of the IPC in the form of shared memory. Your task is to create a client/server pair to process CSV files by loading the text file into shared memory, allowing a second program to parse that file for lines of text containing a matching string. You must create a client which uses the POSIX IPC method you choose to send a command-line pro- vided file name to the server. The server will load the contents of that file into shared memory. The client will use threads to search the shared memory for a command-line provided search string. The client will print each line found containing the substring to the standard output stream. If you would like to challenge yourself with this project, make the following changes: Use a structure in the server which allows it to signal the client as soon as it begins loading lines into memory (rather than after it finishes). A circular queue would be an ideal structure. The goal is to allow the server to write lines to the queues write while the threads read from the queues read pointer until one pointer catches the other. In the client, begin writing lines to the standard output stream as soon as the first one is found by a thread. This may be modeled as a producer/consumer where the search threads are producers and the STDOUT writer is the consumer. The producers will likely be much faster than the consumer, so use multiple slots each representing a line of text containing the search string (a circular queue of strings from the producer/consumer lecture would work). Because there is only one STDOUT, multiple consumers will not provide a speedup. CSCE 311 Project 3: IPC Page 2 of 5 Server The server is started without argument, i.e., ./csv-server If the server does not execute as indicated, the server and correctness portions will receive 0 points. The server is used to accept the file and search string information from the csv-client, open the file, and write the lines of the file to the shared memory. You may hard-code the name of the shared memory provided by the client. The server must perform as follows AND YOU MUST DOCUMENT IN YOUR CODE WHERE EACH STEPS 24 TAKE PLACE: 1. At start, writes "SERVER STARTED" to its STDLOG (use std::clog and std::endl from iostream if using C++). 2. Upon receiving a file name and path (relative to the project directory) from the client, (a) It writes CLIENT REQUEST RECEIVED to its STDLOG (use std::clog and std::endl from iostream if using C++). 3. Opens the shared memory. After it writes "tMEMORY OPEN" to its STDLOG 4. Using the path, Writes "tOPENING: " followed by the provided path name to the terminals STDLOG, e.g. "tOPENING: dat/dante.txt" Opens and reads the file Writes the contents of the file to the shared memory opened above Closes the file and writes "tFILE CLOSED" to the servers STDLOG. If open fails, indicate to the client using the IPC method of your choosing Closes the shared memory and writes "tMEMORY CLOSED" to the servers STDLOG stream. 5. The server need not exit Cont. CSCE 311 Project 3: IPC Page 3 of 5 Client The client should start with the command-line arguments./csv-client, followed by: 1. The name and path of the text file, relative to the root of the project directory which should be searched and 2. A boolean search string for which the each line of the file will be parsed: ./csv-client dat/bankloan1.csv prod + ind + paid If the client does not execute as described above, the client and behavior portions will receive 0 points. The client is used to pass the file name and path to the csv-server, search the lines of text transferred via shared memory, and count the number of lines of text found, while printing each line and its count to its standard output stream. You may hard-code the name of the shared memory provided by the client. The client must behave as follows AND YOU MUST DOCUMENT IN YOUR CODE WHERE EACH STEP TAKES PLACE: 1. Creates a shared memory location and initializes with any
  • 2. necessary structures. I recommend using one or more character arrays of fixed size as a structure to hold the lines of text. Use the shared memory as a means of transmission, not storage. 2. Sends the text file name and path to the server. I recommend using the shared memory you created. 3. Copies the contents of the file, via shared memory, to local storage. I recommend writing into an std::vector<std::string> using std::string(const char *, std::size t) and std::vector::push back 4. Creates four threads, each of which; Process 14 of the lines of the shared memory to Find any lines containing the search expression 5. The client uses the results of the threads search to write all lines of text found to its STDOUT as follows: The client must begin each line found with a count starting from 1 and must use a tab character (t) after the count, e.g., 1 t 7, 193100, 73200, 2.64, 38, professional, house, ftb, repay 2 t 9, 83000, 62500, 1.33, 30, professional, house, ftb, repay 3 t 18, 162700, 77400, 2.10, 37, professional, house, ftb, repay Note that the t should be an actual tab character. If the server was unable to open the file, writes INVALID FILE to its STDERR (use std::cerr and std::endl from iostream if using C++). 6. Destroys the shared memory location. 7. Terminates by returning 0 to indicate a nominative exit status Cont. CSCE 311 Project 3: IPC Page 4 of 5 Notes Client Your client should create and destroy your shared memory. See shm open and shm unlink below. If your client does not destroy the shared memory, subsequent runs will fail and you will lose a substantial amount of points. Consider the barrier problem for signalling the server from the client. A named POSIX semaphore allows processes access to multi-process synchronization. You might hard-code the named semaphore into your client or have your server pass its name with IPC. Your client likely will not create or destroy named semaphores. It will connect to semaphores created by your server. Server Your server should create and destroy any named semaphores used to synchronize the server and client. Given that your server will be killed with CTRL + t, you will only be able to destroy a named semaphore by setting up a signal handler using void (*signal(int sig, void (*func)(int))(int) to destroy the semaphore. Your second option is to simply attempt to destroy any semaphore before you create it. NotethatyourexpectationisanerrorEINVAL(semisnotavalidsemaphore)ifthesemaphore does not currently exist. THAT IS A GOOD THING, in this case. Continue past this error and initialize the semaphore with the named used to destroy it. The start process for your server will like proceed as follows: 1. Create any necessary semaphoresone of which should be the barrier 2. Do the following forever: (a) Lock the barrier semaphore (b) Attempt to acquire the locked barrier semaphoreeffectively blocking until the client unlocks it (c) Connect to the shared memory initialized by the client (d) Use shared memory or any other IPC to get file name/path from client (e) Transfer file via shared memory structure Shared memory structure You may store anything in shared memory. For example you might store a structure as follows: Shared Memory Struct1 path length : const static std::size t path : const char[path length] line length : const static std::size t line : const char[line length] Assuming the client places the file path in the correct member before raising the barrier blocking the server, the server may simply read the file path from the shared memory. You should calculate the size of the path and line such that your struct is some number of pages in memory. No matter what you request, you will get at least one page. PROVIDE CODE IN C++ WITH HEADER/SOURCE FILES AND A FUNCTIOING MAKEFILE.