[SOLVED] COEN436 Homework 1

60.00 $

Category: Tags: , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Homework1-fc0mwu.zip (1814.7 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (1 vote)

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.

When a process is created, the operating systems asks the PIDManager for a pid for that process.

 

Programming assignment tasks

  1. Create a new project in
  2. In the src folder create a new package called concordia.processmanagement
  3. In the new package, create the class PIDManager that will be responsible for allocating process id’s. The class should declare two constants to identify the range of possible pid values:

static final int MIN_PID = 300 static final int MAX_PID = 500

The class should implement the following methods:

void allocateMap()throws Exception—Creates and initializes a data structure for representing pids; throws Exception if unsuccessful

int allocatePid() throws Exception—Allocates and returns a pid; throws Exception if unable to allocate a pid (all pids are in use)

void releasePid(int pid)—Releases a pid

 

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 an array of bits 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 in use. (check the BitSet class in JAVA)

  1. Create a class to represent a Process Control For now, the control block should only contain the PID and the process status.
  2. Create a JAVA interface to allow operations on processes. (Right click, new Java Class and then select interface in IntelliJ)

The interface should declare the following methods of the API:

int createProcess() throws Exception                                                                                                                      Creates a process (by creating its process control block) and adds it to the ready queue. Returns the PID of the process created. Throws exception if unable to create the process (for example if no PID are available)

 

 

void terminateProcess(int pid) throws Exception                                                        Terminates the process with the specified pid. Throws exception if the process doesn’t exist.

 

  1. Create the class that implements the interface from step 5. When a process is created, it should ask for a PID to the PIDManager, creates a process control block and add it to a queue (the ready queue). When a process is terminated, it should release the PID and remove the process control block from the
  2. In the main class (outside of the processcontrol package), create three scenarios to test your implementation. For example, create a process and print its PID. Terminate that Create as many processes as ID’s available and then create one one more process, you should get an error. Create as many processes as ID’s available and then terminate one process. Create one new process, there should be no error. Create one more process. There should be an error. Terminate all processes.
  3. You will demonstrate your assignment to the TA after the due

 

[5points] BONUS: Create your own exceptions to handle errors.

Deliverable

You should submit a .zip folder with the following files

  1. A two-page pdf file including your answers to ALL questions in the
  2. A pdf file including a two-page report of the programming assignment with the following sections:
    1. High level description of the code (description of the methods/functions/threads/data structures and the flow of the program). You can use UML class and sequence diagrams or any other tool or natural language description.
    2. A detailed conclusion, discussing you Please include the answer to What problems did you face?

 

  • Homework1-fc0mwu.zip