Create a number of threads

Assignment Help Computer Engineering
Reference no: EM132200492

Write in Java a PID manager.

An operating system's 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; returns-1 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 threads-for example, 100-and 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 process's 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.

Reference no: EM132200492

Questions Cloud

What are the kinetic theory assumptions about ideal gases : What are the kinetic theory assumptions about ideal gases. State the ideal gas equation.
Types of possible transitions that can occur : Draw the energy level diagram of Hydrogen showing all the types of possible transitions that can occur. Show the IR,UV,VL.
Display the middle character of a string : A main method which calls the other 2 and provides any parameter data those methods require.
Write a java method to multiply two n times n matrices : Write a Java method to multiply two N times N matrices. The two matrices are received parameters. The result should be returned from the method.
Create a number of threads : Create a number of threads-for example, 100-and each threadwill request a pid, sleep for a random period of time, and then release the pid.
Find all n prime numbers that are positive integers greater : How to write a java code that take a given number n , and finds all n prime numbers that are positive integers greater .
Provide the actual recursive implementation of algorithms : A one parameter constructor that takes a File object as a parameter. The dictionary should be populated with the words stored in the file.
Write a application that implements a basic text analyzer : Write a Java application that implements a basic Text Analyzer. The Java application will analyze text stored in a text file.
Display the values of the new list on screen : Read each value from the Stack and multiply its value by 7. Store each of the new values to either a Queue (linked list) or a Priority.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write a function that removes any repeated letters

Write a main method that reads words (strings) from a file and writes the new strings (with no repeated letters, regardless of case,) to another file.

  Write a program that prints the number of quarters and dimes

Write a program that prints the number of quarters, dimes, nickels, and pennies that a customer should get back as change.

  List three operations possible for general lists

List three operations possible for general lists that are not allowed for either stacks or queues. The list is kept contiguously in an array 40 percent full.

  What constitutes a well-maintained system

What constitutes a well-maintained system, in terms of function, utility, and reliability and how does the truly effective SysAdmin ensure success?

  Describe three interfaces you interact with on a daily basis

Describe three interfaces you interact with on a daily basis. Analyze each interface you identified in Question one and assess how it adheres to Mandel's five golden rules.

  Write an assembly program that will examine an input string

Write an assembly program that will examine an input string. Assume that a string does not include more than one line.

  Devise method for implementing global time-ordered broadcast

Devise a simple method for implementing global time-ordered atomic broadcast using only unicasting.

  Similairities and differences between memory management

Discuss the similairities and differences between memory management compaction and disk compaction.

  The organization requires a domain name

find out what domain name is available for the company. Judge whether you would use a .com, .org, or .net for the Web address.The organization requires a domain name

  Analyze algorithm and show the results in order notation

Use the divide-and-conquer approach to write a recursive algorithm that finds the maximum sum in any contiguous sublist of a given list of n real values.

  Identify the product that would be best for the firm

A specialty software development firm is planning to offer one of four new software products and wishes to maximize profit, minimize risk, and increase market.

  Define some possible incremental implementation strategies

Suppose you are developing a system composed of six modules A, B, c, D, E, and F. Define some possible incremental implementation strategies for this system.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd