Giter Site home page Giter Site logo

eolatham / job-scheduler Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 2.0 47 KB

A simple job scheduler written in C that executes a specified number of non-interactive, background-compatible jobs concurrently

Makefile 1.52% C 98.48%
c unix systems-programming multithreading processes concurrency job-management queues

job-scheduler's Introduction

Job Scheduler

Author: Eric Latham

Email: [email protected]

Description

I initially wrote this program for a final project in a UNIX systems programming course taught by Dr. Purushotham Bangalore at UAB , and then I polished it.

This program is a simple job scheduler written in C that executes a specified number of non-interactive, background-compatible jobs concurrently, redirecting the output and error streams of each job to <jobID>.out and <jobID>.err, respectively.

Features

  • User input is handled flexibly with respect to whitespace.

  • The main program error stream is redirected to <executable>.err to avoid interrupting user input.

Algorithm

Divide the main program tasks into threads and execute jobs in new processes.

Input Thread (Main Thread)

Handle user input; insert new jobs and respond to commands.

Execution Thread

Execute waiting jobs concurrently.

- while true:
  - if queue is not empty and number of jobs working < concurrency:
    - take the next job off the queue
    - use a new thread to:
      - increment number of jobs working
      - update job as working
      - use a new process to complete job
      - wait for the process to finish
      - update job as complete
      - decrement number of jobs working
  - wait a second before next iteration

Instructions

To Compile

Use any of the following commands:

  • make
  • gcc -Wall -lpthread -o job_scheduler job_scheduler.c helpers.c

To Run

Use the following command:

  • ./job_scheduler CONCURRENCY
    • CONCURRENCY is an integer clipped to the range [1, 8]

Commands

  • submit COMMAND [ARGS]

    • Add a job with the specified command and arguments to the job queue to be started as soon as possible and print the job's job ID to stdout.
  • showjobs

    • List all jobs that are currently waiting or working by displaying each job's job ID and status.
  • submithistory

    • List all jobs that were completed during the current session by displaying each job's job ID, thread ID (the ID of the thread the job was completed in), command and arguments, start time, end time, and exit status.

job-scheduler's People

Contributors

eolatham avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.