Earn Higher Grades With Instant Assignment Help.Ask Question!

Operating System
(5/5)

this assignment creates the pid manager whose implementation can simply be a single class. Of course, you can create any other classes you might need to implement the pid manager.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Process ID Assignment

Overview

An operating system’s pid manager is responsible for managing process identifiers. At process creation, the pid manager assigns the process a unique pid. When the process completes execution, it returns the pid to the pid manager which in turn may later reassign this pid to another process. Chapter 3 provides a full discussion of process identifiers. What is most important here is recognizing that process identifiers must be unique; no two active processes can have the same pid.

 

Design

  1. The first task in this assignment creates the pid manager whose implementation can simply be a single class. Of course, you can create any other classes you might need to implement the pid manager. You may use any data structure of your choice to represent the availability of process identifiers. One strategy adopts Linux’s approach of 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. Use the following constants to identify the range of possible pid values: MIN_PID is 300 and MAX_PID is

 

Have your pid manager implement the following API for obtaining and releasing a pid:

  • int allocate map( ) – Creates and initializes a data structure for representing pids; returning 0 if unsuccessful or 1 if

  • int allocate pid( ) – Allocates and returns a pid; returns 1 if unable to allocate a pid, all pids are in

  • void release pid(int pid) – Releases a

 

  1. The second task in this assignment consists of writing a multithreaded program that tests your pid manager. Implementing the threads uses either extends Thread or implements Runnable. Create a number of threads where each thread requests a pid, sleeps for a random period of time, releases the pid, and then terminates. Sleeping for a random period of time approximates the typical pid usage in which a new process acquires a pid, the process executes and then terminates, releasing the pid upon its termination. Download the java file needed for the assignment. A thread sleeps by calling the SleepUtilities.nap(duration) function, passing an integer value representing the number of seconds to sleep, where duration is a randomly generated integer between 60 and 300. Before sleeping, each thread should print out (on a new line) the message, “My PID is: x.”, where x is the actual pid for the thread.

 

  1. Create a driver class and make the name of the driver class Assignment1 containing only one method:

public static void main(String args[]).

The main method itself is fairly short containing code to do the following:

  1. Create the pid manager

  2. Create 100

  3. For each thread, pass the pid manager into the thread and begin the execution of the

  4. The main method needs to keep track of the threads and take care of each thread before it can end. The methods of the Thread class you'll need for this are join() and isAlive(). If the thread is dead then execute a join on it in order to properly dispose of that thread. If the thread is still alive then move on to the next thread. The main method keeps doing this check until the last remaining thread has died and been properly

 

  1. You must declare public each class you create which means you define each class in its own

 

  1. You must declare private the data members in every class you

 

  1. You can only use extends in this assignment (extends Thread) when defining your thread class. Though, you don’t have to use “extends Thread” to define your thread class. Remember, “implements Runnable” is the other way in Java to define your thread

 

  1. Tip: Make your program as modular as possible, not placing all your code in one .java file. You can create as many classes as you need in addition to the classes described above. Methods being reasonably small follow the guidance that "A function does one thing, and does it well." You will lose a lot of points for code readability if you don’t make your program as modular as possible. But, do not go overboard on creating classes and methods. Your common sense guides your creation of classes and

 

  1. Do NOT use your own packages in your program. If you see the keyword package on the top line of any of your .java files then you created a package. Create every .java file in the src folder of your Eclipse project, if you’re using

 

  1. Do NOT use any graphical user interface code in your program!

 

  1. Do NOT type any comments in your program. If you do a good job of programming by following the advice in number 7 above then it will be easy for me to determine the task of your

Attachments:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
929 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
687 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
820 Answers Hire Me