Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write in Java a PID manager. An operating systems pid manager is responsible for managing process identifiers. When a process is first created, it is

Write in Java a PID manager.

An operating systems pid manager is responsible for managing process identifiers. When a process is first created, it is assigned a unique pid by the pid manager. The pid is returned to the pid manager when the process completes execution, and the manager may later reassign this pid. What is most important here is to recognize that process identifiers must be unique; no two active processes can have the same pid. Use the following constants to identify the range of possible pid values: #define MIN PID 300 #define MAX PID 5000

Use any data structure of your choice to represent the availability of process identifiers. One strategy is to adopt what Linux has done and use a bitmap in which a value of 0 at position i indicates that a process id of value i is available and a value of 1 indicates that the process id is currently in use. Implement the following API for obtaining and releasing a pid: int allocate map(void)Creates and initializes a data structure for representing pids; returns1 if unsuccessful, 1 if successful int allocate pid(void)Allocates and returns a pid; returns 1 if unable to allocate a pid (all pids are in use) void release pid(int pid)Releases a pid

Write a multithreaded program that tests your solution to the PID manager. Create a number of threadsfor example, 100and each threadwill request a pid, sleep for a random period of time, and then release the pid. (Sleeping for a random period of time approximates the typical pid usage in which a pid is assigned to a new process, the process executes and then terminates, and the pid is released on the processs termination.) On UNIX and Linux systems, sleeping is accomplished through the sleep() function, which is passed an integer value representing the number of seconds to sleep.

Write the Code to ensuring that the data structure used to represent the availability of the process identifiers is safe from race conditions. Use Pthreads and mutex locks.

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_2

Step: 3

blur-text-image_3

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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions

Question

What is meant by the elastic limit for a particular object?

Answered: 1 week ago

Question

Calculate the payback period for the investment.

Answered: 1 week ago

Question

Select suitable tools to analyze service problems.

Answered: 1 week ago