Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write two programs that play a trivia game using shared memory. Include examples of your program output in a report. In order to synchronize

image text in transcribed

1. Write two programs that play a trivia game using shared memory. Include examples of your program output in a report. In order to synchronize the question-answer-result sequence, you will force processes to sleep. Create separate server and client programs (two .c files) according to the following design requirements .The server is assumed to be executed before the client. . The server creates the shared memory and writes a string to shared memory containing the trivia question and sleeps for some period of time (e.g. 10 seconds) to allow the client to get user input The client, which is started after the server, reads and displays the question from shared memory The client allows the user to type an answer and writes it to the same shared memory location, overwriting the question, and sleeps for some period of time (e.g. 10 seconds) to wait for the . . result from the server . After the server's sleep period, it reads the client's answer, displays it, and compares it to the correct answer (which is known by the server). The server writes the result message (correct or incorrect) to the same shared After the client's sleep period, it reads the result and displays it to the user memory location. * Below are examples of how your output might look (user input is in bold). The trivia question in both examples is "What is the capital of Greece?". n example #1, the client's user types the correct answer "Athens". In example #2, the client's user types the incorrect answer "London Server example #1 Sent question. Sleeping. . . Answer received: Athens Client example #1 What is the capitol of Greece? Athens Waiting for result... Correct! Server example #2 Sent question. Sleeping. . . Answer received: London Client example #2 What is the capitol of Greece? London Waiting for result... Wron

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

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions