CSCE313 Texas A & M University C++ Program PA5 Development Project Please write a c++ code and provide comments for easier understanding. Complete everythi

CSCE313 Texas A & M University C++ Program PA5 Development Project Please write a c++ code and provide comments for easier understanding. Complete everything that is required in the PDF document to be submitted. the pptx is for your reference. I can provide a video for better understanding as well. CSCE 313
Wei Zhang
Programming
Assignment 6
PA3 Review
w worker threads
DATA
REP
Data channel 1
DATA
REP
Data channel 2
DATA
REP
DATA
REP
Data
Server

DATA
REP
Data channel w
DATA
REP
• Each worker spends most of the time waiting for data
server responses (inter-process delay)
–Assume 10 sec communication delay
–1 worker can do 0.1 req/sec, 10 workers can do 1
req/sec
PA3 Review
• Each worker watches one data channel for response
–Blocking I/O: Wait till data is ready
–Low CPU utilization as most workers are waiting
• Workers are constantly switched on and off CPU
–High context switching cost
–Given x CPU cores, is there any reason to have more
than x workers?
PA6
• PA6 Method: Use one single event handler thread to
deal with the I/O for all data channels
–Avoid context switching
–Non-blocking I/O: After issuing a request, switches
to other tasks without waiting for response
–Event driven: When data from data channel i is
ready, signal an event
Event handler
DATA
REP
Data channel 1
DATA
REP
Data channel 2
DATA
REP
DATA
REP

DATA
REP
Data channel w
DATA
REP
Data
Server
What We Did in PA3
• In PA3, we called cwrite() immediately followed by a
cread() – this made a thread always until data came
back from server.
• In PA6, we will change that by issuing a bunch of
cwrite()’s and then a bunch of cread()’s
client
Experienced
delay
server
Random delay
inserted by server
PA6
client
server
Initialization: Issue w requests to make
all worker channels busy
w initial requests
keep issuing
requests till 3n
After receiving response from channel i,
issue another request to the same
channel and make it busy again
When receiving response from channel
i, how do I know the corresponding
request?
– Maintain an array of w requests, one
for each channel that remembers the
last request sent through
Event Handler
• Use select() to listen to w worker channels
file descriptor sets to check
int select(int nfds,
fd_set *readfds,
# of fds that are ready
fd_set *writefds,
fd_set *exceptfds,
struct timeval *timeout);
Set these to
NULL, because
we only care
about readfds
block for timeout long, or (NULL) indefinitely
• nfds is the highest-numbered file descriptor in any of
the three sets, plus 1, not # of fds
• We only care about read operations, set writefds,
exceptfds to NULL
fd_set





A set of file descriptors
FD_ZERO(): Initialize
FD_SET(): Add a fd to set
FD_ISSET(): Check if a fd is ready
select() will modify the fd_set data structure, so
needs to provide a new copy every time
• When select() returns, how to test which data
channels are ready?
–Use FD_ISSET() to test each file descriptor

Purchase answer to see full
attachment

Don't use plagiarized sources. Get Your Custom Essay on
CSCE313 Texas A & M University C++ Program PA5 Development Project Please write a c++ code and provide comments for easier understanding. Complete everythi
Just from $13/Page
Order Essay
Homework On Time
Calculate the Price of your PAPER Now
Pages (550 words)
Approximate price: -

Why Choose Us

Top quality papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional academic writers

We have hired a team of professional writers experienced in academic and business writing. Most of them are native speakers and PhD holders able to take care of any assignment you need help with.

Free revisions

If you feel that we missed something, send the order for a free revision. You will have 10 days to send the order for revision after you receive the final paper. You can either do it on your own after signing in to your personal account or by contacting our support.

On-time delivery

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & confidential

We use several checkers to make sure that all papers you receive are plagiarism-free. Our editors carefully go through all in-text citations. We also promise full confidentiality in all our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

You are welcome to choose your academic level and the type of your paper. Our academic experts will gladly help you with essays, case studies, research papers and other assignments.

Admissions

Admission help & business writing

You can be positive that we will be here 24/7 to help you get accepted to the Master’s program at the TOP-universities or help you get a well-paid position.

Reviews

Editing your paper

Our academic writers and editors will help you submit a well-structured and organized paper just on time. We will ensure that your final paper is of the highest quality and absolutely free of mistakes.

Reviews

Revising your paper

Our academic writers and editors will help you with unlimited number of revisions in case you need any customization of your academic papers