Create System Operating in C-
Create System Operating in C-
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// Put the process back in the queue for the next round
process_queue_.push(current_process);
}
}
private:
std::queue<Process> process_queue_;
int next_pid_;
};
int main() {
Scheduler scheduler;
// Define some simple "tasks" (functions)
auto task1 = []() {
for (int i = 0; i < 5; ++i) {
std::cout << " Task 1: " << i << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
};
auto task2 = []() {
for (char c = 'a'; c <= 'e'; ++c) {
std::cout << " Task 2: " << c << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(75));
}
};
// Create and add processes to the scheduler
scheduler.createProcess(task1);
scheduler.createProcess(task2);
// Run the scheduler
scheduler.run();
std::cout << "All processes finished." << std::endl;
return 0;
}