Skip to content

ankit-56/Task_Scheduar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Round-Robin Multithreaded Task Scheduler

This project implements a full-stack, multithreaded task scheduler using C++ for the backend engine and React (Vite) for the stunning frontend UI.

Features

  • Round-Robin Scheduling: The backend distributes task time in equal quantums. Placed tasks are executed sequentially in portions, automatically requeuing if unfinished.
  • Native OS Multithreading: The engine uses Win32 <windows.h> threading primitives (CreateThread, CONDITION_VARIABLE) to bypass older GCC compatibility limitations.
  • Headless Node.js Wrapper: A tiny Express server acts as a middleman, parsing HTTP JSON requests and piping them seamlessly into the C++ stdin/stdout.
  • Beautiful UI: Modern, sleek Glassmorphism design visualizing states of tasks ("Pending", "Running", "Completed") and active Worker threads.

Requirements

  • GCC Compiler (MinGW works perfectly!)
  • Node.js & npm (To run the frontend and the middleman server)

How to Build and Run

1. Start the Backend (C++ Engine + Node Server)

The backend requires compiling the C++ code into an engine.exe, then running the Express Node wrapper to expose it to the web.

Open a terminal and run the following:

cd backend
# Compile the C++ Engine
g++ main.cpp schedular.cpp -o engine.exe

# Install Node dependencies (Express & CORS)
npm install

# Start the wrapper server (Hooks to the C++ Engine)
node server.js

You should see: "Middleman Node Server listening on 18080."

2. Start the Frontend (React UI)

Open a second terminal and run:

cd frontend
# Install dependencies
npm install

# Start the Vite development server
npm run dev

Navigate to http://localhost:5173/ in your web browser!


Sample Tests (To See Round Robin in Action!)

Once your UI is open, try adding the following tasks very quickly to see how the worker threads juggle them:

  1. Long Task
    • Name: Database Backup
    • Duration: 8000 (ms)
  2. Short Task
    • Name: Send Email
    • Duration: 1500 (ms)
  3. Medium Task
    • Name: Process Images
    • Duration: 4000 (ms)
  4. Heavy Task
    • Name: Video Render
    • Duration: 9000 (ms)

Because there are only 3 Worker Threads, the 4th task will stay "Pending". Once the threads start ticking, they will process a maximum of 1000ms (the quantum) per task, and then swap them back to the queue if they aren't finished. You will literally see the worker threads drop and pick up different tasks on the screen!

About

A multithreaded task scheduler in C++ efficiently manages and executes multiple tasks across a pool of worker threads to optimize CPU utilization and minimize latency. It typically uses thread-safe queues, mutexes, and condition variables for concurrent task submission, scheduling, and execution.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors