Skip to content

Instantly share code, notes, and snippets.

@korrio
Created March 8, 2023 07:09
Show Gist options
  • Save korrio/a102e10120e8f73e248aa7344975ab4a to your computer and use it in GitHub Desktop.
Save korrio/a102e10120e8f73e248aa7344975ab4a to your computer and use it in GitHub Desktop.
rr.php
<?php
// Define the list of IPs
$processes = ['IP1', 'IP2', 'IP3', 'IP4', 'IP5'];
// Define the time slice for each IP
$timeSlice = 2;
// Define the current process index
$currentProcessIndex = 0;
// Define the total number of processes
$totalProcesses = count($processes);
// Run the processes in a round robin fashion
while (true) {
// Get the current process
$currentProcess = $processes[$currentProcessIndex];
// Execute the current process for the specified time slice
for ($i = 0; $i < $timeSlice; $i++) {
echo "$currentProcess is running for time slice $i\n";
}
// Move on to the next process
$currentProcessIndex = ($currentProcessIndex + 1) % $totalProcesses;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment