Skip to content

MirImaadAli1/OS-Simulation-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OS-Simulation-Java

A multithreaded operating system simulation in Java implementing processor allocation, priority-based scheduling, and safe concurrency using locks and condition variables.

πŸš€ Overview

This project simulates core behavior of an operating system scheduler, including:

  • Process registration with priorities
  • Dynamic processor allocation
  • Preemptive scheduling
  • Blocking and signaling using Condition variables
  • Thread-safe operations with ReentrantLock

It’s designed to emulate how an OS might manage limited CPU cores and prioritize tasks while ensuring thread safety and correctness.


🧠 Features

  • βœ… Priority Queues (0–9) for handling processes by urgency
  • βœ… Multiple Processors Support (configurable dynamically)
  • βœ… Fair Locking using ReentrantLock(true)
  • βœ… Condition Variables to block and wake threads efficiently
  • βœ… Graceful Handling of process termination and scheduling

πŸ“ Project Structure

OS-Simulation-Java/
β”œβ”€β”€ OS.java               # Core operating system simulation
β”œβ”€β”€ OS_sim_interface.java# Interface definition (provided)
β”œβ”€β”€ Tests.java            # Suite of unit & functional tests
β”œβ”€β”€ Main.java             # Entry point to run tests
β”œβ”€β”€ README.md             # You are here :)

πŸ”§ How It Works

  • Registering a Process:
    Each process is assigned a unique PID and a priority from 0 (lowest) to 9 (highest).

  • Starting a Process:
    If a processor is free, it's immediately assigned. Otherwise, the process is enqueued based on its priority and blocks using Condition.await().

  • Scheduling / Terminating:
    Releases the processor, then signals the next-highest priority waiting process.

  • Concurrency Management:
    All shared state (queues, assignments) is guarded by a single ReentrantLock, ensuring correctness under multithreading.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages