acsicuib / YAFS

Yet Another Fog Simulator (YAFS)
MIT License
98 stars 72 forks source link

Task Scheduling Algorithms #51

Closed sanket099 closed 2 years ago

sanket099 commented 3 years ago

Hi, I had just started working with YAFS and wanted to know how and where to implement simple task scheduling algorithms (FCFS, SJF, Round Robin) in any example file. I would be really thankful for any help or suggestions. @wisaaco

ndganesan commented 2 years ago

Please share some example program it will helpful for us

wisaaco commented 2 years ago

Hi, I forget this issue, sorry for that.

Task request execution in the service queue follows a FIFO scheduling. It's an internal functionality of the simulator that it's complex to change since the queue is an abstraction. Really, the requests in the service queue are managed by the last network link. It's a race condition due to network traffic, a FIFO. We use FIFO scheduling in all our approaches using YAFS.

The code is in the file: https://github.com/acsicuib/YAFS/blob/YAFS3/src/yafs/core.py Lines 237-241.

So, one way, to implement another strategy is to control the requests stored in self.consumer_pipes[pipe_id]. Each service deployed in the infrastructure has a pipe_id (line 838). And the service process wakes up when it has notifications from its pipe (lines 584-...):

while not self.stop and self.des_process_running[ides]:
  if self.des_process_running[ides]:
     msg = yield self.consumer_pipes["%s%s%i"%(app_name,module,ides)].get()

At that moment, you could apply some criteria to execute another request that was stored in the pipe.

Best