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 8638195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:40:02+00:00 2026-06-12T10:40:02+00:00

So Im just wondering about a few tips on doing a scheduler simulation. So

  • 0

So Im just wondering about a few tips on doing a scheduler simulation.

So far, I just want to input a file at the command line i.e. /.scheduler in.file

The in.file holds the following information:

./Job1.txt
./Job2.txt
./Job3.txt
./Job4.txt

Each Job .txt file has random lines of code. With only the first line being significant. The first line is starting ‘tick’ time.

Job A:

10
1fi
3sdkfj
4ksdkk
5kdkfk
6kdkjf
7dkjkfd
9dkkf
10dku

At the moment I just want to take the in.file and order the ‘Job’ files in order of their arrival tick time i.e. first line.

My code thus far:

#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>


#include "projscheduler.h"



/* I/O Files */
//static char *inputFile;
char * in;
static FILE *input;

/*Scheduled jobs indexed by PID*/
struct job list[20];

/* the next job to schedule */
//static struct job *job_next = NULL;

/* Time */
time clock;

/*Initialises job list*/
static void initialise_list(void) {
    for(int i = 0; i < sizeof(list)/sizeof(list[0]); i++) {
        list[i].parameters.pid = -1;
    }
}

/** Read and parse input from input file */
static void parse_input(void) 
{
    char    buffer[BUFSIZ];
    //int   jobs;



    initialise_list();



    while( fgets(buffer, sizeof(buffer), input) )   
    {
        pid j_pid;
        sscanf(buffer, "./%d.txt", &j_pid);

    } 

}   


int main(int argc, char **argv) 
{

    if ( (input = fopen(in, "r")) == NULL ) {
        fprintf(stderr, "cannot open %s\n", argv[1]);
    }

    parse_input(); 


    return EXIT_SUCCESS;
}

HEADER FILE:

/**
 * Simulation of a process scheduler
*/

//#ifndef SCHEDULER_H_
#define SCHEDULER_H_

#include <stddef.h>


/* types */
/** units of time */
typedef long time;
/** process identifier */
typedef int pid;

/** Information about a job of interest to the task scheduler */
struct job_data {

/* pid of this process */
    pid pid;
    /* time process starts */
    time start;
    /* time needed to finish */
    time finish;
    /* time spent processing so far */
    time scheduled;
    /* size of the process */
    size_t size;

};

struct job {

    /* Various parameters used by the scheduler */
    char job_name[BUFSIZ];
    struct job_data parameters;
    /* next job to be scheduled */
    //struct job *next;


};
  • 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-06-12T10:40:03+00:00Added an answer on June 12, 2026 at 10:40 am

    I am unsure what problems you are having exactly but I can see the following errors in the code:

    • In the initialise_list() function the for loop will be iterating too many times and going beyond the bounds the of array:

      for(int i = 0; i < sizeof(list); i++) {
      

    as sizeof(list) will return the number of bytes occupied by the array which is 20 * sizeof(struct job). Change to:

        for(int i = 0; i < sizeof(list) / sizeof(list[0]); i++) {
    
    • this is a missing left parenthesis from fopen() attempt (meaning the posted code does not compile):

      if( (input = fopen(inputfile, "r") == NULL )
      

    should be:

        if( (input = fopen(inputfile, "r")) == NULL )
    
    • proj is an initialised char* and this will mostly likely cause a segmentation fault:

      char *proj;
      sscanf(buffer, "./%s.txt", proj);
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wondering about the performance impact of copying very large php variables. For example
Just wondering about this code below... when I turn off my internet connection and
Just wondering about some practice about this; I have made a simple visual C#
I was just wondering about something. I have a frame that loads pages and
I'm new to web development and am just wondering about best practices for java
I am using .Net3.5. Just wondering my understanding about the insert, update, delete are
I was just wondering on how i go about displaying the balance for the
I'm just wondering what are you thinking about DIV-tag inside FORM-tag? I need something
I was just checking the design guidelines and wondering about the borderless buttons. I
I was just reading abit about JMS and Apache ActiveMQ. And was wondering what

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.