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

  Define sentence as a sequence of words followed by a period

We define a sentence as a sequence of words followed by a period, exclamation mark, or question mark.

  Construct a finite state automata that exactly recognizes

Suppose that during document indexing we are interested in identifying all dates in the format mm/dd/yyyy.

  An asynchronous sequential logic circuit is given on page

an asynchronous sequential logic circuit is given on page by its primitive flow map i.e. initial state table where x1

  Design a simple single-channel dma controller

Design a simple, single-channel DMA controller for the 68000 using SSI and MSI logic. The DMAC has a two-wire interface to the peripheral, consisting of REQ*.

  Make multimedia presentation that incorporates 3D modelling

COMP607 Visual Effects and Animation Assignment - 3D Project. In this assignment you will create a multimedia presentation that incorporates 3D modelling

  What is the major advantage of a plc system

RELAY LADDER LOGIC is a high-level graphic computer language. What is the major advantage of a PLC system over the traditional hardwired control system?

  Calculate the evaporation rate from a snow bank

Calculate the evaporation (sublimation) rate from a snow bank if the ambient air temperature is - 23°C, solar energy is falling on the bank at a rate.

  What is the latency of this communication

A light signal is traveling through a single-mode fiber where the velocity of propagation is approximately 2.04 times 10^8 m/s.

  Which RAID technique would you suggest using

If it is important not to lose any of your data, which RAID technique would you suggest using?

  Explain the challenges auditors face as technology changes

Take a position on whether or not you would want to pursue a career as an IT auditor. Explain the key reasons why or why not. Explain the challenges auditors.

  How does robot security devices allow safer security

How does robot security devices allow effective and safer security in dangerous areas? The response must be typed, single spaced.

  Describe an instance when you heard or told a powerful

describe an instance when you heard or told a powerful story in a leadership position? how did it influence you? what

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