Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use Java language to write this program An operating systems pid manager is responsible for managing process identifiers. When a process is first created, it
Use Java language to write this program
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. Process identifiers must be unique. No two active processes may have the same pid.
Use the following constants to identify the range of possible pid values:
# define min_pid 300
# define max_pid 5000
You may 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 bit map in which a value of 0 at position / indicates that a process id of value / is available and a value of 1 indicates that the process id is currently is use
- Implement the following api for obtaining and releasing a pid
. Int allocate_map(void)- creates and initializers a data structure for representing pids; returns-1 if unsuccessful and 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. You will create several threads- for example, 100 and each thread will request a pid, sleep for a random period of time, and then release the pid.(Sleeping for a random period approximates the typical pid usage in which a pid usage in which a pid is assigned to a new process, the process executes and terminates, and the pid is released on the process termination)
On Unix and Linux system, sleeping is accomplished through the sleep() function, which is passed an integer value representing the number of seconds to sleep.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started