forked from jontore/LinSched
-
Notifications
You must be signed in to change notification settings - Fork 1
/
linsched.c
57 lines (48 loc) · 1.99 KB
/
linsched.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* LinSched -- The Linux Scheduler Simulator
* Copyright (C) 2008 John M. Calandrino
* E-mail: [email protected]
*
* Example scheduling simulation. Tasks are created and then the simulation
* is run for some number of ticks.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see COPYING); if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "linsched.h"
int main(int argc, char **argv)
{
/* Initialize linsched. */
linsched_init();
/* Create some tasks with "callbacks" that should be called
* every scheduling decision.
*/
linsched_create_normal_task(&linsched_announce_callback, 0);
linsched_create_normal_task(&linsched_announce_callback, 0);
linsched_create_normal_task(&linsched_announce_callback, -5);
linsched_create_normal_task(&linsched_announce_callback, 5);
linsched_create_batch_task(&linsched_announce_callback, 15);
linsched_create_batch_task(&linsched_announce_callback, -1);
linsched_create_RTrr_task(&linsched_announce_callback, 90);
linsched_create_RTfifo_task(&linsched_announce_callback, 55);
// create more tasks here...
/* Run simulation for 500 ticks. */
linsched_run_sim(500);
/* Force migrations between two CPUs, and allow migrations
* afterwards (so load balancing will kick in eventually).
*/
linsched_force_migration(linsched_get_task(2), 0, 1);
/* Run simulation to completion. */
linsched_run_sim(LINSCHED_TICKS-500);
return 0;
}