OS Resource Optimizer is a high-performance C++ system resource management and optimization engine designed for operating system-level resource allocation, scheduling, and performance monitoring. This project demonstrates advanced systems programming concepts and real-time resource optimization algorithms.
| Challenge | Implementation | National Interest & Industry Benefit | | :— | :— | :— | | Process Scheduling | Preemptive Round Robin, SJF & MLFQ | Optimizes real-time systems in critical infrastructure | | Memory Management | Custom Best-Fit/First-Fit Allocators | Reduces memory footprint and hardware costs in datacenters | | Parallel Execution | OpenMP Multi-threading Integration | Enables high-performance computing (HPC) scalability | | Resource Stability | Deadlock Prevention Simulations | Enhances reliability for aerospace and industrial OS |
graph TD
A[Process Queue] --> B{Scheduler}
B -->|SJF/RR/Priority| C[CPU Execution]
C --> D{Memory Manager}
D -->|Alloc/Free| E[RAM Simulation]
E --> F[Performance Metrics]
style B fill:#f96,stroke:#333,stroke-width:2px
style D fill:#69f,stroke:#333,stroke-width:2px
std::unique_ptr, std::shared_ptr) for zero-leak memory management.std::optional for resource lookups, std::variant for process types, and structured bindings for metric analysis.# Clone the repository
git clone https://github.com/PkLavc/os-resource-optimizer.git
cd os-resource-optimizer
# Create build directory
mkdir build && cd build
# Configure with CMake
cmake .. -DCMAKE_BUILD_TYPE=Release
# Build the project
cmake --build . --config Release
# Run tests
ctest --output-on-failure
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
cmake .. -G "Visual Studio 16 2019" -A x64
cmake --build . --config Release
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
mingw32-make -j4
#include "core/resource_optimizer.h"
int main() {
// Initialize the optimizer
ResourceOptimizer optimizer;
// Configure optimization parameters
optimizer.setOptimizationLevel(OptimizationLevel::HIGH);
optimizer.enableParallelProcessing(true);
// Start optimization
optimizer.startOptimization();
// Monitor performance
while (optimizer.isRunning()) {
auto metrics = optimizer.getPerformanceMetrics();
std::cout << "CPU Usage: " << metrics.cpuUsage << "%" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
return 0;
}
class CustomScheduler : public Scheduler {
public:
Process* schedule(const std::vector<Process*>& readyQueue) override {
// Implement custom scheduling logic
return selectProcess(readyQueue);
}
private:
Process* selectProcess(const std::vector<Process*>& queue) {
// Custom selection algorithm
// ...
}
};
// Register custom scheduler
optimizer.registerScheduler("custom", std::make_shared<CustomScheduler>());
# config.yaml
optimization:
level: HIGH
parallel_processing: true
memory_threshold: 80
cpu_threshold: 90
scheduling:
algorithm: ROUND_ROBIN
time_slice: 100
priority_boost: true
memory:
allocation_strategy: BEST_FIT
compaction_enabled: true
virtual_memory: true
monitoring:
update_interval: 1000
log_level: INFO
metrics_enabled: true
export OPTIMIZER_LOG_LEVEL=DEBUG
export OPTIMIZER_PARALLEL_JOBS=4
export OPTIMIZER_MEMORY_LIMIT=8GB
# Run all unit tests
./build/tests/os-resource-optimizer-tests
# Run specific test suites
./build/tests/os-resource-optimizer-tests --gtest_filter="Scheduler.*"
# Generate test coverage
cmake .. -DCOVERAGE=ON
make coverage
# Run performance benchmarks
./build/benchmarks/os-resource-optimizer-bench
# Generate performance reports
./build/benchmarks/os-resource-optimizer-bench --report
# Run integration tests
ctest -L integration
# Run stress tests
ctest -L stress --timeout 300
// Enable real-time monitoring
optimizer.enableMonitoring(true);
// Get current system metrics
auto metrics = optimizer.getSystemMetrics();
std::cout << "Active Processes: " << metrics.processCount << std::endl;
std::cout << "Memory Usage: " << metrics.memoryUsage << " MB" << std::endl;
std::cout << "CPU Load: " << metrics.cpuLoad << "%" << std::endl;
// Generate performance report
auto report = optimizer.generatePerformanceReport();
std::cout << "Optimization Report:" << std::endl;
std::cout << " Efficiency: " << report.efficiency << "%" << std::endl;
std::cout << " Resource Utilization: " << report.resourceUtilization << "%" << std::endl;
std::cout << " Recommendations: " << report.recommendations.size() << std::endl;
# Create optimized production build
cmake .. -DCMAKE_BUILD_TYPE=Release -DPRODUCTION=ON
make -j$(nproc)
# Install to system
sudo make install
FROM ubuntu:20.04
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
libgtest-dev
# Copy source and build
COPY . /app
WORKDIR /app
RUN mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release && \
make -j$(nproc)
# Run the optimizer
CMD ["./build/os-resource-optimizer"]
# Create feature branch
git checkout -b feature/new-scheduler
# Make changes and commit
git add .
git commit -m "Add new scheduling algorithm"
# Push and create PR
git push origin feature/new-scheduler
Patrick - Computer Engineer To view other projects and portfolio details, visit: https://pklavc.github.io/projects.html
OS Resource Optimizer - Advanced system resource management for high-performance computing environments.