Display the status of a process

Assignment Help Basic Computer Science
Reference no: EM13977303

//Header file declaration

#include <stdio.h>

#include <stdlib.h>

//Global variable declaration

    char newProcess[] = "New";

    char runningProcess[] = "Running";

    char waitingProcess[] = "Waiting";

    char readyProcess[] = "Ready";

    char terminatedProcess[] = "Terminating";

 

//

    /*  This method will return the state text of a given state

        i.e. if you pass 1 as argument then it will return "New"

    */

    const char * returnState(int state){

        const char *stateText;

        if(state == 0)

            stateText = "New";

        else if(state == 1)

            stateText = "Running";

        else if(state == 2)

            stateText = "Waiting";

        else if(state == 3)

            stateText = "Ready";

        else

            stateText ="Terminated";

 

        return stateText;

    }

 

    /*  This method will print the status of a given process.

        i.e. if process parentProcess[0] is passed as an argument

        then it would use the element value to determine the status.

 

    */

    void printStatus(int processNumber, int value){

        printf(" The current status of process %d is %s.n", processNumber, returnState(value));

    }

 

    /*--- Start of main function*/

    int main(void){

        //Local variable declaration

        int processCount; //this will hold the total number process

        int index; // Index for "for loop"

 

        printf("Hello! Please enter a whole number in between 0-10.n");

        scanf("%d", &processCount);

 

        //Local variable declaration

        int parentProcess[processCount];/*  This variable will store the status of each process. i.e.

                                            if parentProcess[0] = 5 then process 1 is in terminated state, etc.

                                        */

        /*  Initially every process's status would be in new state. So, you have put 1 as value in every element

            of the array. i.e. parentProcess[0] = 1 etc.

        */

        for(index = 0; index < processCount; index++){

            parentProcess[index] = 1;

            printStatus(index, parentProcess[index]);

        }

 

        /* your code goes here*/

    }

Use this code snippet as your guidance. You need to add the following options in this program

1. Give the user an option to enter different status for a process

2. Display the status of a process after a process's state has been changed by the user.

3. The program should not quit until every process's status is changed to "Terminated".

Reference no: EM13977303

Questions Cloud

How fiction contribute to the washington irving story : Choose three of the elements of fiction, such as character, setting, plot, point of view, or style, and analyze in a 750word essay how these three elements of fiction contribute to the overall theme in Washington Irving's story, "Rip Van Winkle.
Discuss ethnicity as a social construction : Discuss ethnicity as a social construction and provide recent and current examples of ethnic hostilities (including examples from India, if appropriate).
Summary and explanation of the product : Write an introductory page written by you with a summary and explanation of the product (Biopsychosocial Assessment of alcohol/Substance Abuse ). The summary will include reflection, analysis, and self assessment of learning. 2 pages. Must be free..
What is the coefficient of kinetic friction : The other end of the string is attached to a 3.60 kg block suspended in the air. When released the 3.60 kg block begins to descend with an acceleration of 3.92m/s2. What is the coefficient of kinetic friction between the 2.40 kg block and the tabl..
Display the status of a process : Use this code snippet as your guidance. You need to add the following options in this program 1. Give the user an option to enter different status for a process 2. Display the status of a process after a process's state has been changed by the user.
Women never stepped foot or acted on the stage : Unless an actor had achieved "star" status as an actor, he would often be considered low class. Women, during many of these times, were expected to be wives and mothers - definitely not actresses. If actresses were to be considered respectable, ..
Is secularization essential to development : Is secularization essential to development? Be sure to show you know what secularization is?
What does artificial forcing mean : 1) What does artificial forcing mean? 2) Why must there be struggle? 3) How could this speech influence a listener in the 20th century?
Determine the cost of goods sold and ending inventory amount : Determine the cost of goods sold and ending inventory amounts by the average, FIFO, and LIFO cost methods. Round average cost per unit to 3 decimal places, and round all other amounts to the nearest dollar. Explain why cost of goods sold is highest u..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Explain the operation of the mips andi instruction

Illustrate your answer with an appropriate example. In your answer you must provide details of the andi instruction format and of what each field in that instruction format does and how an andi instruction is identified.

  Determine the effects of path compression

Write a program to determine the effects of path compression and the various unioning strategies. Your program should process a long sequence of equivalence operations using all six of the possible strategies.

  Explain the role of banks on the money supply

1)a )Explain the role of banks on the money supply. What is money multiplier? Explain.b) If the Central Bank increases the required reserve ratio what will happen to interest rate? Using appropriate diagram, show equilibrium in the money market.

  Remote access for small offices and teleworkers

Case Study 2: Cisco's Remote Access Go to Cisco's Website and read, "How Cisco IT Provides Remote Access for Small Offices and Teleworkers", located at http://bit.ly/MkvlbA. According to the study, an IDC forecast from December 2007, expected the glo..

  What specific challenges will virtualization

In the context of security and trust, what specific challenges will virtualization and cloud computing present across the software lifecycle?  In what ways do the experts foresee the use of each of these technologies evolving in the future?

  Eliminate the transitive dependency in this relation

Vendor is functionally dependent on Compname and Compname is functionally dependent on Prodname. Eliminate the transitive dependency in this relation and form 3NF (third normal form) relations.

  Explain classic five-stage risc integer pipeline

Assume that the initial value of R3 is R2 + 496. Use the classic five-stage RISC integer pipeline and assume all memory accesses take 1 clock cycle.

  What feature in windows vista provides a permission dialog

Moving from one NTFS partition to another creates one copy of the object. The object in the new location inherits the permissions of the new location. So the newly moved file cannot have different permissions than the original.

  Part of the hipaa privacy rule

True or Flase. As a patient, your doctor must sign a HIPAA Consent and Release Form to share your ePHI or PHI with insurance providers who pay for your medical bills. This is part of the HIPAA Privacy Rule.

  The progresses report

The progresses report is a chance to highlight and discuss any issues that you are having in meeting the project plans. Discuss any changes to the original proposal and if needed propose a renegotiate plan on what is to be achieved for the project in..

  Analyze the use of gestures in ipads

Analyze the use of gestures in iPads. Address how users feel about gestures. Evaluate how users feel about the user input when it comes to filling out complicated forms on the iPad.

  Finalize a navigation system

List at least three interactive features that could be added to your site and what purpose each would serve for your site and its visitors. The form created in Part Two of this assignment can be included as one of the interactive features.

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