RRScheduler

RRScheduler

The Round Robin scheduler ensures fair distribution of processing time among tasks by limiting each task's execution time and cycling through all tasks.

Key Features

  • Configurable time slice per task (default: 1 second)

  • Fair CPU time distribution

  • Support for suspending and resuming long-running tasks

  • Preemptive scheduling

Core Functions

def _execute_syscall(self, syscall, executor, syscall_type):
    try:
        syscall.set_time_limit(self.time_slice)
        syscall.set_status("executing")
        self.logger.log(f"{syscall.agent_name} is executing {syscall_type} syscall.\n", "executing")
        syscall.set_start_time(time.time())

        response = executor(syscall)
        syscall.set_response(response)
        
        if response.finished:
            syscall.set_status("done")
            log_status = "done"
        else:
            syscall.set_status("suspending")
            log_status = "suspending"

        syscall.set_end_time(time.time())
        syscall.event.set()
        
        self.logger.log(
            f"{syscall_type} syscall for {syscall.agent_name} is {log_status}. Thread ID: {syscall.get_pid()}\n",
            log_status
        )
        
        return response
    # Error handling omitted for brevity

Last updated