You are on page 1of 1

Scenario 1

Write a client server application, suppose server has a large list of positive integers numbers,
randomly placed. Client attempts to connect to server and will send three numbers to server.
Server searches these numbers from its local list. To make searching process faster, server
divides the list into three equal parts and assign each part to a separate thread. Every thread
search in its region. If any of threads finds all three numbers then it will notify other threads to
stop searching. Server send one of following responses to client after waiting for all threads to
finish their tasks.

 All three number found in list (if all numbers matched)


 Two numbers matched (if any two numbers matched)
 One number matched (if any one number matched),
 No number matched (if no number was matched)

Scenario 2
Consider a scenario where a printer maintains count for number of pages in printing tray. At a
given time only one of two processes can be in execution state, 1. Print, 2. Update tray. These
two processes are carried out on two different threads. Print process will be given total number
of pages to print (keep in mind that printer can print only 2 pages per second), if tray is out of
pages during printing, then you have to inform process “Update Tray” to load more pages.
Process “Print” will be paused during “Update Tray” and will resume once the later process is
completed along with a test page to be printed.

Scenario 3
Suppose that there are three files named instruction.txt, Log.txt and Tax.txt shared among
Machine 1, Machine 2 (back up for Machine 1) and Server. Tax file contains data in following format
NTN#amount; NTN#amount. Suppose that a client sends a request to server for getting sum of
tax paid. Server gives a signal to machine 1 and machine 2 to start process. Machine 1 starts reading
data and stores it in a file having format linenumber#amount#status#writtenby. For
example, if Machine 1 reads line number 1 from Tax.txt it writes into Log.txt as
1#700000#P#M1 means line 1 is read by machine 1 total 70000 is tax amount, P means still work
is pending and M1 indicates machine 1. Machine 2 reads data from Log.txt file after delay of 2
seconds and keeps an update information (last line). If Machine 2 reads same data 3 times with
status as pending it means Machine 1 is down and Machine 2 starts completing left over task of
Machine 1. Server continuously reads a log.txt file if it finds status d it will send amount read from
Log.txt to client.

You might also like