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

  Describe common computer- or network-related activity areas

Describe some of the common computer- or network-related activity areas that companies monitor, and the legal or privacy issues associated with that monitoring.

  Store the names of the given animals in a list

Store the names of these animals in a list, and then use a for loop to print out the name of each animal.

  Write an analysis of the skills and requirements

Write an analysis of the skills and requirements for a career in healthcare information technology, including a self-reflection of the skill development.

  How to maintain operation of the priority queue adt

Show how to maintain such references in O(1) time per operation of the priority queue ADT assuming T is implemented as a linked structure.

  Write function called describe-city that accept name of city

Write a function called describe_city () that accepts name of a city and its country. Function should print a simple sentence, such as Reykjavik is in Iceland.

  What is a mutator method and what is an accessor method

What is a mutator method? What is an accessor method? What is an implicit parameter? How does it differ from an explicit parameter?

  Generate sales-report files for set of traveling salespeople

Write a C++ program that generates sales-report files for a set of traveling salespeople.

  What approaches can you use to better understand your team

What challenges have you had or do you have understanding your team? Based on the video, what approaches can you use to better understand your team?

  How many tapes will be required to back up a hard drive

How many 100MB tapes will be required to back up a 9GB hard drive? How long will the backup process require if one tape can be filled in S minutes?

  Impact on the quality of software available for used

Will commercial software manufacturers be justified in raising their prices to make up for revenue lost to open source competitors? Do you think that strategy will be effective.

  A college course can have one or more scheduled sections

A college course might have one or more scheduled sections, or may not have a scheduled section. Attributes of COURSE include Course_ID, Course_Name, and Units.

  Analyze current european and united states industry standard

Critically analyze current European and United States industry standards or recommendations for any Information Technology (IT) area.

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