Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:37:09+00:00 2026-05-30T21:37:09+00:00

While programming a CPU Scheduling in ANSI C for a linux environment, I have

  • 0

While programming a CPU Scheduling in ANSI C for a linux environment, I have not been able to calculate the wait time for each queued process. Basically, I need to run 20+ processes with 4 cpus, and measure the time it takes for each process, average time it takes, CPU consumption, etc.

Here is an analogy for the process that I am trying to code:

Click me for the image

The image I drew was trying to simplify my problems…
but this is a first come first serve CPU schedualer,
counter A is the CPU burst, counter B is the Device Burst,
line 1 is Ready Queue, line 2 is Device Queue…

Till now, I’m able to output the tasks into an array, but for my assignment I need to find out how long it took for each of the people to wait, the turn around time for each processes, and their average times.

Each person struct have an “arrivalTime” and can be changed anytime
Each person struct also have an array of time required at each counter “timeRequired[]”, it’s alternating, index 0 is for counter A, index 1 is for counter B, index 2 is for A again.
Each person struct have an array pointer for the timeRequired[], “arrayPointer”

The picture I drew says seconds, but it is actually any unit of time, an integer number,
I don’t really need the actual time clock…

What I did so far is I created 2 thread function, 1 for counterA and 1 for counterB,
and when ever A finished serving a person in line, A will stuff the person to B line,
when ever B finished a person, it will stuff it into the A line.

I feel like everything is there for me already, but I really dont know what I need to do from here on to calculated their wait times…

Or is there a easier solution than using threads?

The professor gave us 2 files

the helper methods

[http://pastebin.com/qF7nQsUR%5D

the header file

[http://pastebin.com/nQQNXnmq%5D

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:37:11+00:00Added an answer on May 30, 2026 at 9:37 pm

    I’d approach it this way:

    Figure out how to encode the input. The program needs to have the input “person 1 needs…” available to it in some way.
    These definitions can work:

    struct need {
       int person_id, counter_id, duration
    };
    struct need needs[] = {
       { 1, COUNTER_A, 500 },
       { 1, COUNTER_B, 200 },
    ...
    };
    

    Next, you need to keep track of where each person is at any time.
    This structure can describe what a person’s doing now:

    struct person_activity {
        int person_id;
        struct need *activity;
        int start_time;
    }
    

    An array of these can describe what each is doing at any tie

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What specific techniques have you found to learn keyboard shortcuts while programming? I don't
While not entirely programming related. I recently purchased a SSL certificate, and during the
i've been programming a while in D (http://www.digitalmars.com/d/) now. I prefer it to Java
While this many not seem like a programming question directly, it impacts my development
This has always been on my mind while programming, so I thought I'd spit
Another question in large scale programming: I have a job queue with time stamps
I have been tinkering with BSP trees for a while now and am also
I have been considering taking the plunge and installing Linux on my Playstation 3.
I have been reading Wikipedia's article on K programming language and this is what
Hey, while programming stuff, I have found that it is often very helpful to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.