Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(a) What might have been the intention of the author of this program? (b) What h

ID: 3693094 • Letter: #

Question

(a) What might have been the intention of the author of this program?

(b) What happens if you run this program? How could we fix these problems?

(c) What could happen if you run the version debugged in part (b) using a thread library based on the m-to-1 threading model?

(d) What is your overall assessment of this program? Is this a reasonable approach?

#include #include #include #de fine READ END 0 #de fine WRITE END 1 #de fine MAXBUFSIZ 100 int mypipe [2]: static void *thread func (void* arg) char buffer [MAXBUFSIZ]; close (mypipe [READ_END]); sprintf (buffer, "I am the child thread "); write (mypipe [WRITE_END], buffer, strlen (buffer)); close (mypipe [WRITE_END]); return (void *)NULL; main () pthread t tid; int len; char buffer [MAXBUFSIZ]; pipe (mypipe); pthread create (&tid;, NULL, thread func, NULL) : close (mypipe [WRITE_END]); read (mypipe [READ_END], buffer, MAXBUFSIZ); printf("%s ", buffer); close (mypipe [READ_END]);

Explanation / Answer

Answer for Question:

The above given program after reading that.

This Reader Writers Problem.

Part A:
This program intention one writer can write and multiple readers can the read data written by one writer.

Part B:

if you not run this program you might need provide the synchronous between reader and writer

Part c:

If you use the m to 1 threading model multiple writers one reader will be present.

Part D:
Overally the above program is using for Reader Writers problem using threading mechanism