Hire Experts For Answers
Order NowRelated Study Services
- Homework Answers
- Coursework writing help
- Term paper writing help
- Writing Help
- Paper Writing Help
- Research paper help
- Thesis Help
- Dissertation Help
- Case study writing service
- Capstone Project Writing Help
- Lab report Writing
- Take my online class
- Take my online exam
- Do my test for me
- Do my homework
- Do my math homework
- Online Assignment Help
- Do my assignment
- Essay Writing Help
- Write my college essay
- Write my essay for me
DESCRIPTION
Posted
Modified
Viewed
19
Hey I need help in this assignment:
You shall implement a program where several chat bots will run, each in their own thread, simultaneously but asynchronously with each other. Each bot shall write the specified text message to one, common shared resource, a file named QUOTE.txt. In order to prevent the data from getting corrupted by other bots, the bots shall use an appropriate IPC mechanism/algorithm.
You will do this by developing a project that manages multiple threads writing to a shared file (you aren’t building a chat server, the chat bots each will simply write to a shared/common file).
You must work in pairs (team of 2) unless approved by the instructor.
When your program starts, it shall do the following:
Create a file, named QUOTE.txt, in the current directory (cwd).
Have your running process write it’s pid (Process ID) followed by a Carriage Return and Newline into the file.
Close the file QUOTE.txt
Create a semaphore named FLAG which the threads will use to manage access to the file QUOTE.txt.
Create 7 threads. Use the POSIX version of threads (i.e., pthread_create())
Block/wait for all seven threads to complete their work.
Once all threads are done, destroy the semaphore, then exit gracefully, printing a friendly message to the console
Each thread shall perform the following (note, each thread is running concurrently):
Periodically (even numbered threads - once every two seconds, odd numbered threads – once every 3 seconds) get the semaphore FLAG; once the thread has FLAG, it will proceed to do the following:
Open the file QUOTE.txt and write the thread’s tid (thread id) followed by “The Quote” (followed by a Carriage Return and Newline)
Write to the console (print to stdout) “Thread is running” followed by a newline
Close the file QUOTE.txt
Release the semaphore FLAG
Repeat the above 7 times (they run a total of 8 times).
exit
You will need to use the following POSIX system calls for creating and managing the semaphores with: sem_init(), sem_wait(), sem_post(), and sem_destroy().
I will test your program by compiling it and executing it on edoras. Your program shall be written such that it compiles and executes cleanly when using the gcc, or g++ compiler You shall create a sub-directory named "a1" in your home directory. In it, you shall place your source file(s), your header file, your Makefile (see Canvas for examples on Makefiles), and a README file (see Canvas for README requirements). Your source files SHALL CONTAIN sufficient comments for making the source easy to read. Points will be taken off for poorly (or non) commented source. Name the executable "bots".
Create ~/a1 by hand.
Create source files, an include file, a Makefile, and a README file. Put them into ~/a1.
The Makefile shall create an executable named "bots" in this same directory (~/a1).
Here is a nice overview of threads [https://computing.llnl.gov/tutorials/pthreads/]
The system call "system()" will NOT be allowed
The assignment is due 1700 (5:00 PM) on Monday, 6 June 2022
TURNING IN YOUR WORK:
Your project files shall be loaded onto Assignment #1 on Canvas, in the class account of one of the team members. Be sure to write each
Make sure that all of your files (all source files, Makefile, README file, test files, etc) are in the a1 sub-directory of one of your class account
Before loading files onto Canvas, create a single zip file or a tarball (tar file) with all project files. Then, Attach File (upload it) under Assignment Submission in Assignment #1 (only one team member turns in the assignment on Canvas). Next, Attach the README file. Before submitting your project, include the names and class accounts of both team members and identify which account to be used for testing, then submit your project.
The Quote:
Even numbered threads: “Controlling complexity is the essence of computer programming.
--Brian Kernigan
Odd numbered threads: “Computer science is no more about computers than astronomy is about telescopes.”
--Edsger Dijkstra
I will attach the sample input file and sample output.
Please let me know if you can complete this assignment.
Attachments
Explanations and Answers
0
No answers posted
Post your Answer - free or at a fee
NB: Post a homework question for free and get answers - free or paid homework help.
Get answers to: Help In C Implementing Poxi Threads or similar questions only at Tutlance.
Related Questions
- Software Architecture And Design
- Software Architecture And Design
- Network Fundamentals And Routing Online Exam
- Cs Assignment (Easy & Beginner Cs Student)
- Linux (Script),Via (Vim) Will Be Great
- I Need Help For My Assignment
- I Need Help For My Assignment
- I Need Help For My Assignment
- I Need Help For My Assignment
- Mot Data Desktop Application Program
- 3D To 2D Calibration Matrix Matlab
- Data Communications Network Design
- Program Ascii Table - Data Structures
- Program Ascii Table - Data Structures
- Implementing Trading Strategy Using Python
- R Studio Exam That Is Due May 22Nd 2022
- Java Data Structures - Programming Runtime
- Java Data Structures - Programming Runtime
- Java Data Structures - Programming Runtime
- Java Data Structures - Programming Runtime
- Answer Five Computer Science Questions
- Create A Seam Carving Algorithm
- Create A Seam Carving Algorithm
- Write A One Page Summary That Highlights The History Of Computer Architecture And The Main Event. Use Apa Style
- Ai Fundamentals Past Paper, Computer Science Undergraduate
- Computer Science: Internt Of Things
- Do A Online Game Simulator Code Using Atom
- Do A Online Game Simulator Code Using Atom
- Do A Online Game Simulator Code Using Atom
- Mips Coding Assignment On Qtspim Using Notepad++ For Entry Level Computer Engineering Course
- Java Code For The Outer Method In Avltree
- Implement The Method Outer In Avltree.java Which Returns A Hashset Of The Values
- A+ (220-1002) Domain 1,2,3,4 Post-Assessment
- C++ Vendingmachine Program Need Help
- Complete Multiple Tasks With Written Responses
- Implement Basic Poker Hand Analysis In Java Through Interfaces And Arraylists
- Implement Basic Poker Hand Analysis In Java Through Interfaces And Arraylists
- Income And Expense Management App Using Mean Stack
- Income And Expense Management App Using Mean Stack
- Income And Expense Management App Using Mean Stack
- Income And Expense Management App Using Mean Stack
- In This Project, You Should Design A Date Class And Use It To Acreate Calendar Application That Has Many Features.
- Maths For Data Science Assignment
- Its A Java Gui Project That I Need Help With
- Its A Java Gui Project That I Need Help With
- Help With Cryptography Question
- Help With Cryptography Question
- Mips Coding Assignment On Qtspim Using Notepad++ For Entry Level Computer Engineering Course
- Apply Protection Of Organizational Revenue Streams
- Apply Protection Of Organizational Revenue Streams