Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

first come first serve scheduling algorithm

  • 26-02-2004 4:42pm
    #1
    Registered Users, Registered Users 2 Posts: 264 ✭✭


    hi there im having problems with this program
    im not sure how to access the varibles i inputted...sorry for such a lame question but im c intolerent...jus a hardware buf

    //first come first serve scheduling algorithm

    #include <stdio.h>
    #include <stdlib.h>

    int ProcessCount;

    typedef struct
    {
    char name[10];
    int ProcessName;
    int ArrivalTime;
    int ProcessTime;
    int TurnAroundTime;
    int WaitingTime;
    int AverageResponseTime;
    int AverageTurnAroundTime;
    int AverageWaitingTime;
    } Process;

    void GetInputs(Process P[])
    {
    int counter, j;
    Process t;

    for(counter=0; counter<ProcessCount; counter++)
    {
    printf("\nprocess number: %d", counter+1);
    printf("\n
    \n\n");

    printf("Enter Process Name : ");
    scanf("%s",&P[counter].ProcessName);
    printf("\n");

    printf("Enter Arrival Time : ");
    scanf("%d",&P[counter].ArrivalTime);
    printf("\n");

    printf("Enter Process Time : ");
    scanf("%d",&P[counter].ProcessTime);
    printf("\n");
    }
    //sort processes in ascending order of arrival time
    for(counter=0;counter<ProcessCount-1;counter++)
    {
    for(j=counter+1;j<ProcessCount;j++)
    {
    if(P[counter].ArrivalTime>P[j].ArrivalTime)
    {
    t=P[counter];P[counter]=P[j];P[j]=t;
    }
    }
    }
    }

    void DoScheduling(Process P[])
    {
    //response time T: time that the peocess is present, finish time - arrival time

    //missed time M: T-t

    //penalty ratio P: T/t

    //response ratio R: t/T

    //calculate the waiting time

    //calculate the response time

    //calculate the turn around time

    }

    void PrintResults(Process P[])
    {
    int i=0;


    printf("Average Turn-Around Time: %d",&P.AverageTurnAroundTime);
    printf("\n");

    printf("Average waiting time: %d",&P.AverageWaitingTime);
    printf("\n");

    printf("Average response time: %d",&P.AverageResponseTime);
    printf("\n");
    }

    int main()
    {
    //int AverageTurnAroundTime;

    Process P[10];
    printf("Enter the number of Processes (maximum 10) : ");
    scanf("%d",&ProcessCount);

    printf("\n");

    GetInputs(P);
    DoScheduling(P);
    PrintResults(P);

    printf("\n");
    return 0;
    }


Comments

  • Registered Users, Registered Users 2 Posts: 629 ✭✭✭str8_away


    :confused:
    Access them in the same as you assign them.

    Maybe if you explain more what/how.here you want to access varibles we can be more help.


  • Closed Accounts Posts: 493 ✭✭muffen


    Yeah, I don't get it either.

    If you want us to help, you need to be more detailed.


  • Closed Accounts Posts: 23 Shing


    Francis, I'll show you in college tomorrow. Now stop trying to get other people to do your college assignments for you.

    Regards,
    Wai Shing


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    If you want help with assignments and college work then read the fscking FAQ! Yes, the thread that says "read before posting".

    We don't actually mind people asking for help with assignments if they ask in the right way.
    Check out this guide to asking for help .
    FREQUENTLY GIVEN ANSWER

    The most frequently given answer on the programming board is "Give us more info". So make sure that when posting a question you give as much detail as possible, including stuff you've tried that failed. If you show that you've made an effort at the problem then people are more likely to help. Asking people to write your homework without making any attempt at it will result in a PFO (Please Try Elsewhere).

    Implementing zero tolerance - I'll be banning with prejudice for violations of basic intelligence and common sense.

    Cheers,
    Al.


  • Registered Users, Registered Users 2 Posts: 3,548 ✭✭✭Draupnir


    I did the FCFS algorithm in Java not so long ago for a college assignment and man I think you are going way overboard with the code there buddy, however me and C++ dont get on so I may be wrong


  • Advertisement
Advertisement