Question: Background Modern operating systems provide features for a process to use multiple threads for parallel operations. In the class, we have learned the concepts of
Background
Modern operating systems provide features for a process to use multiple threads for parallel
operations. In the class, we have learned the concepts of multithreading models. There are
various thread libraries. POSIX Pthreads and Java Threads are widely used for creating and
managing threads. The textbook Threads Chapter gives examples of multithreaded
programs using these libraries.
Programming Language
or Java
Programming Task
In this project, you are required to create a program to simulate a web server handling jobs
from multiple clients. Your program should have "client" threads and "server" threads.
The client threads generate jobs to a job pool, and the server threads take jobs out of the pool
for processing. As the pool can only accommodate a limited number of jobs, adding and
removing jobs from the job pool must be synchronized. In specific, your program should satisfy
the following requirements:
Your program should accept five input parameters to specify a the number of client
threads, b the number of server threads, c the number of job pool entries ie the
number of jobs that can be accommodated in the poold the total number of jobs to be
generated, and e the job processing time millisecond
For example, the following command means that your program will create client threads,
server threads, a job pool that can contain up to jobs, generate jobs in total, and
each job takes milliseconds for processing by a server thread.
$serversim
Similar to the producerconsumer problem, the job pool is a buffer that needs to be
maintained in your program and shared by all client and server threads. The job pool is an
array. Each entry of the job pool array can contain a job ID which is an integer.
Each client thread generates a job each time and adds the job into the job pool, if there is
space. Each job has a unique job ID The generated job IDs must be strictly incrementing.
starting from iedots Your program needs to maintain a shared counter,
numcreatedjobs, to track how many jobs have been created.
Each server thread removes a job each time from the job pool for processing in the First
InFirstOut FIFO order. Your program should maintain a counter,
numprocessed jobs, to track how many jobs have been processed by the server threads.
To simulate the job processing time, the server thread should sleep for a period of time in
milliseconds as specified in the user's input argument.
When a client thread or a server thread addsremoves a job tofrom the job pool, it needs
to record the timestamp, the client or server thread ID the index of the job pool entry that
accommodates this job, the job ID into an event log file, named "service.log
Each record of the log file should be formatted as follows:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
