Created
March 8, 2023 07:09
-
-
Save korrio/a102e10120e8f73e248aa7344975ab4a to your computer and use it in GitHub Desktop.
rr.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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