Scheduler
newInteractiveProcess.cpp
Go to the documentation of this file.
1 
10 #include "newInteractiveProcess.h"
11 
12 #include <fstream>
13 
14 #include <utils/randomGenerator.h>
15 
16 #include <scheduler/system.h>
17 #include <scheduler/process.h>
19 
20 #include "eventList.h"
21 
22 using namespace Scheduler;
23 
24 
26 {
27  task = createTask();
28  std::ofstream file;
29  file.open("processes.txt", std::ios_base::app);
30  task->print(file);
31  file.close();
33  scheduleNextEvent();
34  print();
36  return;
37 }
38 
40 {
41  return "New interactive process";
42 }
43 
44 std::shared_ptr<Process> NewInteractiveProcess::createTask()
45 {
46  double cpuLambda = 1.0/5.0;
47  double ioLambda = 1.0/10.0;
48  return Process::createProcess(cpuLambda, ioLambda);
49 }
50 
51 
52 void NewInteractiveProcess::scheduleNextEvent()
53 {
54  if (!renew)
55  return;
57  //The mean duration of a process is nbBursts*(5+10) = 150.
58  double lambda = 1.0/150.0;
59  double interval;
60  do
61  {
62  interval = list->getRandomGenerator()->drawExp(lambda);
63  } while(interval >= std::numeric_limits<double>::infinity());
64  std::shared_ptr<Event> e = std::make_shared<NewInteractiveProcess>(time+interval, false);
65  list->insert(e);
66 }
67 
68 
69 
std::shared_ptr< Process > task
Definition: event.h:60
virtual void print()
print information about the event
Definition: event.cpp:41
Utils::RandomGenerator * getRandomGenerator()
get the random generator
Definition: eventList.cpp:42
std::string getName() override
get the name of the event
void queueProcess(std::shared_ptr< Process > p)
Definition: newProcess.cpp:21
static System * getInstance()
Definition: system.cpp:28
static std::shared_ptr< Process > createProcess(double cpuLambda, double ioLambda)
creates an "interactive" process
Definition: process.cpp:52
void scheduleTask(TriggeringEvent trigger)
This function is the scheduler. When called, it schedule the task to be executed on the processor ama...
TaskScheduler * getScheduler()
returns the task scheduler object
Definition: system.cpp:110
std::shared_ptr< Event > insert(std::shared_ptr< Event > e)
Definition: eventList.cpp:56
double drawExp(double lambda)
bool renew
Definition: event.h:59
TriggeringEvent eventType
The event type is need by the scheduling discipline, to determine if this kind of event triggers invo...
Definition: event.h:64
void process() override
handle the the event TODO: &#39;process&#39; is maybe not the best word for that, given that our simulator ac...
static EventList * getInstance()
Singleton pattern.
Definition: eventList.cpp:22
double time
Definition: event.h:58